From: azv Date: Mon, 24 Aug 2015 13:42:19 +0000 (+0300) Subject: Fix removing of one of multi-coincidence constraints X-Git-Tag: V_1.4.0_beta4~269 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c517422130d1d9e943e3862dc6830dc9020994e9;p=modules%2Fshaper.git Fix removing of one of multi-coincidence constraints --- diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index dbe952f61..6b8326b02 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -577,22 +577,15 @@ bool SketchSolver_Group::isConsistent() bool aResult = myFeatureStorage->isConsistent(); if (!aResult) { // remove invalid entities + std::set anInvalidConstraints; ConstraintConstraintMap::iterator aCIter = myConstraints.begin(); - while (aCIter != myConstraints.end()) { - std::list aConstraints = aCIter->second->constraints(); - std::list::iterator anIt = aConstraints.begin(); - for (; anIt != aConstraints.end(); anIt++) - if (!(*anIt)->data() || !(*anIt)->data()->isValid()) - if (aCIter->second->remove(*anIt)) { - // the constraint is fully removed, detach it from the list - ConstraintConstraintMap::iterator aTmpIt = aCIter++; - myFeatureStorage->removeConstraint(aTmpIt->first); - myConstraints.erase(aTmpIt); - break; - } - if (anIt == aConstraints.end()) - aCIter++; + for (; aCIter != myConstraints.end(); ++aCIter) { + if (!aCIter->first->data() || !aCIter->first->data()->isValid()) + anInvalidConstraints.insert(aCIter->first); } + std::set::const_iterator aRemoveIt = anInvalidConstraints.begin(); + for (; aRemoveIt != anInvalidConstraints.end(); ++aRemoveIt) + removeConstraint(*aRemoveIt); } return aResult; } @@ -623,16 +616,38 @@ void SketchSolver_Group::removeTemporaryConstraints() // ============================================================================ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint) { + bool isFullyRemoved = true; myFeatureStorage->removeConstraint(theConstraint); ConstraintConstraintMap::iterator aCIter = myConstraints.begin(); for (; aCIter != myConstraints.end(); aCIter++) if (aCIter->second->hasConstraint(theConstraint)) { if (!aCIter->second->remove(theConstraint)) // the constraint is not fully removed - aCIter = myConstraints.end(); + isFullyRemoved = false; break; } - if (aCIter != myConstraints.end()) + if (isFullyRemoved) myConstraints.erase(aCIter); + else if (aCIter != myConstraints.end() && + aCIter->first->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { + // Update multicoincidence + std::list aMultiCoinc; + SolverConstraintPtr aCoincidence = aCIter->second; + while (aCIter != myConstraints.end()) { + if (aCIter->second != aCoincidence) { + ++aCIter; + continue; + } + if (aCIter->first != theConstraint) + aMultiCoinc.push_back(aCIter->first); + aCIter->second->remove(aCIter->first); + ConstraintConstraintMap::iterator aRemoveIt = aCIter++; + myConstraints.erase(aRemoveIt); + } + + std::list::iterator anIt = aMultiCoinc.begin(); + for (; anIt != aMultiCoinc.end(); ++anIt) + changeConstraint(*anIt); + } } // ============================================================================