From: azv Date: Tue, 1 Sep 2015 10:53:06 +0000 (+0300) Subject: Modification of distance constraint changes the line direction (issue #874) X-Git-Tag: V_1.4.0_beta4~154 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dd7831bb460da23992f929cebffddfb653e7c5d5;p=modules%2Fshaper.git Modification of distance constraint changes the line direction (issue #874) --- diff --git a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp index d7313a49d..63bd0ae7d 100644 --- a/src/SketchSolver/SketchSolver_ConstraintDistance.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintDistance.cpp @@ -91,9 +91,10 @@ void SketchSolver_ConstraintDistance::adjustConstraint() } std::shared_ptr aLineVec = aPoints[2]->decreased(aPoints[1]); std::shared_ptr aPtLineVec = aPoints[0]->decreased(aPoints[1]); - if (aPtLineVec->cross(aLineVec) * aConstraint.valA < 0.0) { + if (aPtLineVec->cross(aLineVec) * aConstraint.valA < 0.0 || myIsNegative) { aConstraint.valA *= -1.0; myStorage->updateConstraint(aConstraint); + myIsNegative = true; } } } diff --git a/src/SketchSolver/SketchSolver_ConstraintDistance.h b/src/SketchSolver/SketchSolver_ConstraintDistance.h index ba1827208..8c3a7ea5c 100644 --- a/src/SketchSolver/SketchSolver_ConstraintDistance.h +++ b/src/SketchSolver/SketchSolver_ConstraintDistance.h @@ -38,6 +38,7 @@ protected: private: int myType; ///< type of constraint (applicable: SLVS_C_PT_PT_DISTANCE, SLVS_C_PT_LINE_DISTANCE) double myPrevValue; ///< previous value of distance (for correct calculation of a distance sign) + bool myIsNegative; ///< \c true, if the point if placed rightside of line direction (SLVS_C_PT_LINE_DISTANCE only) }; #endif