From dd7831bb460da23992f929cebffddfb653e7c5d5 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 1 Sep 2015 13:53:06 +0300 Subject: [PATCH] Modification of distance constraint changes the line direction (issue #874) --- src/SketchSolver/SketchSolver_ConstraintDistance.cpp | 3 ++- src/SketchSolver/SketchSolver_ConstraintDistance.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) 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 -- 2.39.2