Skip to content

Commit d256d58

Browse files
committed
CR Fix
1 parent a449986 commit d256d58

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

source/MRMesh/MRAlignContoursToMesh.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ Expected<Mesh> bendContoursAlongCurve( const Contours2f& contours, const CurveFu
118118
if ( !bbox.valid() )
119119
return unexpected( "Contours mesh is empty" );
120120

121+
if ( curve.totalLength <= 0.0f )
122+
{
123+
assert( !"invalid curve length" );
124+
return unexpected( "Invalid curve length" );
125+
}
126+
121127
const float cStartDepth = bbox.diagonal() * 0.05f; // use relative depth to avoid floating errors
122128
addBaseToPlanarMesh( contoursMesh, -cStartDepth );
123129
contoursMesh.invalidateCaches();
@@ -146,7 +152,7 @@ Expected<Mesh> bendContoursAlongCurve( const Contours2f& contours, const CurveFu
146152

147153
float curveTime = startCurvePos + xInBox;
148154
if ( params.periodicCurve )
149-
curveTime = std::fmodf( curveTime, curve.totalLength );
155+
curveTime = curveTime - std::floor( curveTime / curve.totalLength ) * curve.totalLength;
150156
const auto pos = curve.func( curveTime );
151157

152158
const auto vecx = pos.dir;

source/MRMesh/MRAlignContoursToMesh.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ MRMESH_API Expected<Mesh> bendContoursAlongSurfacePath( const Contours2f& contou
7171

7272
/// given a polyline by its vertices, computes partial lengths along the polyline from the initial point;
7373
/// return an error if the polyline is less than 2 points or all points have exactly the same location
74-
/// \param outCurveLen optional output of the total polyline length (before possible normalization)
74+
/// \param outCurveLen optional output of the total polyline length
7575
MRMESH_API Expected<std::vector<float>> findPartialLens( const CurvePoints& cp, float * outCurveLen = nullptr );
7676

7777
/// given a polyline by its vertices, and partial lengths as computed by \ref findPartialLens,
@@ -81,7 +81,7 @@ MRMESH_API Expected<std::vector<float>> findPartialLens( const CurvePoints& cp,
8181

8282
/// given a polyline by its vertices, returns curve function representing it;
8383
/// return an error if the polyline is less than 2 points or all points have exactly the same location
84-
/// \param outCurveLen optional output of the total polyline length (before possible normalization)
84+
/// \param outCurveLen optional output of the total polyline length
8585
MRMESH_API Expected<CurveFunc> curveFromPoints( const CurvePoints& cp, float * outCurveLen = nullptr );
8686
MRMESH_API Expected<CurveFunc> curveFromPoints( CurvePoints&& cp, float* outCurveLen = nullptr );
8787

0 commit comments

Comments
 (0)