From: nds Date: Fri, 31 Oct 2014 13:30:45 +0000 (+0300) Subject: refs #222: Fatal error for 0 distance X-Git-Tag: V_0.5~46^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=442e265a361a77a6af27aae0c6125b9721febc39;p=modules%2Fshaper.git refs #222: Fatal error for 0 distance Do not visualize any presentation if the start and end points are equal --- diff --git a/src/GeomAPI/GeomAPI_Pnt2d.cpp b/src/GeomAPI/GeomAPI_Pnt2d.cpp index 70bc64693..062cbfb99 100644 --- a/src/GeomAPI/GeomAPI_Pnt2d.cpp +++ b/src/GeomAPI/GeomAPI_Pnt2d.cpp @@ -10,6 +10,8 @@ #include +#include + #define MY_PNT2D static_cast(myImpl) GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY) @@ -61,3 +63,8 @@ double GeomAPI_Pnt2d::distance(const boost::shared_ptr& theOther) { return MY_PNT2D->Distance(theOther->impl()); } + +bool GeomAPI_Pnt2d::isEqual(const boost::shared_ptr& theOther) const +{ + return distance(theOther) < Precision::Confusion(); +} diff --git a/src/GeomAPI/GeomAPI_Pnt2d.h b/src/GeomAPI/GeomAPI_Pnt2d.h index b7f978908..4470a2aa6 100644 --- a/src/GeomAPI/GeomAPI_Pnt2d.h +++ b/src/GeomAPI/GeomAPI_Pnt2d.h @@ -45,6 +45,9 @@ class GEOMAPI_EXPORT GeomAPI_Pnt2d : public GeomAPI_Interface /// Distance between two points double distance(const boost::shared_ptr& theOther) const; + + /// Returns whether the distance between two points is less then precision confusion + bool isEqual(const boost::shared_ptr& theOther) const; }; #endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 90e1a2437..0ce7f3558 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -101,7 +101,7 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi aPnt_B = getProjectionPoint(aLine, aPnt_A); } } - if (!aPnt_A || !aPnt_B) + if (!aPnt_A || !aPnt_B || aPnt_A->isEqual(aPnt_B)) return thePrevious; boost::shared_ptr aFlyOutAttr = boost::dynamic_pointer_cast<