From 771988faac03768522e0647918c79ed726111820 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 12 Aug 2011 06:38:28 +0000 Subject: [PATCH] Small source code improvement --- src/PIPELINE/VISU_Extractor.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/PIPELINE/VISU_Extractor.cxx b/src/PIPELINE/VISU_Extractor.cxx index 34063cd2..20b64e1e 100644 --- a/src/PIPELINE/VISU_Extractor.cxx +++ b/src/PIPELINE/VISU_Extractor.cxx @@ -43,7 +43,11 @@ #include #include -#define USE_SPRINTF 1 +// Algorithm to cut values (see CutValue()) +// Use sprintf function +#define USE_SPRINTF +// Use new algorithm (works only when USE_SPRINTF is disabled) +#define USE_NEW_ALGORITHM //---------------------------------------------------------------------------- vtkStandardNewMacro(VISU_Extractor); @@ -107,15 +111,13 @@ vtkFloatingPointType CutValue (vtkFloatingPointType theValue, int theDecimals) { vtkFloatingPointType v = theValue; -#ifdef USE_SPRINTF +#if defined(USE_SPRINTF) char aFormat[16]; sprintf(aFormat, "%%.%dg", theDecimals); char aStr [256]; sprintf(aStr, aFormat, theValue); v = atof(aStr); -#else - -#ifndef USE_OLD_ALGORITHM +#elif defined(USE_NEW_ALGORITHM) // // VSR 19/10/2009: new algorithm does not use long long type // @@ -152,8 +154,6 @@ vtkFloatingPointType CutValue (vtkFloatingPointType theValue, int theDecimals) aDegree = pow(10, aDegree); v = ((vtkFloatingPointType)((long long)(v * aDegree))) / aDegree; //printf("$$$ 2 v = %.20g , aDegree = %lld \n", v, (long long)aDegree); -#endif - #endif return v; -- 2.30.2