| 460 | } //anonymous namespace |
| 461 | |
| 462 | void 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 | |
| 490 | void getOneMeshIntersectionContours( const Mesh& meshA, const Mesh& meshB, const ContinuousContours& contours, |
| 491 | OneMeshContours* outA, OneMeshContours* outB, |
no test coverage detected