From e58a8443b1f1e067d28ed242d5fb30e38cf3fdf3 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 26 Feb 2015 15:15:37 +0300 Subject: [PATCH] Issue #407 Crash on distance constraint for two overlapped points --- src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 190665560..3c46ab4a5 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -18,6 +18,8 @@ #include +const double tolerance = 1e-7; + SketchPlugin_ConstraintDistance::SketchPlugin_ConstraintDistance() { } @@ -98,6 +100,10 @@ bool SketchPlugin_ConstraintDistance::compute(const std::string& theAttributeId) std::shared_ptr aPoint1 = sketch()->to3D(aPnt_A->x(), aPnt_A->y()); std::shared_ptr aPoint2 = sketch()->to3D(aPnt_B->x(), aPnt_B->y()); + // it is not possible to create lin2d on the points with equal position + if (aPoint1->distance(aPoint1) < tolerance) + return false; + std::shared_ptr aLine = std::shared_ptr(new GeomAPI_Lin2d(aPnt_A, aPnt_B)); double aDist = aPoint1->distance(aPoint2)/5.; std::shared_ptr aFPnt = aLine->shiftedLocation(aDist); -- 2.39.2