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

Function subdivideLoneContours

source/MRMesh/MROneMeshContours.cpp:462–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460} //anonymous namespace
461
462void subdivideLoneContours( Mesh& mesh, const OneMeshContours& contours, FaceHashMap* new2oldMap /*= nullptr */ )
463{
464 MR_TIMER;
465 MR_WRITER( mesh );
466 HashMap<FaceId, std::vector<int>> face2contoursMap;
467 for ( int i = 0; i < contours.size(); ++i )
468 {
469 FaceId f = std::get<FaceId>( contours[i].intersections.front().primitiveId );
470 face2contoursMap[f].push_back( i );
471 }
472 for ( auto& [faceId, conts] : face2contoursMap )
473 {
474 assert( !conts.empty() );
475 Vector3f massCenter;
476 int counter = 0;
477 // here we find centroid of first lone contour of this face because
478 // splitting with average centroid does not guarantee that any lone contour will be subdivided
479 // and splitting with first contour centroid guarantee that at least this contour will be subdivided
480 for ( const auto& p : contours[conts.front()].intersections )
481 {
482 ++counter;
483 massCenter += p.coordinate;
484 }
485 massCenter /= float( counter );
486 mesh.splitFace( faceId, massCenter, nullptr, new2oldMap );
487 }
488}
489
490void getOneMeshIntersectionContours( const Mesh& meshA, const Mesh& meshB, const ContinuousContours& contours,
491 OneMeshContours* outA, OneMeshContours* outB,

Callers 3

subdivideSelfLoneFunction · 0.85
booleanImplFunction · 0.85
prepareTerrainCutMethod · 0.85

Calls 4

push_backMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
splitFaceMethod · 0.45

Tested by

no test coverage detected