]> Creatis software - gdcm.git/commitdiff
add method
authorjpr <jpr>
Wed, 8 Nov 2006 17:03:38 +0000 (17:03 +0000)
committerjpr <jpr>
Wed, 8 Nov 2006 17:03:38 +0000 (17:03 +0000)
bool File::GetImagePositionPatient( float ipp[3] )

src/gdcmFile.cxx
src/gdcmFile.h

index 09567c0e660712fa93e8a93a08e540106ff1cf6a..23c97b24f1e93689140443f9e884e32196f3666b 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/08/29 10:21:20 $
-  Version:   $Revision: 1.325 $
+  Date:      $Date: 2006/11/08 17:03:38 $
+  Version:   $Revision: 1.326 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -999,6 +999,50 @@ bool File::GetImageOrientationPatient( float iop[6] )
    return false;
 }
 
+/**
+  * \brief gets the info from 0020,0032 : Image Position Patient
+  *                   or from 0020 0030 : Image Position (RET)
+  *
+  * @param ipp adress of the (3)float array to receive values.
+  *        (defaulted as 0.,0.,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::GetImagePositionPatient( float ipp[3] )
+{
+   std::string strImPosiPat;
+   //iop is supposed to be float[3]
+   ipp[0] = ipp[1] = ipp[2] = 0.;
+
+   // 0020 0032 DS REL Image Position (Patient)
+   if ( (strImPosiPat = GetEntryString(0x0020,0x0032)) != GDCM_UNFOUND )
+   {
+      if ( sscanf( strImPosiPat.c_str(), "%f \\ %f \\%f", 
+          &ipp[0], &ipp[1], &ipp[2]) != 3 )
+      {
+         gdcmWarningMacro( "Wrong Image Position Patient (0020,0032)."
+                        << " Less than 3 values were found." );
+         return false;
+      }
+      return true;
+   }
+   //For ACR-NEMA
+   // 0020 0030 DS REL Image Position (RET)
+   else if ( (strImPosiPat = GetEntryString(0x0020,0x0030)) != GDCM_UNFOUND )
+   {
+      if ( sscanf( strImPosiPat.c_str(), "%f \\ %f \\%f ", 
+          &ipp[0], &ipp[1], &ipp[2]) != 3 )
+      {
+         gdcmWarningMacro( "wrong Image Position Patient (0020,0035). "
+                        << "Less than 3 values were found." );
+         return false;
+      }
+      return true;
+   }
+   return false;
+}
+
 /**
  * \brief   Retrieve the number of Bits Stored (actually used)
  *          (as opposed to number of Bits Allocated)
index efd05fb60be201868b8e49aaf501904664af4557..dd42b0b275be57553daf5bcb2abfa2d0375c5677 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.h,v $
   Language:  C++
-  Date:      $Date: 2006/05/30 08:18:50 $
-  Version:   $Revision: 1.128 $
+  Date:      $Date: 2006/11/08 17:03:38 $
+  Version:   $Revision: 1.129 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -130,7 +130,8 @@ public:
    float GetZOrigin();
 
    bool GetImageOrientationPatient( float iop[6] );
-
+   bool GetImagePositionPatient( float ipp[3] );
+   
    int GetBitsStored();
    int GetBitsAllocated();
    int GetHighBitPosition();