From: nds Date: Thu, 26 Feb 2015 12:15:37 +0000 (+0300) Subject: Issue #407 Crash on distance constraint for two overlapped points X-Git-Tag: V_1.1.0~166 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e58a8443b1f1e067d28ed242d5fb30e38cf3fdf3;p=modules%2Fshaper.git Issue #407 Crash on distance constraint for two overlapped points --- 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);