| 488 | } |
| 489 | |
| 490 | void 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; |