void GW_Mesh::ExtractBoundary( GW_Vertex& seed, T_VertexList& boundary, T_VertexMap* pExtracted ) { GW_ASSERT( seed.IsBoundaryVertex() ); GW_Vertex* pPrev = NULL; GW_Vertex* pCur = &seed; GW_Vertex* pNext = NULL; GW_U32 num = 0; do { num++; boundary.push_back(pCur); if( pExtracted!=NULL ) (*pExtracted)[ pCur->GetID() ] = pCur; pNext = NULL; for( GW_VertexIterator it = pCur->BeginVertexIterator(); (it!=pCur->EndVertexIterator()) && (pNext==NULL); ++it ) { GW_Vertex* pVert = *it; if( pVert->IsBoundaryVertex() && pVert!=pPrev ) pNext = pVert; } GW_ASSERT( pNext!=NULL ); pPrev = pCur; pCur = pNext; } while( pCur!=&seed && pNext!=NULL && num<this->GetNbrVertex() ); }
void GW_Mesh::ExtractAllBoundaries( std::list<T_VertexList>& boundary_list ) { T_VertexMap AlreadyExtracted; for( GW_U32 i=0; i<this->GetNbrVertex(); ++i ) { GW_Vertex* pVert = this->GetVertex(i); GW_ASSERT( pVert!=NULL ); if( pVert->IsBoundaryVertex() && AlreadyExtracted.find(i)==AlreadyExtracted.end() ) { T_VertexList boundary; this->ExtractBoundary( *pVert, boundary, &AlreadyExtracted ); boundary_list.push_back( boundary ); } } }