From 281e5935fbec952e6b6600203ce7943f3b2f9b94 Mon Sep 17 00:00:00 2001 From: tomate44 Date: Thu, 9 Mar 2017 16:05:11 +0100 Subject: [PATCH] BSplineCurve approximate, fix function sometime failing with smoothing algo --- src/Mod/Part/App/BSplineCurvePy.xml | 2 +- src/Mod/Part/App/BSplineCurvePyImp.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/BSplineCurvePy.xml b/src/Mod/Part/App/BSplineCurvePy.xml index 987272884d..e0c070935f 100644 --- a/src/Mod/Part/App/BSplineCurvePy.xml +++ b/src/Mod/Part/App/BSplineCurvePy.xml @@ -300,7 +300,7 @@ from the knots table of this B-Spline curve. 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 : diff --git a/src/Mod/Part/App/BSplineCurvePyImp.cpp b/src/Mod/Part/App/BSplineCurvePyImp.cpp index 5a8a19bcb4..0f6a932057 100644 --- a/src/Mod/Part/App/BSplineCurvePyImp.cpp +++ b/src/Mod/Part/App/BSplineCurvePyImp.cpp @@ -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);