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

Method getNew2OldFaceMap

source/MRMesh/MRBooleanOperation.cpp:374–412  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372}
373
374FaceMap BooleanResultMapper::getNew2OldFaceMap( MapObject obj ) const
375{
376 const auto& map = maps[int( obj )];
377 size_t maxNewFace = 0;
378 // find last "new face" for given obj part
379 maxNewFace = tbb::parallel_reduce( tbb::blocked_range( size_t( 0 ), map.cut2origin.size() ), size_t( 0 ),
380 [&map] ( const auto& range, auto curr )
381 {
382 for ( auto i = range.begin(); i < range.end(); ++i )
383 {
384 FaceId cf = FaceId( i );
385 auto of = map.cut2origin[cf];
386 if ( !of )
387 continue;
388 auto nf = cf < map.cut2newFaces.size() ? map.cut2newFaces[cf] : FaceId();
389 if ( !nf )
390 continue;
391 curr = std::max( curr, size_t( nf ) );
392 }
393 return curr;
394 }, [] ( auto a, auto b )
395 {
396 return std::max( a, b );
397 } );
398
399 // fill map in parallel
400 FaceMap outMap( maxNewFace );
401 ParallelFor( map.cut2origin, [&] ( FaceId cf )
402 {
403 auto of = map.cut2origin[cf];
404 if ( !of )
405 return;
406 auto nf = cf < map.cut2newFaces.size() ? map.cut2newFaces[cf] : FaceId();
407 if ( !nf )
408 return;
409 outMap[nf] = of;
410 } );
411 return outMap;
412}
413
414} //namespace MR

Callers 2

EMSCRIPTEN_BINDINGSFunction · 0.80

Calls 5

maxFunction · 0.85
ParallelForFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected