From 19f9c943899a65d51ef7298ec10bddd7985aa756 Mon Sep 17 00:00:00 2001 From: Ajinkya Dahale Date: Sun, 5 Jun 2022 12:15:52 +0530 Subject: [PATCH] [Sketcher] Support splitting arcs of conics This commit also squashes: [Sketcher] Remove redundant geometry type check (Arc of) a circle is (an arc of) a conic. --- src/Mod/Sketcher/App/SketchObject.cpp | 10 +++++----- src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 8a25fcce54..3355edda18 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -3117,8 +3117,8 @@ int SketchObject::split(int GeoId, const Base::Vector3d &point) } } } - else if (geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId()) { - const Part::GeomArcOfEllipse *arc = static_cast(geo); + else if (geo->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId())) { + const Part::GeomArcOfConic *arc = static_cast(geo); startPoint = arc->getStartPoint(); endPoint = arc->getEndPoint(); @@ -3128,13 +3128,13 @@ int SketchObject::split(int GeoId, const Base::Vector3d &point) startParam = arc->getFirstParameter(); endParam = arc->getLastParameter(); // TODO: Using parameter difference as a poor substitute of length. - // Computing length of an arc of an ellipse would be expensive. + // Computing length of an arc of a generic conic would be expensive. if (endParam - splitParam > splitParam - startParam) { longestPart = 1; } // create new arcs - auto newArc = static_cast(arc->clone()); + auto newArc = static_cast(arc->clone()); int newId(GeoEnum::GeoUndef); newGeometries.push_back(newArc); newArc->setRange(startParam, splitParam, /*emulateCCW=*/true); @@ -3145,7 +3145,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d &point) exposeInternalGeometry(newId); // the "second" half - auto newArc2 = static_cast(arc->clone()); + auto newArc2 = static_cast(arc->clone()); int newId2(GeoEnum::GeoUndef); newArc2->setRange(splitParam, endParam, /*emulateCCW=*/true); newId2 = addGeometry(newArc2); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h index 90f3e60b0d..e4d1066ba8 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerSplitting.h @@ -52,8 +52,7 @@ public: const Part::Geometry *geom = Sketch->getGeometry(GeoId); if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() + || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { return true; } @@ -90,8 +89,7 @@ public: const Part::Geometry *geom = sketchgui->getSketchObject()->getGeometry(GeoId); if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() || geom->getTypeId() == Part::GeomCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() - || geom->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() + || geom->isDerivedFrom(Part::GeomArcOfConic::getClassTypeId()) || geom->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { try { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Split edge"));