From 025639ca0e9db3cdf896e244530208879bda3103 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 29 Sep 2017 16:43:01 +0200 Subject: [PATCH] inside toBiArcs check if a spline is closed and split it into two parts if necessary --- src/Mod/Part/App/BSplineCurveBiArcs.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Mod/Part/App/BSplineCurveBiArcs.cpp b/src/Mod/Part/App/BSplineCurveBiArcs.cpp index 09c9432547..fce7c78cc3 100644 --- a/src/Mod/Part/App/BSplineCurveBiArcs.cpp +++ b/src/Mod/Part/App/BSplineCurveBiArcs.cpp @@ -219,9 +219,25 @@ std::list GeomBSplineCurve::toBiArcs(double tolerance) const gp_Vec v_start; gp_Pnt p_end; gp_Vec v_end; - this->myCurve->D1(this->myCurve->FirstParameter(), p_start, v_start); + this->myCurve->D0(this->myCurve->FirstParameter(), p_start); + this->myCurve->D0(this->myCurve->LastParameter(), p_end); std::list list; - createArcs(tolerance, list, p_start, v_start, this->myCurve->FirstParameter(), this->myCurve->LastParameter(), p_end, v_end); + + // the spline is closed + if (p_start.Distance(p_end) < Precision::Intersection()) { + this->myCurve->D1(this->myCurve->FirstParameter(), p_start, v_start); + createArcs(tolerance, list, p_start, v_start, this->myCurve->FirstParameter(), + this->myCurve->LastParameter()/2, p_end, v_end); + this->myCurve->D1(this->myCurve->LastParameter()/2, p_start, v_start); + createArcs(tolerance, list, p_start, v_start, this->myCurve->LastParameter()/2, + this->myCurve->LastParameter(), p_end, v_end); + } + else { + this->myCurve->D1(this->myCurve->FirstParameter(), p_start, v_start); + createArcs(tolerance, list, p_start, v_start, this->myCurve->FirstParameter(), + this->myCurve->LastParameter(), p_end, v_end); + } + return list; }