From ce08cebc1f48dfd86d23e4de86cc33cb1629db5a Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Tue, 13 Dec 2022 21:45:06 +0530 Subject: [PATCH] [Sketcher] Handle split curve corner case It is possible to ask for splitting at an end point of the curve. This leads to a `CADKernelError` and leaves us with a "hanging" clone. This check prevents that. --- src/Mod/Sketcher/App/SketchObject.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index e62b4f02f3..9976cd8822 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -3025,6 +3025,11 @@ int SketchObject::split(int GeoId, const Base::Vector3d &point) endParam = curve->getLastParameter(); // TODO: Using parameter difference as a poor substitute of length. // Computing length of an arc of a generic conic would be expensive. + if (endParam - splitParam < Precision::PConfusion() || + splitParam - startParam < Precision::PConfusion()) { + THROWM(ValueError, "Split point is at one of the end points of the curve."); + return false; + } if (endParam - splitParam > splitParam - startParam) { longestPart = 1; }