Skip to content

Commit

Permalink
SplineSettings/iterations in MRMarkedContour.h (#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedr authored Jan 5, 2025
1 parent 8e8787f commit af5016b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion source/MRMesh/MRMarkedContour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,22 @@ MarkedContour3f makeSpline( MarkedContour3f mc, float markStability )

MarkedContour3f makeSpline( const Contour3f & controlPoints, const SplineSettings & settings )
{
return makeSpline( resample( markedContour( controlPoints ), settings.samplingStep ), settings.controlStability );
MR_TIMER
assert( settings.iterations >= 1 );
MarkedContour3f res = markedContour( controlPoints );
for( int i = 0; i < settings.iterations; ++i )
{
assert( controlPoints.size() == res.marks.count() );
if ( i > 0 )
{
// restore exact control points positions
int n = 0;
for ( auto m : res.marks )
res.contour[m] = controlPoints[n++];
}
res = makeSpline( resample( res, settings.samplingStep ), settings.controlStability );
}
return res;
}

TEST(MRMesh, MarkedContour)
Expand Down
5 changes: 5 additions & 0 deletions source/MRMesh/MRMarkedContour.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ struct SplineSettings

/// a positive value, the more the value the closer resulting spline will be to given control points
float controlStability = 1;

/// the shape of resulting spline depends on the total number of points in the contour,
/// which in turn depends on the length of input contour being sampled;
/// setting iterations greater than one allows you to pass a constructed spline as a better input contour to the next run of the algorithm
int iterations = 1;
};

/// \param controlPoints ordered point the spline to interpolate
Expand Down

0 comments on commit af5016b

Please sign in to comment.