]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #222: Fatal error for 0 distance
authornds <natalia.donis@opencascade.com>
Fri, 31 Oct 2014 13:30:45 +0000 (16:30 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 31 Oct 2014 13:30:45 +0000 (16:30 +0300)
Do not visualize any presentation if the start and end points are equal

src/GeomAPI/GeomAPI_Pnt2d.cpp
src/GeomAPI/GeomAPI_Pnt2d.h
src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp

index 70bc646930fab9e98b4bfaf9028ee58030d9dcf3..062cbfb998e71b1d6ac0956945e8f169bbefdb34 100644 (file)
@@ -10,6 +10,8 @@
 
 #include<gp_Pnt2d.hxx>
 
+#include <Precision.hxx>
+
 #define MY_PNT2D static_cast<gp_Pnt2d*>(myImpl)
 
 GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY)
@@ -61,3 +63,8 @@ double GeomAPI_Pnt2d::distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther)
 {
   return MY_PNT2D->Distance(theOther->impl<gp_Pnt2d>());
 }
+
+bool GeomAPI_Pnt2d::isEqual(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const
+{
+  return distance(theOther) < Precision::Confusion();
+}
index b7f97890861ba22be7824497a8a8fda31249f7b5..4470a2aa6d0a995170c2a6e44a09790bf0983438 100644 (file)
@@ -45,6 +45,9 @@ class GEOMAPI_EXPORT GeomAPI_Pnt2d : public GeomAPI_Interface
 
   /// Distance between two points
   double distance(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
+
+  /// Returns whether the distance between two points is less then precision confusion
+  bool isEqual(const boost::shared_ptr<GeomAPI_Pnt2d>& theOther) const;
 };
 
 #endif
index 90e1a2437e5fcf7733e46e0096e2189320a54ef7..0ce7f355819270fc6de275b53f44d6fe1839a120 100644 (file)
@@ -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<GeomDataAPI_Point2D> aFlyOutAttr = boost::dynamic_pointer_cast<