From efb8846dbff780b76e3d9b480610ec0d0871999b Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 26 Aug 2016 10:55:48 +0300 Subject: [PATCH] Issue #1677: Arc orientation lost after save/open Explicit creation of new group in the solver for the standalone arc for correct movement of the arc dragging by extremities. --- src/SketchPlugin/SketchPlugin_Arc.cpp | 4 ++-- src/SketchSolver/SketchSolver_Manager.cpp | 24 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index aa1d29096..b4666ebca 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -41,7 +41,7 @@ const double tolerance = 1e-7; const double paramTolerance = 1.e-4; -const double PI =3.141592653589793238463; +const double PI = 3.141592653589793238463; namespace { static const std::string& POINT_ID(int theIndex) @@ -68,7 +68,7 @@ SketchPlugin_Arc::SketchPlugin_Arc() myXEndBefore = 0; myYEndBefore = 0; - myParamBefore = 0; + myParamBefore = PI * 2.0; } void SketchPlugin_Arc::initDerivedClassAttributes() diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 61c0547b0..85d5c28ad 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -377,9 +377,31 @@ bool SketchSolver_Manager::moveEntity(std::shared_ptr theF if (!isMoved && theFeature->getKind() == SketchPlugin_Arc::ID()) { // Workaround to move arc. // If the arc has not been constrained, we will push it into empty group and apply movement. + bool hasEmptyGroup = false; for (aGroupIt = myGroups.begin(); aGroupIt != myGroups.end(); aGroupIt++) - if ((*aGroupIt)->isEmpty()) + if ((*aGroupIt)->isEmpty()) { isMoved = (*aGroupIt)->moveFeature(theFeature) || isMoved; + hasEmptyGroup = true; + } + // There is no empty group, create it explicitly + if (!hasEmptyGroup) { + // find sketch containing the arc + CompositeFeaturePtr aWP; + const std::set& aRefs = theFeature->data()->refsToMe(); + std::set::const_iterator aRefIt = aRefs.begin(); + for (; aRefIt != aRefs.end(); ++aRefIt) { + FeaturePtr anOwner = ModelAPI_Feature::feature((*aRefIt)->owner()); + if (anOwner && anOwner->getKind() == SketchPlugin_Sketch::ID()) { + aWP = std::dynamic_pointer_cast(anOwner); + break; + } + } + if (aWP) { + SketchSolver_Group* aGroup = new SketchSolver_Group(aWP); + isMoved = aGroup->moveFeature(theFeature) || isMoved; + myGroups.push_back(aGroup); + } + } } return isMoved; } -- 2.30.2