| 76 | }; |
| 77 | |
| 78 | Expected<void> RadiusCompensator::init() |
| 79 | { |
| 80 | MR_TIMER; |
| 81 | const auto& faceRegion = &mesh_.topology.getFaceIds( params_.region ); |
| 82 | assert( faceRegion ); |
| 83 | vertRegion_ = getInnerVerts( mesh_.topology, *faceRegion ); |
| 84 | auto vertRegionWithBounds = getIncidentVerts( mesh_.topology, *faceRegion ); |
| 85 | |
| 86 | if ( MeshComponents::hasFullySelectedComponent( mesh_, vertRegion_ - mesh_.topology.findBdVerts( nullptr, &vertRegion_ ) ) ) |
| 87 | return unexpected( "MeshPart should not contain closed components" ); |
| 88 | |
| 89 | auto [xvec, yvec] = params_.direction.perpendicular(); |
| 90 | toWorldXf_ = AffineXf3f::linear( Matrix3f::fromColumns( xvec, yvec, params_.direction ) ); |
| 91 | toPlaneXf_ = toWorldXf_.inverse(); |
| 92 | |
| 93 | planeVerts_.resize( vertRegionWithBounds.size() ); |
| 94 | bool keepGoing = BitSetParallelFor( vertRegionWithBounds, [&] ( VertId v ) |
| 95 | { |
| 96 | planeVerts_[v] = to3dim( to2dim( toPlaneXf_( mesh_.points[v] ) ) ); |
| 97 | }, subprogress( params_.callback, 0.0f, 0.1f ) ); |
| 98 | |
| 99 | if ( !keepGoing ) |
| 100 | return unexpectedOperationCanceled(); |
| 101 | |
| 102 | planeTree_ = std::make_unique<AABBTreePoints>( planeVerts_, vertRegionWithBounds ); |
| 103 | return {}; |
| 104 | } |
| 105 | |
| 106 | Expected<void> RadiusCompensator::calcCompensations() |
| 107 | { |
no test coverage detected