Salome HOME
Porting to the current version of TInspector.
[modules/shaper.git] / src / SketchSolver / SketchSolver_ConstraintCollinear.cpp
index 555b77e5bb429cb74acc0ad7f64a94c31ec68559..e36d14e1cb6bbc743554d56a4a479525a2746fe4 100644 (file)
@@ -1,4 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include <SketchSolver_ConstraintCollinear.h>
 #include <SketchSolver_Error.h>
@@ -62,6 +80,9 @@ void SketchSolver_ConstraintCollinear::process()
 void SketchSolver_ConstraintCollinear::notify(const FeaturePtr&      theFeature,
                                               PlaneGCSSolver_Update* theUpdater)
 {
+  if (theFeature == myBaseConstraint && myInSolver)
+    return; // the constraint is already being updated
+
   PlaneGCSSolver_UpdateCoincidence* anUpdater =
       static_cast<PlaneGCSSolver_UpdateCoincidence*>(theUpdater);
 
@@ -110,9 +131,12 @@ void SketchSolver_ConstraintCollinear::notify(const FeaturePtr&      theFeature,
   }
 
   bool isNew = false;
-  for (int i = 0; i < 4 && !isNew; ++i)
+  for (int i = 0; i < 4; ++i) {
     if (aConstraintToApply[i] != myIsConstraintApplied[i])
       isNew = true;
+    myIsConstraintApplied[i] = aConstraintToApply[i];
+  }
+
   if (isNew) {
     mySolverConstraint = createPointsOnLine(aPoints[0], aPoints[1], aLine);
     if (myInSolver) {
@@ -123,8 +147,5 @@ void SketchSolver_ConstraintCollinear::notify(const FeaturePtr&      theFeature,
       myStorage->addConstraint(myBaseConstraint, mySolverConstraint);
       myInSolver = true;
     }
-
-    for (int i = 0; i < 4; ++i)
-      myIsConstraintApplied[i] = aConstraintToApply[i];
   }
 }