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

Method filterCompensations

source/MRMesh/MRRadiusCompensation.cpp:133–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131}
132
133MR::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
173Expected<void> RadiusCompensator::applyCompensation()
174{

Callers 1

compensateRadiusFunction · 0.80

Calls 9

subprogressFunction · 0.85
reportProgressFunction · 0.85
findPointsInBallFunction · 0.85
to3dimFunction · 0.85
to2dimFunction · 0.85
sizeMethod · 0.45
resetMethod · 0.45
test_setMethod · 0.45

Tested by

no test coverage detected