]> Creatis software - gdcm.git/blobdiff - src/gdcmHeaderHelper.cxx
Fix warnings, add a GDCM_DATA_ROOT to CMake
[gdcm.git] / src / gdcmHeaderHelper.cxx
index 9cdab5708e766616c3496dad0a3857f03b8e7a7a..c8647471ceef57b6e3fc129fe8213291906c44ac 100644 (file)
@@ -3,14 +3,12 @@
 #include "gdcmHeaderHelper.h"
 #include "gdcmDirList.h"
 
-#include "gdcmUtil.h" //for debug
+#include "gdcmDebug.h"
 #include <math.h>
 #include <algorithm>
+#include <vector>
 
 //-----------------------------------------------------------------------------
-// gdcmHeaderHelper
-//-----------------------------------------------------------------------------
-// Constructor / Destructor
 /**
  * \ingroup gdcmHeaderHelper
  * \brief   constructor
@@ -133,8 +131,11 @@ float gdcmHeaderHelper::GetXSpacing() {
       dbg.Verbose(0, "gdcmHeader::GetXSpacing: unfound Pixel Spacing (0028,0030)");
       return 1.;
     }
-  if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2)
-    return 0.;
+  int nbValues;
+  if( (nbValues = sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing)) != 2) {
+    if (nbValues==1)  // if single value is found, xspacing is defaulted to yspacing
+       return yspacing;
+  }  
   if (xspacing == 0.) {
     dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem");
     // seems to be a bug in the header ...
@@ -150,20 +151,14 @@ float gdcmHeaderHelper::GetXSpacing() {
   * @return Y dimension of a pixel
   */
 float gdcmHeaderHelper::GetYSpacing() {
-   float xspacing, yspacing;
+   float yspacing;
    std::string StrSpacing = GetEntryByNumber(0x0028,0x0030);
   
    if (StrSpacing == GDCM_UNFOUND) {
       dbg.Verbose(0, "gdcmHeader::GetYSpacing: unfound Pixel Spacing (0028,0030)");
       return 1.;
     }
-  if( sscanf( StrSpacing.c_str(), "%f\\%f", &yspacing, &xspacing) != 2)
-    return 0.;
-  if (xspacing == 0.) {
-    dbg.Verbose(0, "gdcmHeader::GetYSpacing: gdcmData/CT-MONO2-8-abdo.dcm problem");
-    // seems to be a bug in the header ...
-    sscanf( StrSpacing.c_str(), "%f\\0\\%f", &yspacing, &xspacing);
-  }
+  sscanf( StrSpacing.c_str(), "%f", &yspacing);
   return yspacing;
 } 
 
@@ -280,8 +275,8 @@ int gdcmHeaderHelper::GetNumberOfScalarComponents() {
 /**
   * \ingroup gdcmHeaderHelper
   * \brief This function is intended to user that DOESN'T want 
-  * \to get RGB pixels image when it's stored as a PALETTE COLOR image
-  * \ - the (vtk) user is supposed to know how deal with LUTs - 
+  *  to get RGB pixels image when it's stored as a PALETTE COLOR image
+  *   - the (vtk) user is supposed to know how deal with LUTs - 
   * \warning to be used with GetImagePixelsRaw()
   * @return 1 if Gray level, 3 if Color (RGB or YBR - NOT 'PALETTE COLOR' -)
   */
@@ -788,7 +783,7 @@ bool gdcmSerieHeaderHelper::ImagePositionPatientOrdering()
 
 bool gdcmSerieHeaderHelper::ImageNumberOrdering() {
   int min, max, pos;
-  int n = 0;//CoherentGdcmFileList.size(); //O(N) operation !!
+  int n = 0;//CoherentGdcmFileList.size() is a O(N) operation !!
   unsigned char *partition;
   
   std::list<gdcmHeaderHelper*>::iterator it  = CoherentGdcmFileList.begin();