From 00e7eae6f869d3c3d702df926a085e82200e4ea3 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Sun, 19 Jun 2022 21:35:24 +0530 Subject: [PATCH] [Sketcher] Use more segments while drawing splines B-Splines can have an arbitrary number of pieces. Using the same number of segments to draw a multi-piece spline can make the curve blocky. This commit only changes the behavior in edit-mode. --- .../Gui/EditModeGeometryCoinConverter.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/EditModeGeometryCoinConverter.cpp b/src/Mod/Sketcher/Gui/EditModeGeometryCoinConverter.cpp index aa797cf277..212e2f0502 100644 --- a/src/Mod/Sketcher/Gui/EditModeGeometryCoinConverter.cpp +++ b/src/Mod/Sketcher/Gui/EditModeGeometryCoinConverter.cpp @@ -284,9 +284,13 @@ void EditModeGeometryCoinConverter::convert(const Sketcher::GeometryFacade * geo Index[coinLayer].push_back(2); } else if constexpr (curvemode == CurveMode::ClosedCurve) { - double segment = (geo->getLastParameter() - geo->getFirstParameter()) / drawingParameters.curvedEdgeCountSegments; + int numSegments = drawingParameters.curvedEdgeCountSegments; + if constexpr (std::is_same::value) + numSegments *= geo->countKnots(); - for (int i=0; i < drawingParameters.curvedEdgeCountSegments; i++) { + double segment = (geo->getLastParameter() - geo->getFirstParameter()) / numSegments; + + for (int i=0; i < numSegments; i++) { Base::Vector3d pnt = geo->value(i*segment); addPoint(Coords[coinLayer], pnt); } @@ -294,13 +298,16 @@ void EditModeGeometryCoinConverter::convert(const Sketcher::GeometryFacade * geo Base::Vector3d pnt = geo->value(0); addPoint(Coords[coinLayer], pnt); - Index[coinLayer].push_back(drawingParameters.curvedEdgeCountSegments+1); + Index[coinLayer].push_back(numSegments+1); } else if constexpr (curvemode == CurveMode::OpenCurve) { + int numSegments = drawingParameters.curvedEdgeCountSegments; + if constexpr (std::is_same::value) + numSegments *= (geo->countKnots() - 1); // one less segments than knots - double segment = (geo->getLastParameter() - geo->getFirstParameter()) / drawingParameters.curvedEdgeCountSegments; + double segment = (geo->getLastParameter() - geo->getFirstParameter()) / numSegments; - for (int i=0; i < drawingParameters.curvedEdgeCountSegments; i++) { + for (int i=0; i < numSegments; i++) { Base::Vector3d pnt = geo->value(geo->getFirstParameter() + i*segment); addPoint(Coords[coinLayer], pnt); } @@ -308,7 +315,7 @@ void EditModeGeometryCoinConverter::convert(const Sketcher::GeometryFacade * geo Base::Vector3d pnt = geo->value(geo->getLastParameter()); addPoint(Coords[coinLayer], pnt); - Index[coinLayer].push_back(drawingParameters.curvedEdgeCountSegments+1); + Index[coinLayer].push_back(numSegments+1); if constexpr (analysemode == AnalyseMode::BoundingBoxMagnitudeAndBSplineCurvature) { //***************************************************************************************************************