From: azv Date: Wed, 23 Mar 2016 12:58:05 +0000 (+0300) Subject: Fix the problem moving arc with radius constraint (issue #1375) X-Git-Tag: V_2.3.0~373 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8650972609ad538567a5b952c3890ba8613c8f9f;p=modules%2Fshaper.git Fix the problem moving arc with radius constraint (issue #1375) --- diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index c0edad021..c60de6f38 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -268,11 +268,15 @@ void SketchSolver_Group::moveFeature(FeaturePtr theFeature) // Workaround to process arcs. // When move unconstrained arc, add temporary constraint to fix radius. if (theFeature->getKind() == SketchPlugin_Arc::ID()) { + bool hasDup = myStorage->hasDuplicatedConstraint(); SolverConstraintPtr aFixedRadius = aBuilder->createFixedArcRadiusConstraint(theFeature); if (aFixedRadius) { aFixedRadius->process(myStorage, getId(), getWorkplaneId()); - if (aFixedRadius->error().empty()) + hasDup = myStorage->hasDuplicatedConstraint() && !hasDup; + if (aFixedRadius->error().empty() && !hasDup) setTemporary(aFixedRadius); + else + aFixedRadius->remove(); } } } diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index d796f7964..d63622683 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -832,6 +832,21 @@ bool SolveSpaceSolver_Storage::removeConstraint(const Slvs_hConstraint& theConst myConstraints.erase(myConstraints.begin() + aPos); myConstrMaxID = myConstraints.empty() ? SLVS_E_UNKNOWN : myConstraints.back().h; myNeedToResolve = true; + + if (myDuplicatedConstraint) { + // Find a constraint with same type uses same arguments + std::vector::iterator aCIt = myConstraints.begin(); + for (; aCIt != myConstraints.end(); aCIt++) { + if (aConstraint.type != aCIt->type) + continue; + if (aConstraint.ptA == aCIt->ptA && aConstraint.ptB == aCIt->ptB && + aConstraint.entityA == aCIt->entityA && aConstraint.entityB == aCIt->entityB && + aConstraint.entityC == aCIt->entityC && aConstraint.entityD == aCIt->entityD) { + myDuplicatedConstraint = false; + break; + } + } + } } return true; }