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

Function makeTriangleHashMap

source/MRMesh/MRLocalTriangulations.cpp:151–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149static_assert( sizeof( Repetitions ) == 1 );
150
151static ParallelHashMap<UnorientedTriangle, Repetitions> makeTriangleHashMap( const AllLocalTriangulations & triangs )
152{
153 MR_TIMER;
154
155 ParallelHashMap<UnorientedTriangle, Repetitions> map;
156 ParallelFor( size_t(0), map.subcnt(), [&]( size_t myPartId )
157 {
158 for ( VertId v = 0_v; v + 1 < triangs.fanRecords.size(); ++v )
159 {
160 const auto border = triangs.fanRecords[v].border;
161 const auto nbeg = triangs.fanRecords[v].firstNei;
162 const auto nend = triangs.fanRecords[v+1].firstNei;
163 for ( auto n = nbeg; n < nend; ++n )
164 {
165 if ( triangs.neighbors[n] == border )
166 continue;
167 const auto next = triangs.neighbors[n + 1 < nend ? n + 1 : nbeg];
168 bool flipped = false;
169 const UnorientedTriangle triplet( { v, next, triangs.neighbors[n] }, &flipped );
170 const auto hashval = map.hash( triplet );
171 const auto idx = map.subidx( hashval );
172 if ( idx != myPartId )
173 continue;
174 Repetitions & r = map[triplet];
175 if ( flipped )
176 ++r.oppositeOriented;
177 else
178 ++r.sameOriented;
179 }
180 }
181 } );
182 return map;
183}
184
185TrianglesRepetitions computeTrianglesRepetitions( const AllLocalTriangulations & triangs )
186{

Calls 2

ParallelForFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected