From: vsr Date: Fri, 12 Aug 2011 06:38:28 +0000 (+0000) Subject: Small source code improvement X-Git-Tag: V6_main_20110815 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=771988faac03768522e0647918c79ed726111820;p=modules%2Fvisu.git Small source code improvement --- 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;