Salome HOME
Merge branch 'BR_LAND_COVER_MAP' of ssh://git.salome-platform.org/modules/hydro into...
[modules/hydro.git] / src / HYDROData / HYDROData_Tool.cxx
index 210ec410ee8434a29e59973e95a6531c50d91662..f6f0f5a84525e887700d7357bb79c09c5822e1cd 100644 (file)
@@ -33,6 +33,7 @@
 #include <ElSLib.hxx>
 #include <Geom_Curve.hxx>
 #include <gp_Pln.hxx>
+#include <Quantity_Color.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Face.hxx>
@@ -272,6 +273,23 @@ QString HYDROData_Tool::toQString( const TCollection_ExtendedString& theStr )
   return QString( (QChar*)theStr.ToExtString(), theStr.Length() );
 }
 
+Quantity_Color HYDROData_Tool::toOccColor( const QColor& theColor )
+{
+  double r = theColor.red() / 255.0;
+  double g = theColor.green() / 255.0;
+  double b = theColor.blue() / 255.0;
+
+  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 );
+}
+
 std::ostream& operator<<( std::ostream& theStream, const QString& theText )
 {
   theStream << theText.toStdString();
@@ -296,4 +314,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;
+
+}