@@ -521,50 +521,48 @@ OneMeshContours getOneMeshIntersectionContours( const Mesh& meshA, const Mesh& m
521
521
const auto & mainMesh = getMeshAIntersections ? meshA : meshB;
522
522
const auto & otherMesh = getMeshAIntersections ? meshB : meshA;
523
523
res.resize ( contours.size () );
524
- for ( int j = 0 ; j < contours. size (); ++ j )
524
+ ParallelFor ( contours, [&]( size_t j )
525
525
{
526
- auto & curOutContour = res[j].intersections ;
526
+ OneMeshContour cur;
527
+ auto & curOutContour = cur.intersections ;
527
528
const auto & curInContour = contours[j];
528
- res[j].closed = isClosed ( curInContour );
529
529
curOutContour.resize ( curInContour.size () );
530
530
531
- tbb::parallel_for ( tbb::blocked_range<size_t >( 0 , curInContour.size () ),
532
- [&]( const tbb::blocked_range<size_t >& range )
531
+ ParallelFor ( curOutContour, [&]( size_t i )
533
532
{
534
533
Vector3f a, b, c, d, e;
535
- for ( size_t i = range.begin (); i < range.end (); ++i )
536
- {
537
- const auto & inIntersection = curInContour[i];
538
- auto & outIntersection = curOutContour[i];
539
-
540
- bool edgeMain = getMeshAIntersections == inIntersection.isEdgeATriB ;
541
- if ( edgeMain )
542
- {
543
- outIntersection.primitiveId = inIntersection.edge ;
544
- otherMesh.getTriPoints ( inIntersection.tri , a, b, c );
545
- d = mainMesh.orgPnt ( inIntersection.edge );
546
- e = mainMesh.destPnt ( inIntersection.edge );
547
- }
548
- else
549
- {
550
- outIntersection.primitiveId = inIntersection.tri ;
551
- mainMesh.getTriPoints ( inIntersection.tri , a, b, c );
552
- d = otherMesh.orgPnt ( inIntersection.edge );
553
- e = otherMesh.destPnt ( inIntersection.edge );
554
- }
555
- // always calculate in mesh A space
556
- outIntersection.coordinate = findTriangleSegmentIntersectionPrecise (
557
- getCoord ( a, !inIntersection.isEdgeATriB ),
558
- getCoord ( b, !inIntersection.isEdgeATriB ),
559
- getCoord ( c, !inIntersection.isEdgeATriB ),
560
- getCoord ( d, inIntersection.isEdgeATriB ),
561
- getCoord ( e, inIntersection.isEdgeATriB ), converters );
534
+ const auto & inIntersection = curInContour[i];
535
+ auto & outIntersection = curOutContour[i];
562
536
563
- if ( !getMeshAIntersections && rigidB2A )
564
- outIntersection.coordinate = inverseXf ( outIntersection.coordinate );
537
+ bool edgeMain = getMeshAIntersections == inIntersection.isEdgeATriB ;
538
+ if ( edgeMain )
539
+ {
540
+ outIntersection.primitiveId = inIntersection.edge ;
541
+ otherMesh.getTriPoints ( inIntersection.tri , a, b, c );
542
+ d = mainMesh.orgPnt ( inIntersection.edge );
543
+ e = mainMesh.destPnt ( inIntersection.edge );
544
+ }
545
+ else
546
+ {
547
+ outIntersection.primitiveId = inIntersection.tri ;
548
+ mainMesh.getTriPoints ( inIntersection.tri , a, b, c );
549
+ d = otherMesh.orgPnt ( inIntersection.edge );
550
+ e = otherMesh.destPnt ( inIntersection.edge );
565
551
}
552
+ // always calculate in mesh A space
553
+ outIntersection.coordinate = findTriangleSegmentIntersectionPrecise (
554
+ getCoord ( a, !inIntersection.isEdgeATriB ),
555
+ getCoord ( b, !inIntersection.isEdgeATriB ),
556
+ getCoord ( c, !inIntersection.isEdgeATriB ),
557
+ getCoord ( d, inIntersection.isEdgeATriB ),
558
+ getCoord ( e, inIntersection.isEdgeATriB ), converters );
559
+
560
+ if ( !getMeshAIntersections && rigidB2A )
561
+ outIntersection.coordinate = inverseXf ( outIntersection.coordinate );
566
562
} );
567
- }
563
+ cur.closed = isClosed ( curInContour );
564
+ res[j] = std::move ( cur );
565
+ } );
568
566
return res;
569
567
}
570
568
0 commit comments