From 31be39725b4010d471d4b5ea302a2ed9aeecb552 Mon Sep 17 00:00:00 2001 From: azv Date: Mon, 19 Dec 2016 14:43:22 +0300 Subject: [PATCH] PlaneGCS: Sketch is moved when moving arc, attached to it by center. Change algorithm of calculation of arc characteristics (start and end angles), because reversed arcs had invalid values. --- src/SketchPlugin/Test/TestConstraintMirror.py | 2 +- .../PlaneGCSSolver/PlaneGCSSolver_Storage.cpp | 23 ++++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/SketchPlugin/Test/TestConstraintMirror.py b/src/SketchPlugin/Test/TestConstraintMirror.py index 16ab8201c..3f5ae6924 100644 --- a/src/SketchPlugin/Test/TestConstraintMirror.py +++ b/src/SketchPlugin/Test/TestConstraintMirror.py @@ -161,8 +161,8 @@ aMirror = aSketchFeature.addFeature("SketchConstraintMirror") aRefObjectA = aMirror.refattr("ConstraintEntityA") aRefObjectA.setObject(modelAPI_ResultConstruction(aMirrorLine.firstResult())) aRefListInitial = aMirror.reflist("ConstraintMirrorList") -aRefListInitial.append(aSketchArc1.lastResult()) aRefListInitial.append(aSketchLine1.lastResult()) +aRefListInitial.append(aSketchArc1.lastResult()) aRefListInitial.append(aSketchLine2.lastResult()) aMirror.execute() aSession.finishOperation() diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index b26213dcc..6c8527ada 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -414,22 +414,13 @@ void PlaneGCSSolver_Storage::processArc(const EntityWrapperPtr& theArc) *aRadius = aCenterPnt->distance(aStartPnt); if (!anArcFeature->lastResult()) return; - std::shared_ptr anArcEdge = - std::dynamic_pointer_cast(anArcFeature->lastResult()->shape()); - if (!anArcEdge) - return; - anArcEdge->getRange(*aStartAngle, *aEndAngle); - // verify the range is correct and not shifted to an angle - std::shared_ptr aDir(new GeomAPI_Dir2d(cos(*aStartAngle), sin(*aStartAngle))); - std::shared_ptr aCalcStartPnt( - new GeomAPI_Pnt2d(aCenterPnt->xy()->added(aDir->xy()->multiplied(*aRadius)))); - if (aCalcStartPnt->distance(aStartPnt) > tolerance) { - std::shared_ptr aDirToStart( - new GeomAPI_Dir2d(aStartPnt->xy()->decreased(aCenterPnt->xy()))); - double anAngle = aDir->angle(aDirToStart); - *aStartAngle += anAngle; - *aEndAngle += anAngle; - } + static std::shared_ptr OX(new GeomAPI_Dir2d(1.0, 0.0)); + std::shared_ptr aDir(new GeomAPI_Dir2d( + aStartPnt->xy()->decreased(aCenterPnt->xy()))); + *aStartAngle = OX->angle(aDir); + aDir = std::shared_ptr(new GeomAPI_Dir2d( + aEndPnt->xy()->decreased(aCenterPnt->xy()))); + *aEndAngle = OX->angle(aDir); // no need to constraint a fixed or a copied arc if (theArc->group() == GID_OUTOFGROUP || anArcFeature->isCopy()) -- 2.39.2