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

Function findMultipleEdges

source/MRMesh/MRMeshFixer.cpp:81–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81Expected<std::vector<MultipleEdge>> findMultipleEdges( const MeshTopology& topology, ProgressCallback cb )
82{
83 MR_TIMER;
84 tbb::enumerable_thread_specific<std::vector<MultipleEdge>> threadData;
85 const VertId lastValidVert = topology.lastValidVert();
86
87 auto mainThreadId = std::this_thread::get_id();
88 std::atomic<bool> keepGoing{ true };
89 std::atomic<size_t> numDone{ 0 };
90 tbb::parallel_for( tbb::blocked_range<size_t>( size_t{ 0 }, size_t( lastValidVert ) + 1 ), [&] ( const tbb::blocked_range<size_t>& range )
91 {
92 auto & tls = threadData.local();
93 std::vector<VertId> neis;
94 for ( VertId v = VertId( range.begin() ); v < VertId( range.end() ); ++v )
95 {
96 if ( cb && !keepGoing.load( std::memory_order_relaxed ) )
97 break;
98
99 if ( !topology.hasVert( v ) )
100 continue;
101 neis.clear();
102 for ( auto e : orgRing( topology, v ) )
103 {
104 auto nv = topology.dest( e );
105 if ( nv > v )
106 neis.push_back( nv );
107 }
108 std::sort( neis.begin(), neis.end() );
109 auto it = neis.begin();
110 for (;;)
111 {
112 it = std::adjacent_find( it, neis.end() );
113 if ( it == neis.end() )
114 break;
115 auto nv = *it;
116 tls.emplace_back( v, nv );
117 assert( nv == *( it + 1 ) );
118 ++++it;
119 while ( it != neis.end() && *it == nv )
120 ++it;
121 if ( it == neis.end() )
122 break;
123 }
124 }
125
126 if ( cb )
127 numDone += range.size();
128
129 if ( cb && std::this_thread::get_id() == mainThreadId )
130 {
131 if ( !cb( float( numDone ) / float( lastValidVert + 1 ) ) )
132 keepGoing.store( false, std::memory_order_relaxed );
133 }
134 } );
135
136 if ( !keepGoing.load( std::memory_order_relaxed ) || ( cb && !cb( 1.0f ) ) )
137 return unexpectedOperationCanceled();
138

Callers 3

hasMultipleEdgesFunction · 0.85
fixMultipleEdgesFunction · 0.85

Calls 12

orgRingFunction · 0.85
push_backMethod · 0.80
insertMethod · 0.80
lastValidVertMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
loadMethod · 0.45
hasVertMethod · 0.45
clearMethod · 0.45
destMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected