]> Creatis software - gdcm.git/blobdiff - src/gdcmFile.cxx
The automatic set to VR = "LO" for shadow elements that could be
[gdcm.git] / src / gdcmFile.cxx
index 2c6928956289de5d23e0a8efa80a097382e54734..1c5bebc48f7a4571e12a4ecb82b8e37e0aa575d5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/25 13:56:31 $
-  Version:   $Revision: 1.309 $
+  Date:      $Date: 2005/12/21 14:52:12 $
+  Version:   $Revision: 1.313 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -768,17 +768,19 @@ float File::GetZOrigin()
 /**
   * \brief gets the info from 0020,0037 : Image Orientation Patient
   *                   or from 0020 0035 : Image Orientation (RET)
+  *
   * (needed to organize DICOM files based on their x,y,z position)
-  * @param iop adress of the (6)float array to receive values
-  * @return true when one of the tag is found
-  *         false when nothing is found
+  *
+  * @param iop adress of the (6)float array to receive values.
+  *        (defaulted as 1.,0.,0.,0.,1.,0. if nothing -or inconsistent stuff-
+  *        is found.
+  * @return true when one of the tag -with consistent values- is found
+  *         false when nothing or inconsistent stuff - is found
   */
-bool File::GetImageOrientationPatient( double iop[6] )
+bool File::GetImageOrientationPatient( float iop[6] )
 {
    std::string strImOriPat;
-   //iop is supposed to be double[6]
-   iop[0] = iop[4] = 1.;
-   iop[1] = iop[2] = iop[3] = iop[5] = 0.;
+   //iop is supposed to be float[6]
 
    // 0020 0037 DS REL Image Orientation (Patient)
    if ( (strImOriPat = GetEntryString(0x0020,0x0037)) != GDCM_UNFOUND )
@@ -786,10 +788,14 @@ bool File::GetImageOrientationPatient( double iop[6] )
       if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", 
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
       {
+         iop[0] = iop[4] = 1.;
+         iop[1] = iop[2] = iop[3] = iop[5] = 0.;
          gdcmWarningMacro( "Wrong Image Orientation Patient (0020,0037)."
                         << " Less than 6 values were found." );
          return false;
       }
+      else 
+         return true;
    }
    //For ACR-NEMA
    // 0020 0035 DS REL Image Orientation (RET)
@@ -798,12 +804,16 @@ bool File::GetImageOrientationPatient( double iop[6] )
       if ( sscanf( strImOriPat.c_str(), "%f \\ %f \\%f \\%f \\%f \\%f ", 
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
       {
+         iop[0] = iop[4] = 1.;
+         iop[1] = iop[2] = iop[3] = iop[5] = 0.;
          gdcmWarningMacro( "wrong Image Orientation Patient (0020,0035). "
                         << "Less than 6 values were found." );
          return false;
       }
+      else
+         return true;
    }
-   return true;
+   return false;
 }
 
 /**
@@ -1153,7 +1163,7 @@ int File::GetLUTNbits()
 
 /**
  *\brief gets the info from 0028,1052 : Rescale Intercept
- * @return Rescale Intercept
+ * @return Rescale Intercept. defaulted to 0.0 is not found or empty
  */
 float File::GetRescaleIntercept()
 {
@@ -1170,7 +1180,7 @@ float File::GetRescaleIntercept()
 
 /**
  *\brief   gets the info from 0028,1053 : Rescale Slope
- * @return Rescale Slope
+ * @return Rescale Slope. defaulted to 0.0 is not found or empty
  */
 float File::GetRescaleSlope()
 {
@@ -1496,7 +1506,7 @@ bool File::Write(std::string fileName, FileType writetype)
       e0000->SetString(sLen.str());
    }
 
-   // FIXME : Derma?.dcm does not have it...let's remove it ?!? JPRx
+   /// \todo FIXME : Derma?.dcm does not have it...let's remove it ?!? JPRx
    if( writetype != JPEG )
    {
       int i_lgPix = GetEntryLength(GrPixel, NumPixel);
@@ -1516,6 +1526,7 @@ bool File::Write(std::string fileName, FileType writetype)
    return true;
 }
 
+
 //-----------------------------------------------------------------------------
 // Protected