void Foam::MeshedSurface<triFace>::transcribe(MeshedSurface<face>& surf) { // first triangulate surf.triangulate(); this->storedPoints().transfer(surf.storedPoints()); this->storedZones().transfer(surf.storedZones()); // transcribe from face -> triFace List<face>& origFaces = surf.storedFaces(); List<triFace> newFaces(origFaces.size()); forAll(origFaces, facei) { newFaces[facei] = triFace ( static_cast<const labelUList&>(origFaces[facei]) ); }
dgInt32 dgConvexHull4d::AddVertex (const dgBigVector& vertex) { dgSetPrecisionDouble precision; dgInt32 index = -1; dgListNode* const faceNode = FindFacingNode(vertex); if (faceNode) { index = m_count; m_points[index] = vertex; m_points[index].m_index = index; m_count ++; dgList<dgListNode*> newFaces(GetAllocator()); dgList<dgListNode*> deleteList(GetAllocator()); InsertNewVertex(index, faceNode, deleteList, newFaces); for (dgList<dgListNode*>::dgListNode* deleteNode = deleteList.GetFirst(); deleteNode; deleteNode = deleteNode->GetNext()) { dgListNode* const node = deleteNode->GetInfo(); DeleteFace (node); } } return index; }
void TriSoup::RemapData( const std::vector<int>& faceOrder ) { ASSERT(faceOrder.size() == m_faces.size()); // use the new cache aware index buffer to reorder the vertex buffer data. Create a map // from idxOld -> idxNew. const int numVerts = NumVertices(); std::vector<int> vertRemap(numVerts, -1); std::vector<Vertex> newVerts(NumVertices()); std::vector<Face> newFaces(NumFaces()); int curVert = 0; for(int i = 0, c = faceOrder.size(); i < c; ++i) { // put the face in the correct order ASSERT(faceOrder[i] < NumFaces()); newFaces[i] = m_faces[faceOrder[i]]; // remap the vertices in the current face for(int j = 0; j < 3; ++j) { int v0 = newFaces[i].m_vertices[j]; if(vertRemap[v0] == -1) { newVerts[curVert] = m_vertices[v0]; vertRemap[v0] = curVert; ++curVert; } newFaces[i].m_vertices[j] = vertRemap[v0]; } } ASSERT(curVert == (int)vertRemap.size()); m_faces.swap(newFaces); m_vertices.swap(newVerts); }