From: azv Date: Fri, 12 Sep 2014 07:16:45 +0000 (+0400) Subject: Issue #106 (reopened) fix: Crash on distance between coincident points X-Git-Tag: V_0.4.4~65^2~1^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d12132838a46feab9f4aa85e5ce82ae02846694e;p=modules%2Fshaper.git Issue #106 (reopened) fix: Crash on distance between coincident points --- 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(