From d12132838a46feab9f4aa85e5ce82ae02846694e Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 12 Sep 2014 11:16:45 +0400 Subject: [PATCH] Issue #106 (reopened) fix: Crash on distance between coincident points --- src/GeomAPI/GeomAPI_AISObject.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index 7f068f0f9..22863757e 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -23,6 +23,8 @@ #include #include +const double tolerance = 1e-7; + const int CONSTRAINT_TEXT_HEIGHT = 28; /// the text height of the constraint const int CONSTRAINT_TEXT_SELECTION_TOLERANCE = 20; /// the text selection tolerance @@ -67,9 +69,14 @@ void GeomAPI_AISObject::createDistance(boost::shared_ptr theStartPo { double aFlyout = 0; if (theFlyoutPoint) { - boost::shared_ptr aLine = boost::shared_ptr( - new GeomAPI_Lin(theStartPoint, theEndPoint)); - double aDist = aLine->distance(theFlyoutPoint); + double aDist = 0.0; + if (theStartPoint->distance(theEndPoint) < tolerance) + aDist = theStartPoint->distance(theFlyoutPoint); + else { + boost::shared_ptr aLine = boost::shared_ptr( + new GeomAPI_Lin(theStartPoint, theEndPoint)); + aDist = aLine->distance(theFlyoutPoint); + } boost::shared_ptr aLineDir = theEndPoint->xyz()->decreased(theStartPoint->xyz()); boost::shared_ptr aFOutDir = theFlyoutPoint->xyz()->decreased( -- 2.39.2