Beispiel #1
0
// input is data from mesh.Append(append, TMap, VMap) - copy/rewrite faces from appendpolys
void MeshPolygons::AppendPolygons( VFTriangleMesh & mesh, 
								   VFTriangleMesh & append, MeshPolygons & appendpolys, 
								   VertexMap & VMap, TriangleMap & TMap, UVMap * pUVMap )
{
	std::vector<IMesh::VertexID> vBoundary;
	std::vector<unsigned int> vBoundaryUV;
	id_iterator curp(appendpolys.begin()), endp(appendpolys.end());
	while ( curp != endp ) {
		PolygonID sID = *curp++;

		const std::vector<IMesh::TriangleID> & vTris = appendpolys.GetTriangles(sID);
		size_t nCount = vTris.size();
		PolygonID sNewID = CreatePolygon((unsigned int)nCount);
		for ( unsigned int k = 0; k < nCount; ++k )
			AppendTriangle( sNewID, TMap.GetNew(vTris[k]) );

		const std::vector<IMesh::VertexID> & vOldBoundary = appendpolys.GetBoundary(sID);
		const std::vector<unsigned int> & vOldBoundaryUV = appendpolys.GetBoundaryUV(sID);
		nCount = vOldBoundary.size();
		vBoundary.resize(nCount);
		for ( unsigned int k = 0; k < nCount; ++k )
			vBoundary[k] = VMap.GetNew( vOldBoundary[k] );
		if ( pUVMap ) {
			nCount = vOldBoundaryUV.size();
			vBoundaryUV.resize(nCount);
			for ( unsigned int k = 0; k < nCount; ++k )
				vBoundaryUV[k] = pUVMap->GetNew( vOldBoundaryUV[k] );
		} else
			vBoundaryUV = vOldBoundaryUV;

		SetBoundary(sNewID, vBoundary, &vBoundaryUV);
	}
}
Beispiel #2
0
void MeshPolygons::RewriteBoundaries( const VertexMap & VMap )
{
	std::set<Polygon>::iterator curt(m_vPolygons.begin()), endt(m_vPolygons.end());
	while ( curt != endt ) {
		Polygon & t = const_cast<Polygon&>(*curt++);
		size_t nVerts = t.vBoundary.size();
		for ( unsigned int k = 0; k < nVerts; ++k ) {
			IMesh::VertexID vNew = VMap.GetNew(t.vBoundary[k]);
			if ( vNew != IMesh::InvalidID )
				t.vBoundary[k] = vNew;
		}
	}
}
Beispiel #3
0
void MeshPolygons::Rewrite( const VertexMap & VMap, const TriangleMap & TMap )
{
	m_PolygonMap.clear();

	std::set<Polygon>::iterator curt(m_vPolygons.begin()), endt(m_vPolygons.end());
	while ( curt != endt ) {
		Polygon & t = const_cast<Polygon&>(*curt++);
		size_t nTris = t.vTris.size();
		for ( unsigned int k = 0 ; k < nTris; ++k ) {
			IMesh::TriangleID tNew = TMap.GetNew( t.vTris[k] );
			if ( tNew != IMesh::InvalidID )
				t.vTris[k] = tNew;
			m_PolygonMap.insert( std::pair<IMesh::TriangleID, PolygonID>( t.vTris[k], t.id ) );
		}
		size_t nVerts = t.vBoundary.size();
		for ( unsigned int k = 0; k < nVerts; ++k ) {
			IMesh::VertexID vNew = VMap.GetNew( t.vBoundary[k] );
			if ( vNew != IMesh::InvalidID )
				t.vBoundary[k] = vNew;
		}
	}
}