void TriangleMesh::splitAllFaces() { const std::vector<Face*> faceListCopy = getFaceList(); for(unsigned int i=0; i<faceListCopy.size(); ++i) splitFace(*faceList[i]); }
void Mesh::triangulateAllFaces() { for(int i = 0; i < faces.size(); i++) { // Pick a vertex on the face to "fan out" from Vertex *fanVert = faces[i].halfEdge->vertex; HalfEdge *he = faces[i].halfEdge->next->next; do // loop over all vertices except the one we just picked, and the one right next to it { splitFace(&faces[i], fanVert, he->vertex); } while(he->next != faces[i].halfEdge); } }
static void randomize(Graph &graph, const int32 seed) { check(graph.CountNodes() == 4u); check(graph.CountHalfEdges() == 8u); check(graph.CountFaces() == 2u); FRandomStream random(seed); /// @todo We skip first face because is the surrounding face. But this won't /// be always the case, if the graph is generated differently it might be a /// different one. Graph::Face *face = &*(++graph.GetFaces().begin()); do { face = splitFace(graph, *face, random); #ifdef CARLA_ROAD_GENERATOR_EXTRA_LOG graph.PrintToLog(); #endif // CARLA_ROAD_GENERATOR_EXTRA_LOG } while (face != nullptr); }
void CstmCGAL::splitFace(Mesh& mesh, face_descriptor f) { if (mesh.degree(f) > 4) { halfedge_descriptor h = mesh.halfedge(f); mesh.set_face(h,Mesh::null_face()); mesh.set_face(mesh.next(h),Mesh::null_face()); mesh.add_face( mesh.source(h), mesh.source(mesh.next(h)), mesh.source(mesh.next(mesh.next(h))) ); mesh.set_face(mesh.opposite(mesh.prev(h)),f); mesh.set_halfedge(f,mesh.opposite(mesh.prev(h))); splitFace(mesh, f); } }
// Subdivide a cell and add the subcells to the octree int OctreeGrid::splitCell(int cellId, bool graded, bool paired) { oct_debug(cellId != -1); oct_debug(cellIsLeaf(cellId)); const Cell &cell = m_Cells[cellId]; // Retrieve cell corners const int v0 = cell.corner(CORNER_X0_Y0_Z0); const int v1 = cell.corner(CORNER_X1_Y0_Z0); const int v2 = cell.corner(CORNER_X1_Y1_Z0); const int v3 = cell.corner(CORNER_X0_Y1_Z0); const int v4 = cell.corner(CORNER_X0_Y0_Z1); const int v5 = cell.corner(CORNER_X1_Y0_Z1); const int v6 = cell.corner(CORNER_X1_Y1_Z1); const int v7 = cell.corner(CORNER_X0_Y1_Z1); // Start by splitting incident faces const int f0 = splitFace(v0, v3, v4, v7, X); const int f1 = splitFace(v1, v2, v5, v6, X); const int f2 = splitFace(v0, v1, v4, v5, Y); const int f3 = splitFace(v3, v2, v7, v6, Y); const int f4 = splitFace(v0, v1, v3, v2, Z); const int f5 = splitFace(v4, v5, v7, v6, Z); // Then connect the middle points of the faces createNodeLinks(f0, f1, X); createNodeLinks(f2, f3, Y); createNodeLinks(f4, f5, Z); const int c0 = splitEdge(f0, f1, X); updateNodeLinks(f2, f3, c0, Y); updateNodeLinks(f4, f5, c0, Z); // Retrieve midpoint of cell edges const int e01 = getMidEdgeNode(v0, v1, X); const int e32 = getMidEdgeNode(v3, v2, X); const int e45 = getMidEdgeNode(v4, v5, X); const int e76 = getMidEdgeNode(v7, v6, X); const int e03 = getMidEdgeNode(v0, v3, Y); const int e12 = getMidEdgeNode(v1, v2, Y); const int e47 = getMidEdgeNode(v4, v7, Y); const int e56 = getMidEdgeNode(v5, v6, Y); const int e04 = getMidEdgeNode(v0, v4, Z); const int e15 = getMidEdgeNode(v1, v5, Z); const int e26 = getMidEdgeNode(v2, v6, Z); const int e37 = getMidEdgeNode(v3, v7, Z); // Create a new cell for each subvolume const int offset = (int) m_Cells.size(); m_Cells.resize(m_Cells.size() + 8); m_Cells[offset+CORNER_X0_Y0_Z0].cornerNodeId = {{v0, e01, f4, e03, e04, f2, c0, f0}}; m_Cells[offset+CORNER_X1_Y0_Z0].cornerNodeId = {{e01, v1, e12, f4, f2, e15, f1, c0}}; m_Cells[offset+CORNER_X1_Y1_Z0].cornerNodeId = {{f4, e12, v2, e32, c0, f1, e26, f3}}; m_Cells[offset+CORNER_X0_Y1_Z0].cornerNodeId = {{e03, f4, e32, v3, f0, c0, f3, e37}}; m_Cells[offset+CORNER_X0_Y0_Z1].cornerNodeId = {{e04, f2, c0, f0, v4, e45, f5, e47}}; m_Cells[offset+CORNER_X1_Y0_Z1].cornerNodeId = {{f2, e15, f1, c0, e45, v5, e56, f5}}; m_Cells[offset+CORNER_X1_Y1_Z1].cornerNodeId = {{c0, f1, e26, f3, f5, e56, v6, e76}}; m_Cells[offset+CORNER_X0_Y1_Z1].cornerNodeId = {{f0, c0, f3, e37, e47, f5, e76, v7}}; // Update link to child cell m_Cells[cellId].firstChild = offset; // Update cell adjacency relations for (int axis = 0; axis < 3; ++axis) { updateSubcellLinks(cellId, axis); updateSubcellLinks(cellId, nextCell(cellId, axis), axis); updateSubcellLinks(prevCell(cellId, axis), cellId, axis); } // Ensure proper 2:1 grading if (graded) { makeCellGraded(cellId, paired); } // Ensure children are either all leaves, or all internal cells if (paired) { makeCellPaired(cellId, graded); if (cellId < m_NumRootCells) { // Special case for root cells: if one gets split, then we need to split all root cells for (int c = 0; c < m_NumRootCells; ++c) { if (cellIsLeaf(c)) { splitCell(c, graded, paired); } } } else { // Ensure sibling cells are also properly split int firstSibling = m_NumRootCells + 8 * ((cellId - m_NumRootCells) / 8); for (int c = firstSibling; c < firstSibling + 8; ++c) { if (cellIsLeaf(c)) { splitCell(c, graded, paired); } } } } return c0; }
//------------------------------------------------------------------------------------------- void vertexFty::doIt() //------------------------------------------------------------------------------------------- { meshCreator& creator = *ftyCreator; MIntArray& vtxList = *selVtxIDs; BPT_Helpers helper; //MERKE:Diese prozedur arbeitet nur mit dem MeshCreator, benutzt also kein MFnMesh etc. //zuersteinmal ein Ba aufbauen mit den gewählten vertizen BPT_BA selCheckList(vtxList,true,false,creator.getLastVtxID()); //ArbeitsArray für die folgende Prozedur // BPT_BA selList = selCheckList; //wird als lookup verwendet, der nicht verändert wird //Die einfachste Lösung: Ba aufbauen mit allen Faces, die schon bearbeitet wurden - bedeutet aber auch, dass für jeden SelVtx die //verbundenen Faces geholt werden müssen - momentan ist die Sache ziemlich billig (CPU ZEIT) //man müsste zuerst die verbundenen Faces zu allen Vertizen holen, und dese Dann abarbeiten MIntArray allConnectedFaces; UINT r = null; UINT l,i,x; //für iterationen // UINT cv; // == currentVtx MIntArray faceVtx; //vertizen des jeweiligen faces MIntArray connectedFaces; //hält die mit dem Vtx verbundenen Faces MIntArray match; //Array fr übereinstimmende Vtx //jetzt durch die SelVtx parsen und eine Facezurodnung herstellen l = vtxList.length(); //alle verbundenen Faces holen for(i = null; i < l; i++) { creator.getConnectedFaces(vtxList[i],connectedFaces); allConnectedFaces.setLength(allConnectedFaces.length() + connectedFaces.length()); for(x = null; x < connectedFaces.length(); x++) { allConnectedFaces[r++] = connectedFaces[x]; } } helper.memoryPrune(allConnectedFaces); l = allConnectedFaces.length(); for(i = null; i < l; i++) { creator.getFaceVtxIDs(allConnectedFaces[i],faceVtx); selCheckList.findMatching(faceVtx, match); if(match.length() > 1) splitFace(faceVtx,match,allConnectedFaces[i]); } /* for(i = 0; i < l; i++) { cv = vtxList[i]; //wenn der gegenwärtige Vtx noch nicht bearbeitet wurde if( ! selCheckList[cv]) //hier lieber operator [] nehmen, da isFlagSet noch nen unnötigen rangecheck macht { continue; } //ansonsten weitermachen und: //die verbundenen Faces holen creator.getConnectedFaces(cv,connectedFaces); //jetzt in jedem verbundenen Face checken, ob von den entsprechenden faceVertices //gewählte vertices vorhanden sind //zuvor aber den gegenwärtigen cv entfernen selCheckList.setBitFalse(cv); for(x = 0; x < connectedFaces.length(); x++) { creator.getFaceVtxIDs(connectedFaces[x],faceVtx); //wenn mehr als nur der cv auf dem face gewählt sind, dann connectProzedur starten selList.findMatching(faceVtx, match); //if(match.length() > 1) if(match.length() > 1) //nur testweise {//es handelt sich um ein gültiges face, da mindestens 2 vertizen im Face gewählt waren ->splitten INVIS(helper.printArray(faceVtx," = zu bearbeitendes Face");); splitFace(faceVtx, match, connectedFaces[x]); //zuguterletzt noch die matches aus selCheckList entfernen, damit diese nicht nochmal bearbeitet werden selCheckList.remove(match); } } } */ }
void CstmCGAL::splitFaces(Mesh& mesh) { Mesh::Face_range::iterator f, f_end; for (boost::tie(f,f_end) = mesh.faces(); f != f_end ; f++) { splitFace(mesh,*f); } }