BSplineCurve approximate, fix function sometime failing with smoothing algo

This commit is contained in:
tomate44
2017-03-09 16:05:11 +01:00
committed by wmayer
parent e219f5c2d4
commit 281e5935fb
2 changed files with 10 additions and 2 deletions

View File

@@ -300,7 +300,7 @@ from the knots table of this B-Spline curve.</UserDocu>
Replaces this B-Spline curve by approximating a set of points.
The function accepts keywords as arguments.
approximate2(Points = list_of_points)
approximate(Points = list_of_points)
Optional arguments :

View File

@@ -840,7 +840,15 @@ PyObject* BSplineCurvePy::approximate(PyObject *args, PyObject *kwds)
if (weight1 || weight2 || weight3) {
// It seems that this function only works with Continuity = C0, C1 or C2
if (!(c == GeomAbs_C0 || c == GeomAbs_C1 || c == GeomAbs_C2)) {
if (degMax < 3) {
c = GeomAbs_C0;
}
else if (degMax < 5) {
if (!(c == GeomAbs_C0)) {
c = GeomAbs_C1;
}
}
else if (!(c == GeomAbs_C0 || c == GeomAbs_C1 || c == GeomAbs_C2)) {
c = GeomAbs_C2;
}
GeomAPI_PointsToBSpline fit(pnts, weight1, weight2, weight3, degMax, c, tol3d);