/** * Simplifies a mesh, merging its faces. */ bool BOP_Merge::mergeFaces() { BOP_Indexs mergeVertices; BOP_Vertexs vertices = m_mesh->getVertexs(); BOP_IT_Vertexs v = vertices.begin(); const BOP_IT_Vertexs verticesEnd = vertices.end(); // Advance to first mergeable vertex advance(v,m_firstVertex); BOP_Index pos = m_firstVertex; // Add unbroken vertices to the list while(v!=verticesEnd) { if ((*v)->getTAG() != BROKEN) mergeVertices.push_back(pos); v++;pos++; } // Merge faces with that vertices return mergeFaces(mergeVertices); }
void BOP_Merge2::cleanup( void ) { BOP_Edges edges = m_mesh->getEdges(); for (BOP_IT_Edges edge = edges.begin(); edge != edges.end(); ++edge) { BOP_Indexs faces = (*edge)->getFaces(); for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); ++face) { BOP_Face *f = m_mesh->getFace(*face); if(f->getTAG()== UNCLASSIFIED) ; else (*edge)->removeFace(*face); } if( (*edge)->getFaces().size() == 0) (*edge)->setUsed(false); } BOP_Vertexs v = m_mesh->getVertexs(); for( BOP_IT_Vertexs it = v.begin(); it != v.end(); ++it ) { if( (*it)->getTAG() != BROKEN) { BOP_Indexs iedges = (*it)->getEdges(); for(BOP_IT_Indexs i = iedges.begin();i!=iedges.end();i++) if( m_mesh->getEdge((*i))->getUsed( ) == false) (*it)->removeEdge( *i ); if( (*it)->getEdges().size() == 0 ) (*it)->setTAG(BROKEN); } } // clean_nonmanifold( m_mesh ); }
void dumpmesh ( BOP_Mesh *m, bool force ) { unsigned int nonmanifold = 0; { BOP_Edges edges = m->getEdges(); int count = 0; for (BOP_IT_Edges edge = edges.begin(); edge != edges.end(); ++count, ++edge) { if (!(*edge)->getUsed() && (*edge)->getFaces().size() == 0 ) continue; BOP_Vertex * v1 = m->getVertex((*edge)->getVertex1()); BOP_Vertex * v2 = m->getVertex((*edge)->getVertex2()); if(v1->getTAG()!= BROKEN || v2->getTAG()!= BROKEN ) { int fcount = 0; BOP_Indexs faces = (*edge)->getFaces(); for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); face++) { BOP_Face *f = m->getFace(*face); if(f->getTAG()== UNCLASSIFIED) ++fcount; } if(fcount !=0 && fcount !=2 ) { ++nonmanifold; } } } if (!force && nonmanifold == 0) return; } if( nonmanifold ) cout << nonmanifold << " edges detected" << endl; #ifdef BOP_DEBUG cout << "---------------------------" << endl; BOP_Edges edges = m->getEdges(); int count = 0; for (BOP_IT_Edges edge = edges.begin(); edge != edges.end(); ++count, ++edge) { BOP_Vertex * v1 = m->getVertex((*edge)->getVertex1()); BOP_Vertex * v2 = m->getVertex((*edge)->getVertex2()); if(v1->getTAG()!= BROKEN || v2->getTAG()!= BROKEN ) { int fcount = 0; BOP_Indexs faces = (*edge)->getFaces(); cout << count << ", " << (*edge) << ", " << faces.size() << endl; for (BOP_IT_Indexs face = faces.begin(); face != faces.end(); face++) { BOP_Face *f = m->getFace(*face); if(f->getTAG()== UNCLASSIFIED) ++fcount; cout << " face " << f << endl; } if(fcount !=0 && fcount !=2 ) cout << " NON-MANIFOLD" << endl; } } BOP_Faces faces = m->getFaces(); count = 0; for (BOP_IT_Faces face = faces.begin(); face != faces.end(); face++) { if( count < 12*2 || (*face)->getTAG() != BROKEN ) { cout << count << ", " << *face << endl; } ++count; } BOP_Vertexs verts = m->getVertexs(); count = 0; for (BOP_IT_Vertexs vert = verts.begin(); vert != verts.end(); vert++) { cout << count++ << ", " << *vert << " " << (*vert)->getNumEdges() << endl; BOP_Indexs edges = (*vert)->getEdges(); for( BOP_IT_Indexs it = edges.begin(); it != edges.end(); ++it) { BOP_Edge *edge = m->getEdge(*it); cout << " " << edge << endl; } } cout << "===========================" << endl; #endif }