Salome HOME
Merge branch 'master' of https://git.salome-platform.org/git/modules/hydro
[modules/hydro.git] / src / HYDROData / HYDROData_Tool.cxx
index def682d94cc6900d6cc1ad2aaccf967460f70edc..7d1339241db68abd290f6b348fa52791943294ba 100644 (file)
@@ -40,6 +40,7 @@
 #include <TopoDS_Shape.hxx>
 #include <TopoDS_Wire.hxx>
 #include <limits>
+#include <math.h>
 
 static int aMaxNameId = std::numeric_limits<int>::max();
 
@@ -282,6 +283,32 @@ Quantity_Color HYDROData_Tool::toOccColor( const QColor& theColor )
   return Quantity_Color( r, g, b, Quantity_TOC_RGB );
 }
 
+QColor HYDROData_Tool::toQtColor( const Quantity_Color& theColor )
+{
+  int r = 255 * theColor.Red();
+  int g = 255 * theColor.Green();
+  int b = 255 * theColor.Blue();
+  return QColor( r, g, b );
+}
+
+bool HYDROData_Tool::IsNan( double theValue )
+{
+#ifdef WIN32
+  return _isnan( theValue );
+#else
+  return isnan( theValue );
+#endif
+}
+
+bool HYDROData_Tool::IsInf( double theValue )
+{
+#ifdef WIN32
+  return (!_finite( theValue  ) );
+#else
+  return isinf( theValue );
+#endif  
+}
+
 std::ostream& operator<<( std::ostream& theStream, const QString& theText )
 {
   theStream << theText.toStdString();
@@ -306,3 +333,17 @@ std::ostream& operator<<( std::ostream& theStream, const TopoDS_Face& theFace )
   return theStream;
 }
 
+std::ostream& operator<<( std::ostream& theStream, const gp_XY& theXY )
+{
+  theStream << "(" << theXY.X() << "; " << theXY.Y() << ")";
+  return theStream;
+}
+
+bool operator == ( const gp_XY& thePoint1, const gp_XY& thePoint2 )
+{
+  const double EPS = 1E-3;
+  return
+    fabs( thePoint1.X() - thePoint2.X() ) < EPS &&
+    fabs( thePoint1.Y() - thePoint2.Y() ) < EPS;
+
+}