From 4da262dd3310f96bcbf903b9a1cbc038f8fc2b2f Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 15 Jan 2017 01:49:45 +0100 Subject: [PATCH] Sketcher: BSpline solver improvement =================================== In the unusual event that endpoint knot multiplicity is edited, avoid trying to force the bspline end-point to match the corresponding control point (aka pole), as this leads to unsolvable sketches. --- src/Mod/Sketcher/App/Sketch.cpp | 36 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index 2cece36a9a..b0f2ae6d55 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -678,14 +678,14 @@ int Sketch::addBSpline(const Part::GeomBSplineCurve &bspline, bool fixed) std::vector spoles; for(std::vector::const_iterator it = poles.begin(); it != poles.end(); ++it){ - params.push_back(new double( (*it).x )); - params.push_back(new double( (*it).y )); - - GCS::Point p; - p.x = params[params.size()-2]; - p.y = params[params.size()-1]; - - spoles.push_back(p); + params.push_back(new double( (*it).x )); + params.push_back(new double( (*it).y )); + + GCS::Point p; + p.x = params[params.size()-2]; + p.y = params[params.size()-1]; + + spoles.push_back(p); } std::vector sweights; @@ -736,15 +736,15 @@ int Sketch::addBSpline(const Part::GeomBSplineCurve &bspline, bool fixed) Points.push_back(p2); GCS::BSpline bs; - bs.start = p1; - bs.end = p2; - bs.poles = spoles; - bs.weights = sweights; - bs.knots = sknots; - bs.mult = mult; - bs.degree = degree; - bs.periodic = periodic; - def.index = BSplines.size(); + bs.start = p1; + bs.end = p2; + bs.poles = spoles; + bs.weights = sweights; + bs.knots = sknots; + bs.mult = mult; + bs.degree = degree; + bs.periodic = periodic; + def.index = BSplines.size(); BSplines.push_back(bs); // store complete set @@ -753,7 +753,7 @@ int Sketch::addBSpline(const Part::GeomBSplineCurve &bspline, bool fixed) // WARNING: This is only valid where the multiplicity of the endpoints conforms with a BSpline // only then the startpoint is the first control point and the endpoint is the last control point // accordingly, it is never the case for a periodic BSpline. - if(!bs.periodic) { + if(!bs.periodic && bs.mult[0] > bs.degree && bs.mult[mult.size()-1] > bs.degree) { GCSsys.addConstraintP2PCoincident(*(bs.poles.begin()),bs.start); GCSsys.addConstraintP2PCoincident(*(bs.poles.end()-1),bs.end); }