From ec6eaa509d986ce3ae5fbfd291dab7bc414a6da5 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 23 May 2018 17:45:49 +0200 Subject: [PATCH] Sketcher: Improved B-Spline creation --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 255c1976a7..bc69440cf5 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -4712,11 +4712,28 @@ public: ConstrMethod == 0 ?"False":"True", geometryCreationMode==Construction?"True":"False"); - - - + currentgeoid++; + // autoconstraints were added to the circles of the poles, which is ok because they must go to the + // right position, or the user will freak-out if they appear out of the autoconstrained position. + // However, autoconstrains on the first and last pole, in normal non-periodic b-splines (with appropriate endpoint knot multiplicity) + // as the ones created by this tool are intended for the b-spline endpoints, and not for the poles, + // so here we retrieve any autoconstraint on those poles' center and mangle it to the endpoint. + if (ConstrMethod == 0) { + + for(auto & constr : static_cast(sketchgui->getObject())->Constraints.getValues()) { + if(constr->First == FirstPoleGeoId && constr->FirstPos == Sketcher::mid) { + constr->First = currentgeoid; + constr->FirstPos = Sketcher::start; + } + else if(constr->First == (FirstPoleGeoId + CurrentConstraint - 1) && constr->FirstPos == Sketcher::mid) { + constr->First = currentgeoid; + constr->FirstPos = Sketcher::end; + } + } + } + // Constraint pole circles to B-spline. std::stringstream cstream;