]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #463: Fillet constraint - closed line is destroyed
authorazv <azv@opencascade.com>
Thu, 16 Apr 2015 13:51:50 +0000 (16:51 +0300)
committerazv <azv@opencascade.com>
Thu, 16 Apr 2015 13:51:50 +0000 (16:51 +0300)
Allow to move fillet components

src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Solver.cpp
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SketchSolver_Storage.h

index a7f8d5b4801a50a90785797741ac02d5f0a4cc0f..e630978ecc48952bde87291222a7b16f1104b44a 100644 (file)
@@ -411,8 +411,18 @@ bool SketchSolver_Group::resolveConstraints()
     try {
       if (myStorage->hasDuplicatedConstraint())
         aResult = SLVS_RESULT_INCONSISTENT;
-      else
-        aResult = myConstrSolver.solve();
+      else {
+        // To avoid overconstraint situation, we will remove temporary constraints one-by-one
+        // and try to find the case without overconstraint
+        int aNbTemp = (int)myTempConstraints.size();
+        while (true) {
+          aResult = myConstrSolver.solve();
+          if (aResult == SLVS_RESULT_OKAY || aNbTemp <= 0)
+            break;
+          aNbTemp = myStorage->removeFirstTemporaryConstraint();
+          myStorage->initializeSolver(myConstrSolver);
+        }
+      }
     } catch (...) {
       Events_Error::send(SketchSolver_Error::SOLVESPACE_CRASH(), this);
       return false;
index 0e7b1761cc51e62b2aeeede9ce12c1c952d9f51c..4e7a4f0e9269f7e2d76ad8219a130fce099864f3 100644 (file)
@@ -63,8 +63,10 @@ void SketchSolver_Solver::setConstraints(Slvs_Constraint* theConstraints, int th
     myEquationsSystem.constraints = theSize;
   }
   else if (myEquationsSystem.constraints != theSize) {
-    delete[] myEquationsSystem.constraint;
-    myEquationsSystem.constraint = new Slvs_Constraint[theSize];
+    if (theSize > myEquationsSystem.constraints) {
+      delete[] myEquationsSystem.constraint;
+      myEquationsSystem.constraint = new Slvs_Constraint[theSize];
+    }
     myEquationsSystem.constraints = theSize;
   }
   memcpy(myEquationsSystem.constraint, theConstraints, theSize * sizeof(Slvs_Constraint));
index 1d5a8332d882f8a59259e275af2b74e57080e417..250ce7e564e1fb49ae4c8f463727631a0da19c27 100644 (file)
@@ -546,6 +546,15 @@ void SketchSolver_Storage::removeTemporaryConstraints()
   myTemporaryConstraints.clear();
 }
 
+int SketchSolver_Storage::removeFirstTemporaryConstraint()
+{
+  if (myTemporaryConstraints.empty())
+    return 0;
+  removeConstraint(*myTemporaryConstraints.begin());
+  myTemporaryConstraints.erase(myTemporaryConstraints.begin());
+  return (int)myTemporaryConstraints.size();
+}
+
 bool SketchSolver_Storage::isTemporary(const Slvs_hConstraint& theConstraintID) const
 {
   return myTemporaryConstraints.find(theConstraintID) != myTemporaryConstraints.end();
index fbd9acf6412592b1382e64ac107e60c142edc8fe..fc2e46ceba6963d96d58325fa7d780bcad72a184 100644 (file)
@@ -108,6 +108,9 @@ public:
   void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID);
   /// \brief Remove all transient constraints
   void removeTemporaryConstraints();
+  /// \brief Remove first temporary constraint
+  /// \return Number of remaining temporary constraints
+  int removeFirstTemporaryConstraint();
   /// \brief Checks the constraint is temporary
   bool isTemporary(const Slvs_hConstraint& theConstraintID) const;