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

Function getNumComponents

source/MRMesh/MRPolylineComponents.cpp:46–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44{
45
46size_t getNumComponents( const PolylineTopology& topology )
47{
48 MR_TIMER;
49 auto unionFindStruct = getUnionFindStructure( topology );
50
51 std::atomic<size_t> res{ 0 };
52 tbb::parallel_for( tbb::blocked_range<UndirectedEdgeId>( 0_ue, UndirectedEdgeId( unionFindStruct.size() ) ),
53 [&] ( const tbb::blocked_range<UndirectedEdgeId>& range )
54 {
55 size_t myRoots = 0;
56 for ( auto ue = range.begin(); ue < range.end(); ++ue )
57 {
58 if ( !topology.hasEdge( ue ) )
59 continue;
60 if ( ue == unionFindStruct.findUpdateRange( ue, range.begin(), range.end() ) )
61 ++myRoots;
62 }
63 res.fetch_add( myRoots, std::memory_order_relaxed );
64 } );
65 return res;
66}
67
68UndirectedEdgeBitSet getComponent( const PolylineTopology& topology, UndirectedEdgeId id )
69{

Callers

nothing calls this directly

Calls 6

getUnionFindStructureFunction · 0.85
findUpdateRangeMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
hasEdgeMethod · 0.45

Tested by

no test coverage detected