From bd3fb1611dd176786f1e021d93008bf1a506f30f Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 9 Sep 2019 16:38:03 +0300 Subject: [PATCH] Task 2.11. Ability to impose a midpoint on an arc (refers issue #3002) Revert more code related to arc processing in SketchSolver plugin. --- .../PlaneGCSSolver/PlaneGCSSolver_Storage.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 9f23cf6c5..6a41efc0d 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -223,6 +223,30 @@ bool PlaneGCSSolver_Storage::update(FeaturePtr theFeature, bool theForce) if (sendNotify && isUpdated) notify(theFeature); + // update arc + if (aRelated && aRelated->type() == ENTITY_ARC) { + /// TODO: this code should be shared with FeatureBuilder somehow + + std::shared_ptr anEntity = + std::dynamic_pointer_cast(aRelated); + std::shared_ptr anArc = std::dynamic_pointer_cast(anEntity->entity()); + + static std::shared_ptr OX(new GeomAPI_Dir2d(1.0, 0.0)); + std::shared_ptr aCenter( + new GeomAPI_Pnt2d(*anArc->center.x, *anArc->center.y)); + std::shared_ptr aStart( + new GeomAPI_Pnt2d(*anArc->start.x, *anArc->start.y)); + + *anArc->rad = aStart->distance(aCenter); + + std::shared_ptr aDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy()))); + *anArc->startAngle = OX->angle(aDir); + + aDir = std::shared_ptr( + new GeomAPI_Dir2d((*anArc->end.x) - aCenter->x(), (*anArc->end.y) - aCenter->y())); + *anArc->endAngle = OX->angle(aDir); + } + return isUpdated; } -- 2.39.2