From: azv Date: Tue, 22 Dec 2015 08:04:22 +0000 (+0300) Subject: Fix the problem removing multi-coincidence between points (issue #1123) X-Git-Tag: V_2.1.0~114 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97495017af929e2d0564366338cf630feb586f64;p=modules%2Fshaper.git Fix the problem removing multi-coincidence between points (issue #1123) --- diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp index e5c24158c..5ce8df014 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp @@ -94,12 +94,14 @@ bool SketchSolver_ConstraintFixed::remove() cleanErrorMsg(); // Move fixed entities back to the current group FeaturePtr aFeature = myBaseFeature; - if (myBaseConstraint && myFixedAttribute && myFixedAttribute->isObject()) - aFeature = ModelAPI_Feature::feature(myFixedAttribute->object()); + if (myBaseConstraint && myFixedAttribute) { + if (myFixedAttribute->isObject()) + aFeature = ModelAPI_Feature::feature(myFixedAttribute->object()); + else + myStorage->update(AttributePtr(myFixedAttribute), myGroupID); + } if (aFeature) myStorage->update(aFeature, myGroupID); - else if (myFixedAttribute) - myStorage->update(AttributePtr(myFixedAttribute), myGroupID); // Remove constraint or base feature if (myBaseConstraint) { diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 67b346579..742ef54bd 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -335,13 +335,10 @@ bool SketchSolver_Storage::removeEntity(FeaturePtr theFeature) EntityWrapperPtr anEntity = aFound->second; myFeatureMap.erase(aFound); - // Check the feature is not used by constraints - if (isUsed(theFeature)) - return false; // the feature is used, don't remove it - - // Remove feature - if (remove(anEntity)) + // Check if the feature is not used by constraints, remove it + if (!isUsed(theFeature) && remove(anEntity)) return true; + // feature is not removed, revert operation myFeatureMap[theFeature] = anEntity; update(anEntity); @@ -357,18 +354,10 @@ bool SketchSolver_Storage::removeEntity(AttributePtr theAttribute) EntityWrapperPtr anEntity = aFound->second; myAttributeMap.erase(aFound); - // Check the attribute is not used by constraints - if (isUsed(theAttribute)) - return false; // the attribute is used, don't remove it - // Check the attribute is not used by other features - std::map::const_iterator aFIt = myFeatureMap.begin(); - for (; aFIt != myFeatureMap.end(); ++aFIt) - if (::isUsed(aFIt->second, theAttribute)) // the attribute is used, don't remove it - return false; - - // Remove attribute - if (remove(anEntity)) + // Check if the attribute is not used by constraints and features, remove it + if (!isUsed(theAttribute) && remove(anEntity)) return true; + // attribute is not removed, revert operation myAttributeMap[theAttribute] = anEntity; update(anEntity); diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 999f43eef..6d7400ddf 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -1552,8 +1552,8 @@ bool SolveSpaceSolver_Storage::removeCoincidence(ConstraintWrapperPtr theConstra std::set aSlaves = aPtPtIt->second; EntityWrapperPtr aNewMaster = *aSlaves.begin(); aSlaves.erase(aSlaves.begin()); - myCoincidentPoints[aNewMaster] = aSlaves; myCoincidentPoints.erase(aPtPtIt); + myCoincidentPoints[aNewMaster] = aSlaves; aPtPtIt = myCoincidentPoints.find(aNewMaster); } else aPtPtIt->second.erase(aNotCIt->first);