From 3a3b13d43c061445e7fc700086b91bb4eae32aff Mon Sep 17 00:00:00 2001 From: srit Date: Mon, 8 Feb 2010 10:10:44 +0000 Subject: [PATCH] Ported C99 std::isnormal function --- common/clitkPortability.h | 11 ++++++++++- itk/itkBinaryGuerreroFilter.h | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/common/clitkPortability.h b/common/clitkPortability.h index da1b7ba..63bb6ac 100755 --- a/common/clitkPortability.h +++ b/common/clitkPortability.h @@ -1,10 +1,19 @@ #ifndef CLITKPORTABILITY_H #define CLITKPORTABILITY_H - + #if defined(WIN32) # define rint(x) floor(x+0.5) # define lrint(x) (long)rint(x) # define _USE_MATH_DEFINES #endif +template +int IsNormal(const T val) { +#if defined(_MSC_VER) + return _finite(val); +#elif defined(unix) + return std::isnormal(val); +#endif +} + #endif /* end #define CLITKPORTABILITY_H */ diff --git a/itk/itkBinaryGuerreroFilter.h b/itk/itkBinaryGuerreroFilter.h index fdc6d21..383a21f 100644 --- a/itk/itkBinaryGuerreroFilter.h +++ b/itk/itkBinaryGuerreroFilter.h @@ -59,7 +59,7 @@ class GuerreroFunctor else //Use the original formula as described in Guerrero's paper vol_change=static_cast( 1000. * (Bstar-A) / (A*(1000.+Bstar)) ); - if (std::isnormal(vol_change)) + if (IsNormal(vol_change)) return vol_change; else return 0.; -- 2.45.2