MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / refineFeatureObject

Function refineFeatureObject

source/MRMesh/MRFeatureRefine.cpp:235–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233{
234
235Expected<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
282Expected<AffineXf3f> refineFeatureObject( const FeatureObject& featObj, const PointCloud& pointCloud, const RefineParameters& params )
283{

Callers

nothing calls this directly

Calls 14

forEachObjectKindFunction · 0.85
getVertsForRefineFeatureFunction · 0.85
getPointsMinimalCountFunction · 0.85
getRefinedXfFunction · 0.85
reportProgressFunction · 0.85
countMethod · 0.80
unexpectedFunction · 0.70
cloneMethod · 0.45
computeBoundingBoxMethod · 0.45

Tested by

no test coverage detected