From: azv Date: Wed, 29 Mar 2017 08:01:30 +0000 (+0300) Subject: Checking that collinearity constraint is already in the solver X-Git-Tag: V_2.7.0~160 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2d16a964beb97df4af8f734a28accf44bbf6abd4;p=modules%2Fshaper.git Checking that collinearity constraint is already in the solver --- diff --git a/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp b/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp index 32ec0721d..555b77e5b 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCollinear.cpp @@ -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]; } } diff --git a/src/SketchSolver/SketchSolver_ConstraintCollinear.h b/src/SketchSolver/SketchSolver_ConstraintCollinear.h index a70cc80ac..abceb5431 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCollinear.h +++ b/src/SketchSolver/SketchSolver_ConstraintCollinear.h @@ -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