From 5fa3d87b09378001a33833aa51f90be86c0a7254 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 26 May 2015 10:49:25 +0300 Subject: [PATCH] Fix the problem in updating of constraint --- src/SketchSolver/SketchSolver_Constraint.cpp | 25 ++++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Constraint.cpp b/src/SketchSolver/SketchSolver_Constraint.cpp index 2a4c36f8f..1ab3b596b 100644 --- a/src/SketchSolver/SketchSolver_Constraint.cpp +++ b/src/SketchSolver/SketchSolver_Constraint.cpp @@ -118,6 +118,17 @@ void SketchSolver_Constraint::process() bool SketchSolver_Constraint::checkAttributesChanged(ConstraintPtr theConstraint) { + std::set aCurAttrs; // list of currently used attributes + std::vector::const_iterator aConstrIter = mySlvsConstraints.begin(); + for (; aConstrIter != mySlvsConstraints.end(); aConstrIter++) { + Slvs_Constraint aConstr = myStorage->getConstraint(*aConstrIter); + if (aConstr.ptA != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.ptA); + if (aConstr.ptB != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.ptB); + if (aConstr.entityA != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityA); + if (aConstr.entityB != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityB); + if (aConstr.entityC != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityC); + if (aConstr.entityD != SLVS_E_UNKNOWN) aCurAttrs.insert(aConstr.entityD); + } // Check the attrbutes of constraint are changed ConstraintPtr aConstraint = theConstraint ? theConstraint : myBaseConstraint; std::list anAttrList = aConstraint->data()->attributes(std::string()); @@ -128,11 +139,14 @@ bool SketchSolver_Constraint::checkAttributesChanged(ConstraintPtr theConstraint if (aRefAttr) { if (aRefAttr->isObject()) { FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object()); - if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end()) + std::map::iterator aFIt = myFeatureMap.find(aFeature); + if (aFeature && (aFIt == myFeatureMap.end() || aCurAttrs.find(aFIt->second) == aCurAttrs.end())) + return true; + } else if (aRefAttr->attr()) { + std::map::iterator anAIt = myAttributeMap.find(aRefAttr->attr()); + if (anAIt == myAttributeMap.end() || aCurAttrs.find(anAIt->second) == aCurAttrs.end()) return true; - } else if (aRefAttr->attr() && - myAttributeMap.find(aRefAttr->attr()) == myAttributeMap.end()) - return true; + } } AttributeRefListPtr aRefList = std::dynamic_pointer_cast(*anAttrIter); @@ -141,7 +155,8 @@ bool SketchSolver_Constraint::checkAttributesChanged(ConstraintPtr theConstraint std::list::iterator anIt = anItems.begin(); for (; anIt != anItems.end(); anIt++) { FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt); - if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end()) + std::map::iterator aFIt = myFeatureMap.find(aFeature); + if (aFeature && (aFIt == myFeatureMap.end() || aCurAttrs.find(aFIt->second) == aCurAttrs.end())) return true; } } -- 2.39.2