]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #463: Improve movement of fillet
authorazv <azv@opencascade.com>
Fri, 17 Apr 2015 09:28:58 +0000 (12:28 +0300)
committerazv <azv@opencascade.com>
Fri, 17 Apr 2015 09:30:19 +0000 (12:30 +0300)
src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Storage.cpp
src/SketchSolver/SketchSolver_Storage.h

index 4f1b07f8f8697c6f580352644fc871fb2c7ef2cf..721913b19af45323648de8f7d0c9246a2ac000d2 100644 (file)
@@ -68,10 +68,16 @@ void SketchSolver_ConstraintCoincidence::attach(
 Slvs_hConstraint SketchSolver_ConstraintCoincidence::addConstraint(
     Slvs_hEntity thePoint1, Slvs_hEntity thePoint2)
 {
+  bool hasDuplicated = myStorage->hasDuplicatedConstraint();
   Slvs_Constraint aNewConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(),
       SLVS_C_POINTS_COINCIDENT, myGroup->getWorkplaneId(), 0.0, thePoint1, thePoint2, 
       SLVS_E_UNKNOWN, SLVS_E_UNKNOWN);
   Slvs_hConstraint aNewID = myStorage->addConstraint(aNewConstraint);
+  if (!hasDuplicated && myStorage->hasDuplicatedConstraint()) {
+    // the duplicated constraint appears
+    myStorage->removeConstraint(aNewID);
+    return SLVS_E_UNKNOWN;
+  }
   mySlvsConstraints.push_back(aNewID);
   return aNewID;
 }
index e630978ecc48952bde87291222a7b16f1104b44a..8a5267be2c6fb42a56f027737ec2fe34e580f743 100644 (file)
@@ -419,7 +419,7 @@ bool SketchSolver_Group::resolveConstraints()
           aResult = myConstrSolver.solve();
           if (aResult == SLVS_RESULT_OKAY || aNbTemp <= 0)
             break;
-          aNbTemp = myStorage->removeFirstTemporaryConstraint();
+          aNbTemp = myStorage->deleteTemporaryConstraint();
           myStorage->initializeSolver(myConstrSolver);
         }
       }
index 250ce7e564e1fb49ae4c8f463727631a0da19c27..63b22bf4cb4bf2360ae85b0afb4a213d0436c164 100644 (file)
@@ -546,12 +546,37 @@ void SketchSolver_Storage::removeTemporaryConstraints()
   myTemporaryConstraints.clear();
 }
 
-int SketchSolver_Storage::removeFirstTemporaryConstraint()
+int SketchSolver_Storage::deleteTemporaryConstraint()
 {
   if (myTemporaryConstraints.empty())
     return 0;
-  removeConstraint(*myTemporaryConstraints.begin());
-  myTemporaryConstraints.erase(myTemporaryConstraints.begin());
+  // Search the point-on-line or a non-rigid constraint
+  std::set<Slvs_hConstraint>::iterator aCIt = myTemporaryConstraints.begin();
+  for (; aCIt != myTemporaryConstraints.end(); aCIt++) {
+    int aPos = Search(*aCIt, myConstraints);
+    if (myConstraints[aPos].type != SLVS_C_WHERE_DRAGGED)
+      break;
+    std::vector<Slvs_Constraint>::iterator anIt = myConstraints.begin();
+    for (; anIt != myConstraints.end(); anIt++)
+      if (anIt->type == SLVS_C_PT_ON_LINE && anIt->ptA == myConstraints[aPos].ptA)
+        break;
+    if (anIt != myConstraints.end())
+      break;
+  }
+  if (aCIt == myTemporaryConstraints.end())
+    aCIt = myTemporaryConstraints.begin();
+  bool aNewFixed = (*aCIt == myFixed);
+  removeConstraint(*aCIt);
+  myTemporaryConstraints.erase(aCIt);
+  if (aNewFixed) {
+    for (aCIt = myTemporaryConstraints.begin(); aCIt != myTemporaryConstraints.end(); aCIt++) {
+      int aPos = Search(*aCIt, myConstraints);
+      if (myConstraints[aPos].type == SLVS_C_WHERE_DRAGGED) {
+        myFixed = *aCIt;
+        break;
+      }
+    }
+  }
   return (int)myTemporaryConstraints.size();
 }
 
index 6a861e5ae8ba1679022f569750de5d303225b679..669f2c0eacc12fd31ef1491d0ef558ed982b3c33 100644 (file)
@@ -108,9 +108,9 @@ public:
   void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID);
   /// \brief Remove all transient constraints
   void removeTemporaryConstraints();
-  /// \brief Remove first temporary constraint
+  /// \brief Remove one temporary constraint. Preferable to remove the points under Point-on-Line constraint
   /// \return Number of remaining temporary constraints
-  int removeFirstTemporaryConstraint();
+  int deleteTemporaryConstraint();
   /// \brief Checks the constraint is temporary
   bool isTemporary(const Slvs_hConstraint& theConstraintID) const;