| 131 | } |
| 132 | |
| 133 | MR::Expected<void> RadiusCompensator::filterCompensations() |
| 134 | { |
| 135 | auto sb = subprogress( params_.callback, 0.3f, 0.4f ); |
| 136 | VertBitSet visitedVerts = vertRegion_; |
| 137 | int i = 0; |
| 138 | for ( auto& [cost, cId] : costs_ ) |
| 139 | { |
| 140 | ++i; |
| 141 | if ( ( i % 1024 == 0 ) && !reportProgress( sb, float( i ) / float( costs_.size() ) ) ) |
| 142 | return unexpectedOperationCanceled(); |
| 143 | |
| 144 | if ( cId < 0 ) |
| 145 | continue; |
| 146 | |
| 147 | visitedVerts.reset( cId ); |
| 148 | const auto& toolCenter = toolCenters_[cId]; |
| 149 | if ( toolCenter.x == FLT_MAX || cost == -FLT_MAX ) |
| 150 | { |
| 151 | cId = VertId(); // filter it out |
| 152 | continue; |
| 153 | } |
| 154 | auto planeToolCenter = toPlaneXf_( toolCenter ); |
| 155 | |
| 156 | bool validCompensation = false; |
| 157 | findPointsInBall( *planeTree_, { .center = to3dim( to2dim( planeToolCenter ) ),.radiusSq = radiusSq_ }, |
| 158 | [&] ( const PointsProjectionResult & found, const Vector3f &, Ball3f & ) |
| 159 | { |
| 160 | const auto v = found.vId; |
| 161 | auto planePoint = toPlaneXf_( mesh_.points[v] ); |
| 162 | auto shift = calcCompensationMovement_( planePoint, planeToolCenter ); |
| 163 | if ( shift != Vector3f() ) |
| 164 | validCompensation = visitedVerts.test_set( v, false ) || validCompensation; |
| 165 | return Processing::Continue; |
| 166 | } ); |
| 167 | if ( !validCompensation ) |
| 168 | cId = VertId(); // filter it out |
| 169 | } |
| 170 | return {}; |
| 171 | } |
| 172 | |
| 173 | Expected<void> RadiusCompensator::applyCompensation() |
| 174 | { |
no test coverage detected