+
+TopoDS_Shape HYDROData_Tool::getFirstShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups,
+ const int theGroupId )
+{
+ TopoDS_Shape aResShape;
+ if ( theGroupId < 1 || theGroupId > theGroups.Length() )
+ return aResShape;
+
+ Handle(HYDROData_ShapesGroup) aGroup =
+ Handle(HYDROData_ShapesGroup)::DownCast( theGroups.Value( theGroupId ) );
+ if ( aGroup.IsNull() )
+ return aResShape;
+
+ TopTools_SequenceOfShape aGroupShapes;
+ aGroup->GetShapes( aGroupShapes );
+
+ if ( !aGroupShapes.IsEmpty() )
+ aResShape = aGroupShapes.First();
+
+ return aResShape;
+}
+
+TCollection_ExtendedString HYDROData_Tool::toExtString( const QString& theStr )
+{
+ TCollection_ExtendedString aRes;
+ if( !theStr.isEmpty() )
+ {
+ Standard_ExtString extStr = new Standard_ExtCharacter[ ( theStr.length() + 1 ) * 2 ];
+ memcpy( (void*)extStr, theStr.unicode(), theStr.length() * 2 );
+ ((short*)extStr)[theStr.length()] = '\0';
+ aRes = TCollection_ExtendedString( extStr );
+ delete [] extStr;
+ }
+ return aRes;
+}
+
+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 );
+}
+
+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();
+ return theStream;
+}
+
+std::ostream& operator<<( std::ostream& theStream, const QColor& theColor )
+{
+ theStream << "[" << theColor.red() << ", " << theColor.green() << ", " << theColor.blue() << "]";
+ return theStream;
+}
+
+std::ostream& operator<<( std::ostream& theStream, const TopoDS_Shape& theShape )
+{
+ theStream << "[" << theShape.TShape().operator->() << "]";
+ return theStream;
+}
+
+std::ostream& operator<<( std::ostream& theStream, const TopoDS_Face& theFace )
+{
+ theStream << "[" << theFace.TShape().operator->() << "]";
+ 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;
+
+}