From bbce4cb4c43c249ade9dcce748283cc6fb5cfb49 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Wed, 11 Jan 2023 20:24:20 +0530 Subject: [PATCH] [Sketcher] Do not allow B-spline degree to be too high ...depending on number of poles (and periodic status). NOTE: It is still possible to run the command in console with a higher degree. --- src/Mod/Sketcher/Gui/DrawSketchHandlerBSpline.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerBSpline.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerBSpline.h index a617946a25..02cfdd2adf 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerBSpline.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerBSpline.h @@ -394,6 +394,8 @@ private: int currentgeoid = getHighestCurveIndex(); + unsigned int maxDegree = ConstrMethod == 0 ? (BSplinePoles.size()-1) : (BSplinePoles.size()); + try { //Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Add B-spline curve")); @@ -406,11 +408,11 @@ private: // {"poles", "mults", "knots", "periodic", "degree", "weights", "CheckRational", NULL}; Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.BSplineCurve" - "(%s,None,None,%s,%d,None,False),%s)", - controlpoints.c_str(), - ConstrMethod == 0 ?"False":"True", - SplineDegree, - geometryCreationMode==Construction?"True":"False"); + "(%s,None,None,%s,%d,None,False),%s)", + controlpoints.c_str(), + ConstrMethod == 0 ?"False":"True", + std::min(maxDegree, SplineDegree), + geometryCreationMode==Construction?"True":"False"); currentgeoid++; @@ -500,7 +502,7 @@ protected: std::vector> sugConstr; int ConstrMethod; - int SplineDegree; + unsigned int SplineDegree; bool IsClosed; std::vector poleGeoIds; Base::Vector2d prevCursorPosition;