]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix the problem moving arc with radius constraint (issue #1375)
authorazv <azv@opencascade.com>
Wed, 23 Mar 2016 12:58:05 +0000 (15:58 +0300)
committerazv <azv@opencascade.com>
Wed, 23 Mar 2016 12:58:05 +0000 (15:58 +0300)
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp

index c0edad021f899af3bae506cf6ca24fb367f02618..c60de6f38b252b4ae427573cde1e6fc3ce58a356 100644 (file)
@@ -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();
     }
   }
 }
index d796f7964206c4a6598a9f7dab289f2ac8724ad1..d63622683115195836f410da652ec0d5e4e3b8b1 100644 (file)
@@ -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<Slvs_Constraint>::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;
 }