]> Creatis software - gdcm.git/blobdiff - src/gdcmFile.cxx
COMP: Fix compilation for VS6
[gdcm.git] / src / gdcmFile.cxx
index e9e789edd1e6f458073d0cbb48d24f22037a5955..f79b64e7c8618eb8cc8f574c93ef064f13daf54e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/07/19 15:25:53 $
-  Version:   $Revision: 1.252 $
+  Date:      $Date: 2005/07/30 18:17:08 $
+  Version:   $Revision: 1.264 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
 //                                   as the Z coordinate, 
 // 0. for all the coordinates if nothing is found
 //
-// Image Position (Patient) (0020,0032) What is it used for?
+// Image Position (Patient) (0020,0032) VM=3 What is it used for?
 // -->
 //  The attribute Patient Orientation (0020,0020) from the General Image Module 
 // is of type 2C and has the condition Required if image does not require 
 // Image Orientation (0020,0037) and Image Position (0020,0032). 
-// However, if the image does require the attributes Image Orientation (0020,0037)
-// and Image Position (0020,0032) then attribute Patient Orientation (0020,0020)
-// should not be present in the images.
+// However, if the image does require the attributes 
+// - Image Orientation (Patient) (0020,0037), VM=6
+// - Image Position Patient (0020,0032), VM=3
+// then attribute Patient Orientation (0020,0020) should not be present
+//  in the images.
 //
 // Remember also :
 // Patient Position (0018,5100) values : HFP   = Head First-Prone
 //                                       FFDL = Feet First-Decubitus Left
 //                                       FFP  = Feet First-Prone
 //                                       FFS  = Feet First-Supine
+//                    can also find      SEMIERECT
+//                                       SUPINE
 // CS 2 Patient Orientation (0020 0020)
 //               When the coordinates of the image 
-//               are always present, this field is almost never used
+//               are always present, this field is almost never used.
+//               Better we don't tust it too much ...
+//               Found Values are :      L\P
+//                                       L\FP
+//                                       P\F
+//                                       L\F
+//                                       P\FR
+//                                       R\F
+//
+// (0020|0037) [Image Orientation (Patient)] [1\0\0\0\1\0 ]
+
+                                      
 // ---------------------------------------------------------------
 //
 #include "gdcmFile.h"
@@ -66,6 +81,7 @@
 
 namespace gdcm 
 {
+
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
 
@@ -719,7 +735,7 @@ float File::GetZOrigin()
   * @param iop adress of the (6)float array to receive values
   * @return cosines of image orientation patient
   */
-void File::GetImageOrientationPatient( float iop[6] )
+bool File::GetImageOrientationPatient( float iop[6] )
 {
    std::string strImOriPat;
    //iop is supposed to be float[6]
@@ -732,6 +748,7 @@ void File::GetImageOrientationPatient( float iop[6] )
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
       {
          gdcmWarningMacro( "Wrong Image Orientation Patient (0020,0037). Less than 6 values were found." );
+         return false;
       }
    }
    //For ACR-NEMA
@@ -742,8 +759,10 @@ void File::GetImageOrientationPatient( float iop[6] )
           &iop[0], &iop[1], &iop[2], &iop[3], &iop[4], &iop[5]) != 6 )
       {
          gdcmWarningMacro( "wrong Image Orientation Patient (0020,0035). Less than 6 values were found." );
+         return false;
       }
    }
+   return true;
 }
 
 /**
@@ -766,8 +785,8 @@ int File::GetBitsStored()
 
 /**
  * \brief   Retrieve the number of Bits Allocated
- *          (8, 12 -compacted ACR-NEMA files-, 16, ...)
- * @return  The encountered number of Bits Allocated, 0 by default.
+ *          (8, 12 -compacted ACR-NEMA files-, 16, 24 -old RGB ACR-NEMA files-,)
+ * @return  The encountered Number of Bits Allocated, 0 by default.
  *          0 means the file is NOT USABLE. The caller has to check it !
  */
 int File::GetBitsAllocated()
@@ -901,8 +920,8 @@ std::string File::GetPixelType()
    }
    else if ( bitsAlloc == "24" )
    {
-      // (in order no to be messed up
-      bitsAlloc = "8";  // by old RGB images)
+      // (in order no to be messed up by old RGB images)
+      bitsAlloc = "8";
    }
 
    std::string sign = GetEntryValue(0x0028, 0x0103);//"Pixel Representation"
@@ -1295,9 +1314,11 @@ void File::AnonymizeNoLoad()
       if ( d == NULL)
          continue;
 
-      if ( dynamic_cast<BinEntry *>(d)
-        || dynamic_cast<SeqEntry *>(d) )
-         continue;
+         if ( dynamic_cast<SeqEntry *>(d) )
+         {
+            gdcmWarningMacro( "You cannot 'Anonymize a SeqEntry ");
+            continue;
+         }
 
       offset = d->GetOffset();
       lgth =   d->GetLength();
@@ -1318,6 +1339,7 @@ void File::AnonymizeNoLoad()
 /**
  * \brief anonymize a File (remove Patient's personal info passed with
  *        AddAnonymizeElement()
+ * \note You cannot Anonymize a BinEntry (to be fixed)
  */
 bool File::AnonymizeFile()
 {
@@ -1356,11 +1378,19 @@ bool File::AnonymizeFile()
          if ( d == NULL)
             continue;
 
-         if ( dynamic_cast<BinEntry *>(d)
-           || dynamic_cast<SeqEntry *>(d) )
+         if ( dynamic_cast<SeqEntry *>(d) )
+         {
+            gdcmWarningMacro( "You cannot 'Anonymize' a SeqEntry ");
             continue;
+         }
 
-         SetValEntry ((*it).Value, (*it).Group, (*it).Elem);
+         if ( dynamic_cast<BinEntry *>(d) )
+         {
+            gdcmWarningMacro( "To 'Anonymize' a BinEntry, better use AnonymizeNoLoad (FIXME) ");
+            continue;
+         }
+         else
+            SetValEntry ((*it).Value, (*it).Group, (*it).Elem);
       }
 }
 
@@ -1721,11 +1751,12 @@ void File::ReadAndSkipEncapsulatedBasicOffsetTable()
 }
 
 // These are the deprecated method that one day should be removed (after the next release)
+
 #ifndef GDCM_LEGACY_REMOVE
 /**
- * \brief  Constructor 
+ * \brief  Constructor (DEPRECATED : temporaryly kept not to break the API)
  * @param  filename name of the file whose header we want to analyze
- * @deprecated do not use anymore
+ * @deprecated do not use any longer
  */
 File::File( std::string const &filename )
      :Document( )
@@ -1733,15 +1764,16 @@ File::File( std::string const &filename )
    RLEInfo  = new RLEFramesInfo;
    JPEGInfo = new JPEGFragmentsInfo;
 
-   Load( filename ); // gdcm::Document is first Loaded, then the 'File part'
+   SetFileName( filename );
+   Load( ); // gdcm::Document is first Loaded, then the 'File part'
 }
 
 /**
- * \brief   Loader. (DEPRECATED : not to break the API)
+ * \brief   Loader. (DEPRECATED :  temporaryly kept not to break the API)
  * @param   fileName file to be open for parsing
  * @return false if file cannot be open or no swap info was found,
  *         or no tag was found.
- * @deprecated Use the Load() function instead
+ * @deprecated Use the Load() [ + SetLoadMode() ] + SetFileName() functions instead
  */
 bool File::Load( std::string const &fileName ) 
 {