MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / extractClosedLoops

Function extractClosedLoops

source/MRMesh/MREdgePaths.cpp:417–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417std::vector<EdgeLoop> extractClosedLoops( const MeshTopology & topology, EdgeBitSet & edges )
418{
419 MR_TIMER;
420 std::vector<EdgeLoop> res;
421 for ( ;; )
422 {
423 UnionFind<VertId> vertComponents( topology.vertSize() );
424 EdgeId loopEdge;
425 for ( EdgeId e : edges )
426 {
427 const auto o = topology.org( e );
428 const auto d = topology.dest( e );
429 assert( o != d );
430 if ( vertComponents.united( o, d ) )
431 {
432 loopEdge = e;
433 break;
434 }
435 vertComponents.unite( o, d );
436 }
437 if ( !loopEdge.valid() )
438 break;
439
440 edges.reset( loopEdge );
441 auto path = buildSmallestMetricPath( topology, [&]( EdgeId e )
442 {
443 return edges.test( e.sym() ) ? 1.0f : 1e5f; // sym() because inside buildSmallestMetricPath we search from finish to start
444 }, topology.dest( loopEdge ), topology.org( loopEdge ) );
445 assert ( !path.empty() );
446 for ( EdgeId e : path )
447 {
448 assert( edges.test( e ) );
449 edges.reset( e );
450 }
451
452 path.push_back( loopEdge );
453 assert( isEdgeLoop( topology, path ) );
454
455 res.push_back( std::move( path ) );
456 }
457
458 return res;
459}
460
461std::vector<EdgeLoop> extractClosedLoops( const MeshTopology & topology, const std::vector<EdgeId> & inEdges, EdgeBitSet * outNotLoopEdges )
462{

Callers 1

extractLongestClosedLoopFunction · 0.85

Calls 15

isEdgeLoopFunction · 0.85
unitedMethod · 0.80
uniteMethod · 0.80
push_backMethod · 0.80
buildSmallestMetricPathFunction · 0.70
vertSizeMethod · 0.45
orgMethod · 0.45
destMethod · 0.45
validMethod · 0.45
resetMethod · 0.45
testMethod · 0.45
symMethod · 0.45

Tested by

no test coverage detected