From e91225b4527adcbf95b59d83f1d5ea26197b7582 Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 7 Dec 2015 08:57:06 +0300 Subject: [PATCH] isnan(), isinf() are reimplemented without boost --- src/HYDROData/HYDROData_Bathymetry.cxx | 6 +++--- src/HYDROData/HYDROData_Image.cxx | 5 +++-- src/HYDROData/HYDROData_Profile.cxx | 6 +++--- src/HYDROData/HYDROData_Tool.cxx | 19 +++++++++++++++++++ src/HYDROData/HYDROData_Tool.h | 3 +++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index db0e9d4b..24fae3f2 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -476,9 +476,9 @@ bool HYDROData_Bathymetry::importFromXYZFile( QFile& theFile, if ( !isXOk || !isYOk || !isZOk ) return false; - if ( isnan( aPoint.X() ) || isinf( aPoint.X() ) || - isnan( aPoint.Y() ) || isinf( aPoint.Y() ) || - isnan( aPoint.Z() ) || isinf( aPoint.Z() ) ) + if ( HYDROData_Tool::IsNan( aPoint.X() ) || HYDROData_Tool::IsInf( aPoint.X() ) || + HYDROData_Tool::IsNan( aPoint.Y() ) || HYDROData_Tool::IsInf( aPoint.Y() ) || + HYDROData_Tool::IsNan( aPoint.Z() ) || HYDROData_Tool::IsInf( aPoint.Z() ) ) return false; // Invert the z value if requested diff --git a/src/HYDROData/HYDROData_Image.cxx b/src/HYDROData/HYDROData_Image.cxx index 1cadb4bf..287541b1 100644 --- a/src/HYDROData/HYDROData_Image.cxx +++ b/src/HYDROData/HYDROData_Image.cxx @@ -21,6 +21,7 @@ #include "HYDROData_Document.h" #include "HYDROData_Lambert93.h" #include "HYDROData_OperationsFactory.h" +#include "HYDROData_Tool.h" #include #include @@ -670,8 +671,8 @@ bool HYDROData_Image::SetGlobalPointsFromFile( const QString& theFileName ) // Check the result if ( !isDoubleOk || - isnan( aDoubleValue ) || - isinf( aDoubleValue ) ) { + HYDROData_Tool::IsNan( aDoubleValue ) || + HYDROData_Tool::IsInf( aDoubleValue ) ) { continue; } diff --git a/src/HYDROData/HYDROData_Profile.cxx b/src/HYDROData/HYDROData_Profile.cxx index 3e638794..4f69515e 100644 --- a/src/HYDROData/HYDROData_Profile.cxx +++ b/src/HYDROData/HYDROData_Profile.cxx @@ -618,8 +618,8 @@ bool HYDROData_Profile::ImportFromFile( OSD_File& theFile, double aCoordX = aValX.RealValue(); double aCoordY = aValY.RealValue(); - if ( isnan( aCoordX ) || isinf( aCoordX ) || - isnan( aCoordY ) || isinf( aCoordY ) ) + if ( HYDROData_Tool::IsNan( aCoordX ) || HYDROData_Tool::IsInf( aCoordX ) || + HYDROData_Tool::IsNan( aCoordY ) || HYDROData_Tool::IsInf( aCoordY ) ) aRes = false; if ( anIsParametric ) @@ -645,7 +645,7 @@ bool HYDROData_Profile::ImportFromFile( OSD_File& theFile, } double aCoordZ = aValZ.RealValue(); - if ( isnan( aCoordZ ) || isinf( aCoordZ ) ) + if ( HYDROData_Tool::IsNan( aCoordZ ) || HYDROData_Tool::IsInf( aCoordZ ) ) aRes = false; ProfilePoint aPoint( aCoordX, aCoordY, aCoordZ ); diff --git a/src/HYDROData/HYDROData_Tool.cxx b/src/HYDROData/HYDROData_Tool.cxx index f6f0f5a8..7d133924 100644 --- a/src/HYDROData/HYDROData_Tool.cxx +++ b/src/HYDROData/HYDROData_Tool.cxx @@ -40,6 +40,7 @@ #include #include #include +#include static int aMaxNameId = std::numeric_limits::max(); @@ -290,6 +291,24 @@ QColor HYDROData_Tool::toQtColor( const Quantity_Color& theColor ) 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(); diff --git a/src/HYDROData/HYDROData_Tool.h b/src/HYDROData/HYDROData_Tool.h index b9b6d6d7..e8fd7967 100644 --- a/src/HYDROData/HYDROData_Tool.h +++ b/src/HYDROData/HYDROData_Tool.h @@ -121,6 +121,9 @@ public: static Quantity_Color toOccColor( const QColor& ); static QColor toQtColor( const Quantity_Color& ); + + static bool IsNan( double theValue ); + static bool IsInf( double theValue ); }; inline bool ValuesEquals( const double& theFirst, const double& theSecond ) -- 2.39.2