| 233 | { |
| 234 | |
| 235 | Expected<AffineXf3f> refineFeatureObject( const FeatureObject& featObj, const Mesh& mesh, const RefineParameters& params ) |
| 236 | { |
| 237 | MR_TIMER; |
| 238 | |
| 239 | auto featureType = FeaturesObjectKind::_count; |
| 240 | forEachObjectKind( [&] ( auto type ) |
| 241 | { |
| 242 | if ( dynamic_cast<typename ObjKindTraits<type.value>::type const*>( &featObj ) ) |
| 243 | { |
| 244 | featureType = type; |
| 245 | return true; |
| 246 | } |
| 247 | return false; |
| 248 | } ); |
| 249 | assert( featureType != FeaturesObjectKind::_count ); |
| 250 | |
| 251 | auto refinedFeature = std::dynamic_pointer_cast<FeatureObject>( featObj.clone() ); |
| 252 | assert( refinedFeature ); |
| 253 | makeFeaturePseudoInfinite( refinedFeature, mesh.computeBoundingBox() ); |
| 254 | |
| 255 | VertBitSet prevResults; |
| 256 | for ( auto i = 0; i < params.maxIterations; ++i ) |
| 257 | { |
| 258 | auto vbs = getVertsForRefineFeature( mesh, *refinedFeature, params.distanceLimit, params.normalTolerance ); |
| 259 | if ( vbs.count() < getPointsMinimalCount( featureType ) ) |
| 260 | { |
| 261 | return unexpected( fmt::format( |
| 262 | "Unable to refine. Number of selected verts ({}) less than minimal ({}) for this feature type", |
| 263 | vbs.count(), |
| 264 | getPointsMinimalCount( featureType ) |
| 265 | ) ); |
| 266 | } |
| 267 | |
| 268 | const auto refinedXf = getRefinedXf( mesh, featureType, vbs, params.faceRegion ); |
| 269 | refinedFeature->setXf( refinedXf ); |
| 270 | |
| 271 | if ( vbs == prevResults ) |
| 272 | break; |
| 273 | prevResults = std::move( vbs ); |
| 274 | |
| 275 | if ( !reportProgress( params.callback, (float)i / (float)params.maxIterations ) ) |
| 276 | return unexpectedOperationCanceled(); |
| 277 | } |
| 278 | |
| 279 | return refinedFeature->xf(); |
| 280 | } |
| 281 | |
| 282 | Expected<AffineXf3f> refineFeatureObject( const FeatureObject& featObj, const PointCloud& pointCloud, const RefineParameters& params ) |
| 283 | { |
nothing calls this directly
no test coverage detected