From: azv Date: Wed, 27 Apr 2016 07:08:37 +0000 (+0300) Subject: Coincidence constraint is violated (issue #1458). X-Git-Tag: V_2.3.0~94 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=842fc4264b1ccbee2da68b41020ae2c08f64a111;p=modules%2Fshaper.git Coincidence constraint is violated (issue #1458). Changed the mechanism of splitting groups of constraints. --- diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index c60de6f38..639af961c 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -485,27 +485,39 @@ void SketchSolver_Group::splitGroup(std::list& theCuts) } std::list::iterator aCutsIter; - aUnuseIt = anUnusedConstraints.begin(); - for ( ; aUnuseIt != anUnusedConstraints.end(); ++aUnuseIt) { - // Remove unused constraints + // Remove unused constraints + for (aUnuseIt = anUnusedConstraints.begin(); aUnuseIt != anUnusedConstraints.end(); ++aUnuseIt) removeConstraint(*aUnuseIt); - // Try to append constraint to already existent group - for (aCutsIter = theCuts.begin(); aCutsIter != theCuts.end(); ++aCutsIter) - if ((*aCutsIter)->isInteract(*aUnuseIt)) { - (*aCutsIter)->changeConstraint(*aUnuseIt); - break; - } - if (aCutsIter == theCuts.end()) { + + SketchSolver_Group* aBaseGroup; + for (aUnuseIt = anUnusedConstraints.begin(); aUnuseIt != anUnusedConstraints.end(); ++aUnuseIt) { + aBaseGroup = 0; + aCutsIter = theCuts.begin(); + // Try to append constraint to the current group + if (isInteract(*aUnuseIt)) { + changeConstraint(*aUnuseIt); + aBaseGroup = this; + } else { + // Try to append constraint to already existent group + for (; aCutsIter != theCuts.end(); ++aCutsIter) + if ((*aCutsIter)->isInteract(*aUnuseIt)) { + (*aCutsIter)->changeConstraint(*aUnuseIt); + break; + } + } + + if (aCutsIter == theCuts.end() && !aBaseGroup) { // Add new group SketchSolver_Group* aGroup = new SketchSolver_Group(mySketch); aGroup->changeConstraint(*aUnuseIt); theCuts.push_back(aGroup); } else { + if (!aBaseGroup) + aBaseGroup = *aCutsIter++; // Find other groups interacting with constraint - std::list::iterator aBaseGroupIt = aCutsIter; - for (++aCutsIter; aCutsIter != theCuts.end(); ++aCutsIter) + for (; aCutsIter != theCuts.end(); ++aCutsIter) if ((*aCutsIter)->isInteract(*aUnuseIt)) { - (*aBaseGroupIt)->mergeGroups(**aCutsIter); + aBaseGroup->mergeGroups(**aCutsIter); std::list::iterator aRemoveIt = aCutsIter--; theCuts.erase(aRemoveIt); }