]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Checking that collinearity constraint is already in the solver
authorazv <azv@opencascade.com>
Wed, 29 Mar 2017 08:01:30 +0000 (11:01 +0300)
committerazv <azv@opencascade.com>
Wed, 29 Mar 2017 08:01:40 +0000 (11:01 +0300)
src/SketchSolver/SketchSolver_ConstraintCollinear.cpp
src/SketchSolver/SketchSolver_ConstraintCollinear.h

index 32ec0721d2b74809e6aaf0282efb1a2366d8ab9b..555b77e5bb429cb74acc0ad7f64a94c31ec68559 100644 (file)
@@ -115,7 +115,16 @@ void SketchSolver_ConstraintCollinear::notify(const FeaturePtr&      theFeature,
       isNew = true;
   if (isNew) {
     mySolverConstraint = createPointsOnLine(aPoints[0], aPoints[1], aLine);
-    myStorage->removeConstraint(myBaseConstraint);
-    myStorage->addConstraint(myBaseConstraint, mySolverConstraint);
+    if (myInSolver) {
+      myStorage->removeConstraint(myBaseConstraint);
+      myInSolver = false;
+    }
+    if (mySolverConstraint) {
+      myStorage->addConstraint(myBaseConstraint, mySolverConstraint);
+      myInSolver = true;
+    }
+
+    for (int i = 0; i < 4; ++i)
+      myIsConstraintApplied[i] = aConstraintToApply[i];
   }
 }
index a70cc80acfc821a62d36ddf21323411a63f0dc33..abceb5431fd5f6c585c273e3d8722b9cb04a9781 100644 (file)
@@ -18,7 +18,8 @@ class SketchSolver_ConstraintCollinear : public SketchSolver_Constraint
 public:
   /// Constructor based on SketchPlugin constraint
   SketchSolver_ConstraintCollinear(ConstraintPtr theConstraint)
-    : SketchSolver_Constraint(theConstraint)
+    : SketchSolver_Constraint(theConstraint),
+      myInSolver(false)
   {
     for (int i = 0; i < 4; ++i)
       myIsConstraintApplied[i] = false;
@@ -35,6 +36,7 @@ protected:
 private:
   EntityWrapperPtr myPoints[4];  ///< extremities on collinear lines
   bool myIsConstraintApplied[4]; ///< set \c true if point on opposite line
+  bool myInSolver; ///< the constraint is added to the solver
 };
 
 #endif