From 0b5a982a51a44fd23b53772325922fd93ebb126e Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 16 Dec 2015 08:18:01 +0300 Subject: [PATCH] Add arc to solver if any its attribute is added --- src/SketchSolver/SketchSolver_Manager.cpp | 7 +++++-- src/SketchSolver/SketchSolver_Storage.cpp | 14 ++++++++++++++ .../SolveSpaceSolver/SolveSpaceSolver_Storage.cpp | 15 --------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Manager.cpp b/src/SketchSolver/SketchSolver_Manager.cpp index 34b2ea040..354a3d9d8 100644 --- a/src/SketchSolver/SketchSolver_Manager.cpp +++ b/src/SketchSolver/SketchSolver_Manager.cpp @@ -258,8 +258,11 @@ bool SketchSolver_Manager::changeFeature(std::shared_ptr t } if (aConstraint) - return (*aFirstGroupIter)->changeConstraint(aConstraint); - return (*aFirstGroupIter)->updateFeature(theFeature); + (*aFirstGroupIter)->changeConstraint(aConstraint); + else + (*aFirstGroupIter)->updateFeature(theFeature); + // groups are merged => need to resolve them + return true; } // Something goes wrong diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 2e283a90f..e440a795b 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -132,6 +132,20 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG EntityWrapperPtr aRelated = entity(anAttribute); if (!aRelated) { // Attribute is not exist, create it + // verify the attribute is a point of arc and add whole arc + if (anAttribute->owner()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(anAttribute->owner()); + if (aFeature->getKind() == SketchPlugin_Arc::ID() && + myFeatureMap.find(aFeature) == myFeatureMap.end()) { + // Additional checking that all attributes are initialized + if (aFeature->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && + aFeature->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && + aFeature->attribute(SketchPlugin_Arc::END_ID())->isInitialized()) { +//// myFeatureMap[aFeature] = EntityWrapperPtr(); + return SketchSolver_Storage::update(aFeature); + } + } + } BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); GroupID aGroup = theGroup != GID_UNKNOWN ? theGroup : myGroupID; aRelated = aBuilder->createAttribute(anAttribute, aGroup); diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index d48730926..96b7ec077 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -184,21 +184,6 @@ bool SolveSpaceSolver_Storage::update(EntityWrapperPtr& theEntity) if (anEntity->type() == ENTITY_SKETCH) storeWorkplane(anEntity); - - // For the correct work with arcs we will add them if their parameter is added - if (theEntity->baseAttribute()) { - FeaturePtr aFeature = ModelAPI_Feature::feature(theEntity->baseAttribute()->owner()); - if (aFeature->getKind() == SketchPlugin_Arc::ID() && - myFeatureMap.find(aFeature) == myFeatureMap.end()) { - // Additional checking that all attributes are initialized - if (aFeature->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && - aFeature->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && - aFeature->attribute(SketchPlugin_Arc::END_ID())->isInitialized()) { - myFeatureMap[aFeature] = EntityWrapperPtr(); - return SketchSolver_Storage::update(aFeature); - } - } - } } return isUpdated; -- 2.39.2