From: azv Date: Tue, 7 Apr 2015 06:47:21 +0000 (+0300) Subject: Fix the problems with constraint removing X-Git-Tag: V_1.1.0~54^2~8^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2dccea222b3540c85c20fe330a493cd1ba393e0;p=modules%2Fshaper.git Fix the problems with constraint removing --- diff --git a/src/SketchSolver/SketchSolver_FeatureStorage.cpp b/src/SketchSolver/SketchSolver_FeatureStorage.cpp index 610993a74..ef8461256 100644 --- a/src/SketchSolver/SketchSolver_FeatureStorage.cpp +++ b/src/SketchSolver/SketchSolver_FeatureStorage.cpp @@ -91,14 +91,10 @@ void SketchSolver_FeatureStorage::removeConstraint(ConstraintPtr theConstraint) while (aFeatIter != myFeatures.end()) { aCIter = aFeatIter->second.find(theConstraint); if (aCIter != aFeatIter->second.end()) { - aFeatIter->second.erase(aCIter); - if (aFeatIter->second.empty()) { - MapFeatureConstraint::iterator aTmpIter = aFeatIter; // stores iterator for the next element, while the current is deleting - aTmpIter++; - myFeatures.erase(aFeatIter); - aFeatIter = aTmpIter; - continue; - } + FeaturePtr aFeature = aFeatIter->first; + aFeatIter++; + removeFeature(aFeature, theConstraint); + continue; } aFeatIter++; } @@ -200,7 +196,7 @@ void SketchSolver_FeatureStorage::changeFeature(FeaturePtr theFeature, Constrain void SketchSolver_FeatureStorage::removeFeature(FeaturePtr theFeature) { MapFeatureConstraint::iterator aFeatIter = myFeatures.find(theFeature); - if (aFeatIter != myFeatures.end()) + if (aFeatIter == myFeatures.end()) return; // no such feature std::set aConstraints = aFeatIter->second; @@ -212,7 +208,7 @@ void SketchSolver_FeatureStorage::removeFeature(FeaturePtr theFeature) void SketchSolver_FeatureStorage::removeFeature(FeaturePtr theFeature, ConstraintPtr theConstraint) { MapFeatureConstraint::iterator aFeatIter = myFeatures.find(theFeature); - if (aFeatIter != myFeatures.end()) + if (aFeatIter == myFeatures.end()) return; // no such feature std::list anAttributes = theFeature->data()->attributes(std::string()); @@ -287,7 +283,7 @@ void SketchSolver_FeatureStorage::removeAttribute(AttributePtr theAttribute) void SketchSolver_FeatureStorage::removeAttribute(AttributePtr theAttribute, FeaturePtr theFeature) { MapAttributeFeature::iterator anAttrIter = myAttributes.find(theAttribute); - if (anAttrIter != myAttributes.end()) + if (anAttrIter == myAttributes.end()) return; // no such attribute anAttrIter->second.erase(theFeature); diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 2c6d8f576..b51828ba9 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -439,8 +439,20 @@ void SketchSolver_Group::splitGroup(std::vector& theCuts) anUnusedConstraints.push_back(*anIter); } - std::vector::iterator aCutsIter; + // Check the unused constraints once again, because they may become interacted with new storage since adding constraints std::vector::iterator aUnuseIt = anUnusedConstraints.begin(); + while (aUnuseIt != anUnusedConstraints.end()) { + if (aNewFeatStorage->isInteract(*aUnuseIt)) { + size_t aShift = aUnuseIt - anUnusedConstraints.begin(); + anUnusedConstraints.erase(aUnuseIt); + aUnuseIt = anUnusedConstraints.begin() + aShift; + continue; + } + aUnuseIt++; + } + + std::vector::iterator aCutsIter; + aUnuseIt = anUnusedConstraints.begin(); for ( ; aUnuseIt != anUnusedConstraints.end(); aUnuseIt++) { // Remove unused constraints removeConstraint(*aUnuseIt);