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

Function findPartialLens

source/MRMesh/MRAlignContoursToMesh.cpp:213–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213Expected<std::vector<float>> findPartialLens( const CurvePoints& cp, float * outCurveLen )
214{
215 MR_TIMER;
216 if ( cp.size() < 2 )
217 {
218 assert( false );
219 return unexpected( "Curve is too short" );
220 }
221
222 std::vector<float> lens;
223 lens.reserve( cp.size() );
224 lens.push_back( 0 );
225 for ( int i = 0; i + 1 < cp.size(); ++i )
226 lens.push_back( lens.back() + distance( cp[i].pos, cp[i+1].pos ) );
227 assert( lens.size() == cp.size() );
228 if ( outCurveLen )
229 *outCurveLen = lens.back();
230 if ( lens.back() <= 0 )
231 return unexpected( "curve has zero length" );
232
233 return lens;
234}
235
236CurvePoint getCurvePoint( const CurvePoints& cp, const std::vector<float> & lens, float p )
237{

Callers 1

curveFromPointsFunction · 0.85

Calls 5

push_backMethod · 0.80
unexpectedFunction · 0.70
distanceFunction · 0.70
sizeMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected