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

Function getOneMeshIntersectionContours

source/MRMesh/MROneMeshContours.cpp:490–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

488}
489
490void getOneMeshIntersectionContours( const Mesh& meshA, const Mesh& meshB, const ContinuousContours& contours,
491 OneMeshContours* outA, OneMeshContours* outB,
492 const CoordinateConverters& converters, const AffineXf3f* rigidB2A, Contours3f* outPtsA, bool addSelfyTerminalVerts )
493{
494 MR_TIMER;
495 assert( outA || outB || outPtsA );
496 // addSelfyTerminalVerts is supported only if both meshes are actually the same without any relative transformation
497 assert( !addSelfyTerminalVerts || ( &meshA == &meshB && !rigidB2A ) );
498
499 std::function<Vector3f( const Vector3f& coord, bool meshA )> getCoord;
500
501 if ( !rigidB2A )
502 {
503 getCoord = []( const Vector3f& coord, bool )
504 {
505 return coord;
506 };
507 }
508 else
509 {
510 getCoord = [xf = *rigidB2A]( const Vector3f& coord, bool meshA )
511 {
512 return meshA ? coord : xf( coord );
513 };
514 }
515 AffineXf3f inverseXf;
516 if ( rigidB2A )
517 inverseXf = rigidB2A->inverse();
518 if ( outA )
519 outA->resize( contours.size() );
520 if ( outB )
521 outB->resize( contours.size() );
522 if ( outPtsA )
523 outPtsA->resize( contours.size() );
524 ParallelFor( contours, [&]( size_t j )
525 {
526 OneMeshContour curA, curB;
527 Contour3f ptsA;
528 const auto& curInContour = contours[j];
529 if ( curInContour.empty() )
530 return;
531 curA.closed = curB.closed = isClosed( curInContour );
532 if ( outA )
533 curA.intersections.resize( curInContour.size() );
534 if ( outB )
535 curB.intersections.resize( curInContour.size() );
536 if ( outPtsA )
537 resizeNoInit( ptsA, curInContour.size() );
538
539 ParallelFor( curInContour, [&]( size_t i )
540 {
541 Vector3f a, b, c, d, e;
542 const auto& inIntersection = curInContour[i];
543 OneMeshIntersection pntA, pntB;
544
545 if ( inIntersection.isEdgeATriB() )
546 {
547 pntA.primitiveId = inIntersection.edge;

Callers 6

TESTFunction · 0.85
EMSCRIPTEN_BINDINGSFunction · 0.85
findIntersectionContoursFunction · 0.85
booleanImplFunction · 0.85

Calls 15

ParallelForFunction · 0.85
getCoordFunction · 0.85
isEdgeATriBMethod · 0.80
triMethod · 0.80
getTriPointsMethod · 0.80
rightMethod · 0.80
isTriVertMethod · 0.80
insertMethod · 0.80
leftMethod · 0.80
push_backMethod · 0.80
isClosedFunction · 0.70

Tested by 2

TESTFunction · 0.68