From 8650972609ad538567a5b952c3890ba8613c8f9f Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 23 Mar 2016 15:58:05 +0300 Subject: [PATCH] Fix the problem moving arc with radius constraint (issue #1375) --- src/SketchSolver/SketchSolver_Group.cpp | 6 +++++- .../SolveSpaceSolver/SolveSpaceSolver_Storage.cpp | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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; } -- 2.39.2