]> Creatis software - gdcm.git/blobdiff - src/gdcmHeader.cxx
* Erroneous leading white fix:
[gdcm.git] / src / gdcmHeader.cxx
index c95f8a84a2a472728ce63347df29df8a041419cf..19d008908d49f313d0015f87912bc6297513e53d 100644 (file)
@@ -1,15 +1,29 @@
-// gdcmHeader.cxx
-//-----------------------------------------------------------------------------
-#include <stdio.h>
-#include <cerrno>
-#include <cctype>    // for isalpha
-#include <vector>
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmHeader.cxx,v $
+  Language:  C++
+  Date:      $Date: 2004/06/20 18:08:47 $
+  Version:   $Revision: 1.165 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
 
 #include "gdcmHeader.h"
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
 #include "gdcmTS.h"
+#include "gdcmValEntry.h"
+
+#include <vector>
 
 //-----------------------------------------------------------------------------
 // Constructor / Destructor
@@ -26,14 +40,14 @@ gdcmHeader::gdcmHeader(const char *InFilename,
                        bool exception_on_error,
                        bool enable_sequences, 
                        bool ignore_shadow):
-   gdcmParser(InFilename,exception_on_error,enable_sequences,ignore_shadow)
+   gdcmDocument(InFilename,exception_on_error,enable_sequences,ignore_shadow)
 { 
-
+/*
    typedef struct {
       guint32 totalSQlength;
       guint32 alreadyParsedlength;
    } pileElem;
-
+*/
    
    // for some ACR-NEMA images GrPixel, NumPixel is *not* 7fe0,0010
    // We may encounter the 'RETired' (0x0028, 0x0200) tag
@@ -46,127 +60,21 @@ gdcmHeader::gdcmHeader(const char *InFilename,
    
    // This IS the right place for the code
  
-      std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
-      if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
-         GrPixel = 0x7fe0;                   // default value
-      } else {
-         GrPixel = (guint16) atoi( ImageLocation.c_str() );
-      }   
-      if (GrPixel == 0xe07f) // sometimes Image Location value doesn't follow 
-         GrPixel = 0x7fe0;   // the supposed processor endianity. 
-                             // see gdcmData/cr172241.dcm      
-      if (GrPixel != 0x7fe0) 
-         // This is a kludge for old dirty Philips imager.
-         NumPixel = 0x1010;
-      else
-         NumPixel = 0x0010;
-
-      TagKey key = gdcmDictEntry::TranslateToKey(GrPixel, NumPixel);
-      countGrPixel = GetEntry().count(key);
-      
-      // we set the SQ Depth of each Header Entry
-   
-   int top =-1;
-   int countSQ = 0;      
-   pileElem pile[100]; // Hope embedded sequence depth is no that long !
-
-   int currentParsedlength = 0;
-   int totalElementlength;
-   std::ostringstream tab; 
-   tab << "   ";
-   
-   int DEBUG = 0;  // Sorry; Dealing with e-film breaker images
-                   // will (certainly) cause a lot of troubles ...
-                   // I prefer keeping my 'trace' on .            
+   std::string ImageLocation = GetEntryByNumber(0x0028, 0x0200);
+   if ( ImageLocation == GDCM_UNFOUND ) { // Image Location
+      GrPixel = 0x7fe0;                   // default value
+   } else {
+      GrPixel = (guint16) atoi( ImageLocation.c_str() );
+   }   
+   if (GrPixel == 0xe07f) // sometimes Image Location value doesn't follow 
+      GrPixel = 0x7fe0;   // the supposed processor endianity. 
+                          // see gdcmData/cr172241.dcm      
+   if (GrPixel != 0x7fe0) 
+      // This is a kludge for old dirty Philips imager.
+      NumPixel = 0x1010;
+   else
+      NumPixel = 0x0010;
    
-   for (ListTag::iterator i = listEntries.begin();  
-       i != listEntries.end();
-       ++i) {
-      (*i)->SetSQDepthLevel(countSQ);
-      if ( (*i)->GetVR() == "SQ" && (*i)->GetReadLength() != 0) {   // SQ found         
-         countSQ++;
-        top ++;         
-           if ( top >= 20) {
-               std::cout << "Kaie ! Kaie! SQ Stack Overflow" << std::endl;
-              return;
-            }
-        if (DEBUG) std::cout << "\n >>>>> empile niveau " << top 
-                        << "; Lgr SeQ: " << (*i)->GetReadLength() 
-                         << "\n" <<std::endl;
-                
-        pile[top].totalSQlength = (*i)->GetReadLength();
-        pile[top].alreadyParsedlength = 0; 
-        currentParsedlength = 0;                      
-
-      } else {                              // non SQ found
-      
-         if (countSQ != 0) {                // we are 'inside a SeQuence'
-            if ( (*i)->GetGroup()==0xfffe  && (*i)->GetElement()==0xe0dd){
-              // we just found 'end of SeQuence'
-               
-              if (DEBUG)
-                   std::cout << "fffe,e0dd : depile" << std::endl;
-               currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2                                    
-              countSQ --;
-               top --; 
-               pile[top].alreadyParsedlength +=  currentParsedlength;
-            } else {
-              // we are on a 'standard' elem
-              // or a Zero-length SeQuence
-              
-              totalElementlength =  (*i)->GetFullLength();            
-              currentParsedlength += totalElementlength;                                
-               pile[top].alreadyParsedlength += totalElementlength;
-              
-               if (pile[top].totalSQlength == 0xffffffff) {
-                  if (DEBUG)
-                    std::cout << "totalSeQlength == 0xffffffff" 
-                               << std::endl; 
-               } else {
-                 if (DEBUG) 
-                       std::cout << "alrdyPseLgt:"
-                      << pile[top].alreadyParsedlength << " totSeQlgt: " 
-                      << pile[top].totalSQlength << " curPseLgt: " 
-                      << currentParsedlength
-                      << std::endl;
-                  while (pile[top].alreadyParsedlength==pile[top].totalSQlength) {
-                 
-                    if (DEBUG) 
-                         std::cout << " \n<<<<<< On depile niveau " << top 
-                                   << " \n" <<  std::endl;
-                     (*i)->SetSQDepthLevel(countSQ);                
-                     currentParsedlength = pile[top].alreadyParsedlength;
-                     countSQ --;
-                     top --;
-                    if (top >=0) {
-                       
-                        pile[top].alreadyParsedlength +=  currentParsedlength +12;
-                                               // 12 : length of 'SQ embedded' SQ element
-                        currentParsedlength += 8; // gr:2 elem:2 vr:2 lgt:2
-                                                                                            
-                       if (DEBUG)
-                             std::cout << pile[top].alreadyParsedlength << " " 
-                                       << pile[top].totalSQlength << " " 
-                                       << currentParsedlength
-                                       << std::endl;
-                     }                              
-                    if (top == -1) {
-                        currentParsedlength = 0;
-                        break;
-                     }                                                      
-                  }
-               }                               
-            }              
-         }   // end : 'inside a SeQuence'   
-      } 
-      if (DEBUG) {
-         for (int k=0; k<(*i)->GetSQDepthLevel();k++) {
-           std::cout << tab;
-         }
-        (*i)->SetPrintLevel(2);
-        (*i)->Print();
-      }      
-   } // end for        
 }
 
 /**
@@ -174,7 +82,7 @@ gdcmHeader::gdcmHeader(const char *InFilename,
  * @param exception_on_error whether we want to throw an exception or not
  */
 gdcmHeader::gdcmHeader(bool exception_on_error) :
-   gdcmParser(exception_on_error)
+   gdcmDocument(exception_on_error)
 {
 }
 
@@ -188,234 +96,37 @@ gdcmHeader::~gdcmHeader (void) {
 //-----------------------------------------------------------------------------
 // Print
 
-// see gdcmParser.cxx
-
-/**
-  * \ingroup gdcmHeader
-  * \brief   Prints the Header Entries (Dicom Elements)
-  *          from the chained list
-  *          and skips the elements belonging to a SeQuence
-  * @return
-  */ 
-void gdcmHeader::PrintEntryNoSQ(std::ostream & os) {
-
-   int depth;
-   for (ListTag::iterator i = listEntries.begin();  
-        i != listEntries.end();
-        ++i)
-   {
-      depth= (*i)->GetSQDepthLevel();
-      if ( depth != 0 /*|| (*i)->GetVR() =="SQ" */){
-         continue;
-      }
-      (*i)->SetPrintLevel(printLevel);
-      (*i)->Print(os); 
-   } 
-}
-
-/**
-  * \ingroup gdcmHeader
-  * \brief   Prints the Header Entries (Dicom Elements)
-  *          from the chained list
-  *          and indents the elements belonging to any SeQuence
-  * \warning : will be removed
-  * @return
-  */ 
-void gdcmHeader::PrintEntryNiceSQ(std::ostream & os) {    
-   std::ostringstream tab; 
-   tab << "   ";
-
-   int depth;   
-   for (ListTag::iterator i = listEntries.begin();  
-      i != listEntries.end();
-       ++i) {
-      depth= (*i)->GetSQDepthLevel();
-      if (depth != 0) { 
-         for (int k=0;k<depth;k++)
-           os << tab.str();
-      } 
-      (*i)->SetPrintLevel(printLevel);
-      (*i)->Print(os);
-             
-   } // end for     
-}
 
 //-----------------------------------------------------------------------------
 // Public
 
 /**
- * \ingroup gdcmHeader
  * \brief  This predicate, based on hopefully reasonable heuristics,
- *         decides whether or not the current gdcmParser was properly parsed
+ *         decides whether or not the current gdcmHeader was properly parsed
  *         and contains the mandatory information for being considered as
  *         a well formed and usable Dicom/Acr File.
- * @return true when gdcmParser is the one of a reasonable Dicom/Acr file,
+ * @return true when gdcmHeader is the one of a reasonable Dicom/Acr file,
  *         false otherwise. 
  */
 bool gdcmHeader::IsReadable(void) {
-   if(!gdcmParser::IsReadable()) {
+   if(!gdcmDocument::IsReadable()) {
       return(false);
    }
    std::string res = GetEntryByNumber(0x0028, 0x0005);
    if ( res != GDCM_UNFOUND && atoi(res.c_str()) > 4 ) 
       return false; // Image Dimensions
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0100) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0100) )
       return false; // "Bits Allocated"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0101) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0101) )
       return false; // "Bits Stored"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0102) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0102) )
       return false; // "High Bit"
-   if ( !GetHeaderEntryByNumber(0x0028, 0x0103) )
+   if ( !GetDocEntryByNumber(0x0028, 0x0103) )
       return false; // "Pixel Representation" i.e. 'Sign'
    return true;
 }
 
 /**
- * \ingroup gdcmHeader
- * \brief   Determines if the Transfer Syntax was already encountered
- *          and if it corresponds to a JPEGBaseLineProcess1 one.
- * @return  True when JPEGBaseLineProcess1found. False in all other cases.
- */
-bool gdcmHeader::IsJPEGBaseLineProcess1TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
-   if ( !Element )
-      return false;
-   LoadHeaderEntrySafe(Element);
-
-   std::string Transfer = Element->GetValue();
-   if ( Transfer == "1.2.840.10008.1.2.4.50" )
-      return true;
-   return false;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief   Determines if the Transfer Syntax was already encountered
- *          and if it corresponds to a JPEGExtendedProcess2-4 one.
- * @return  True when JPEGExtendedProcess2-4 found. False in all other cases.
- */
-bool gdcmHeader::IsJPEGExtendedProcess2_4TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
-   if ( !Element )
-      return false;
-   LoadHeaderEntrySafe(Element);
-   return ( Element->GetValue() == "1.2.840.10008.1.2.4.51" );
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief   Determines if the Transfer Syntax was already encountered
- *          and if it corresponds to a JPEGExtendeProcess3-5 one.
- * @return  True when JPEGExtendedProcess3-5 found. False in all other cases.
- */
-bool gdcmHeader::IsJPEGExtendedProcess3_5TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
-   if ( !Element )
-      return false;
-   LoadHeaderEntrySafe(Element);
-
-   std::string Transfer = Element->GetValue();
-   if ( Transfer == "1.2.840.10008.1.2.4.52" )
-      return true;
-   return false;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief   Determines if the Transfer Syntax was already encountered
- *          and if it corresponds to a JPEGSpectralSelectionProcess6-8 one.
- * @return  True when JPEGSpectralSelectionProcess6-8 found. False in all
- *          other cases.
- */
-bool gdcmHeader::IsJPEGSpectralSelectionProcess6_8TransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
-   if ( !Element )
-      return false;
-   LoadHeaderEntrySafe(Element);
-
-   std::string Transfer = Element->GetValue();
-   if ( Transfer == "1.2.840.10008.1.2.4.53" )
-      return true;
-   return false;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief   Determines if the Transfer Syntax was already encountered
- *          and if it corresponds to a RLE Lossless one.
- * @return  True when RLE Lossless found. False in all
- *          other cases.
- */
-bool gdcmHeader::IsRLELossLessTransferSyntax(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
-   if ( !Element )
-      return false;
-   LoadHeaderEntrySafe(Element);
-
-   std::string Transfer = Element->GetValue();
-   if ( Transfer == "1.2.840.10008.1.2.5" ) {
-      return true;
-    }
-   return false;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief  Determines if Transfer Syntax was already encountered
- *          and if it corresponds to a JPEG Lossless one. 
- * @return  True when RLE Lossless found. False in all
- *          other cases. 
- */
-bool gdcmHeader::IsJPEGLossless(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
-    // faire qq chose d'intelligent a la place de ça
-   if ( !Element )
-      return false;
-   LoadHeaderEntrySafe(Element);
-
-   const char * Transfert = Element->GetValue().c_str();
-   if ( memcmp(Transfert+strlen(Transfert)-2 ,"70",2)==0) return true;
-   if ( memcmp(Transfert+strlen(Transfert)-2 ,"55",2)==0) return true;
-   if (Element->GetValue() == "1.2.840.10008.1.2.4.57")   return true;
-
-   return false;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief   Determines if the Transfer Syntax was already encountered
- *          and if it corresponds to a JPEG2000 one
- * @return  True when JPEG2000 (Lossly or LossLess) found. False in all
- *          other cases.
- */
-bool gdcmHeader::IsJPEG2000(void) {
-   gdcmHeaderEntry* Element = GetHeaderEntryByNumber(0x0002, 0x0010);
-   if ( !Element )
-      return false;
-   LoadHeaderEntrySafe(Element);
-
-   std::string Transfer = Element->GetValue();
-   if (    (Transfer == "1.2.840.10008.1.2.4.90") 
-        || (Transfer == "1.2.840.10008.1.2.4.91") )
-      return true;
-   return false;
-}
-
-/**
- * \ingroup gdcmHeader
- * \brief   Predicate for dicom version 3 file.
- * @return  True when the file is a dicom version 3.
- */
-bool gdcmHeader::IsDicomV3(void) {
-   // Checking if Transfert Syntax exists is enough
-   // Anyway, it's to late check if the 'Preamble' was found ...
-   // And ... would it be a rich idea to check ?
-   // (some 'no Preamble' DICOM images exist !)
-   return (GetHeaderEntryByNumber(0x0002, 0x0010) != NULL);
-}
-
-/**
- * \ingroup gdcmHeader
  * \brief   Retrieve the number of columns of image.
  * @return  The encountered size when found, 0 by default.
  *          0 means the file is NOT USABLE. The caller will have to check
@@ -597,29 +308,17 @@ std::string gdcmHeader::GetPixelType(void) {
  * @return Pixel Offset
  */
 size_t gdcmHeader::GetPixelOffset(void) { 
-   //
-   // If the element (0x0088,0x0200) 'icone image sequence' is found
-   // (grPixel,numPixel) is stored twice : the first one for the icon
-   // the second one for the image ...
-   // pb : sometimes , (0x0088,0x0200) exists, but doesn't contain *anything*
-   // see gdcmData/MxTwinLossLess.dcm ...
-
-   //std::string icone = GetEntryByNumber(0x0088,0x0200); //icone image sequence
       
-   IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);          
-   TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
-   gdcmHeaderEntry* PixelElement;
-   if (countGrPixel == 1)   
-      PixelElement = (it.first)->second;
-   else {
-      PixelElement = (++it.first)->second; // hope there are no more than 2 !
-   } 
+   gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel);
    if (PixelElement) {
       return PixelElement->GetOffset();
    } else {
-/*      std::cout << "Big trouble : Pixel Element ("
+#ifdef GDCM_DEBUG
+      std::cout << "Big trouble : Pixel Element ("
                 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
-                << std::endl;  */
+                << std::endl;  
+#endif //GDCM_DEBUG
       return 0;
    }     
 }
@@ -634,22 +333,16 @@ size_t gdcmHeader::GetPixelOffset(void) {
  */
 size_t gdcmHeader::GetPixelAreaLength(void) { 
           
-   IterHT it = GetHeaderEntrySameNumber(GrPixel,NumPixel);          
-   TagKey key = gdcmDictEntry::TranslateToKey(GrPixel,NumPixel);
-   gdcmHeaderEntry* PixelElement;
-  
-  if (countGrPixel==1)  
-      PixelElement = (it.first)->second;
-   else
-      PixelElement = (++it.first)->second;
+   gdcmDocEntry* PixelElement = GetDocEntryByNumber(GrPixel,NumPixel);
 
    if (PixelElement) {
       return PixelElement->GetLength();
    } else {
-/*      std::cout << "Big trouble : Pixel Element ("
+#ifdef GDCM_DEBUG
+      std::cout << "Big trouble : Pixel Element ("
                 << std::hex << GrPixel<<","<< NumPixel<< ") NOT found"
                 << std::endl;
-*/
+#endif //GDCM_DEBUG
       return 0;
    }
 }
@@ -667,22 +360,22 @@ bool gdcmHeader::HasLUT(void) {
 
    // Check the presence of the LUT Descriptors, and LUT Tables    
    // LutDescriptorRed    
-   if ( !GetHeaderEntryByNumber(0x0028,0x1101) )
+   if ( !GetDocEntryByNumber(0x0028,0x1101) )
       return false;
    // LutDescriptorGreen 
-   if ( !GetHeaderEntryByNumber(0x0028,0x1102) )
+   if ( !GetDocEntryByNumber(0x0028,0x1102) )
       return false;
    // LutDescriptorBlue 
-   if ( !GetHeaderEntryByNumber(0x0028,0x1103) )
+   if ( !GetDocEntryByNumber(0x0028,0x1103) )
       return false;   
    // Red Palette Color Lookup Table Data
-   if ( !GetHeaderEntryByNumber(0x0028,0x1201) )
+   if ( !GetDocEntryByNumber(0x0028,0x1201) )
       return false; 
    // Green Palette Color Lookup Table Data       
-   if ( !GetHeaderEntryByNumber(0x0028,0x1202) )
+   if ( !GetDocEntryByNumber(0x0028,0x1202) )
       return false;
    // Blue Palette Color Lookup Table Data      
-   if ( !GetHeaderEntryByNumber(0x0028,0x1203) )
+   if ( !GetDocEntryByNumber(0x0028,0x1203) )
       return false;
    // FIXME : (0x0028,0x3006) : LUT Data (CTX dependent)
    //         NOT taken into account, but we don't know how to use it ...   
@@ -792,7 +485,7 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) {
    } 
    // forge the 4 * 8 Bits Red/Green/Blue/Alpha LUT 
    
-   unsigned char *LUTRGBA = new (unsigned char)[1024]; // 256 * 4 (R, G, B, Alpha) 
+   unsigned char *LUTRGBA = new unsigned char[1024]; // 256 * 4 (R, G, B, Alpha) 
    if (!LUTRGBA) {
       return NULL;
    }
@@ -849,27 +542,26 @@ unsigned char * gdcmHeader::GetLUTRGBA(void) {
 } 
 
 /**
- * \ingroup gdcmHeader
- * \brief gets the info from 0002,0010 : Transfert Syntax and gdcmTS
+ * \brief Accesses the info from 0002,0010 : Transfert Syntax and gdcmTS
  *        else 1.
- * @return the full Transfert Syntax Name (as oposite to Transfert Syntax UID)
+ * @return The full Transfert Syntax Name (as opposed to Transfert Syntax UID)
  */
 std::string gdcmHeader::GetTransfertSyntaxName(void) { 
    // use the gdcmTS (TS : Transfert Syntax)
    std::string TransfertSyntax = GetEntryByNumber(0x0002,0x0010);
    if (TransfertSyntax == GDCM_UNFOUND) {
-      dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName: unfound Transfert Syntax (0002,0010)");
+      dbg.Verbose(0, "gdcmHeader::GetTransfertSyntaxName:"
+                     " unfound Transfert Syntax (0002,0010)");
       return "Uncompressed ACR-NEMA";
    }
    // we do it only when we need it
    gdcmTS * ts = gdcmGlobal::GetTS();
    std::string tsName=ts->GetValue(TransfertSyntax);
-   //delete ts; // Seg Fault when deleted ?!
+   //delete ts; /// \todo Seg Fault when deleted ?!
    return tsName;
 }
 
 /**
- * \ingroup   gdcmHeader
  * \brief Sets the Pixel Area size in the Header
  *        --> not-for-rats function
  * @param ImageDataSize new Pixel Area Size
@@ -879,11 +571,9 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
    std::string content1;
    char car[20];
 
-   // Assumes HeaderEntry (GrPixel, NumPixel) is unique ...   
-   // TODO deal with multiplicity (see gdcmData/icone.dcm)
    sprintf(car,"%d",ImageDataSize);
  
-   gdcmHeaderEntry *a = GetHeaderEntryByNumber(GrPixel, NumPixel);
+   gdcmDocEntry *a = GetDocEntryByNumber(GrPixel, NumPixel);
    a->SetLength(ImageDataSize);
 
    ImageDataSize+=8;
@@ -892,101 +582,16 @@ void gdcmHeader::SetImageDataSize(size_t ImageDataSize) {
    SetEntryByNumber(content1, GrPixel, NumPixel);
 }
 
-
-/**
- * \ingroup   gdcmHeader
- * \brief compares 2 Headers, according to DICOMDIR rules
- *        --> not-for-rats function
- * \warning does NOT work with ACR-NEMA files
- * \todo find a trick to solve the pb (use RET fields ?)
- * @param header 
- * @return true if 'smaller'
- */
- bool gdcmHeader::operator<(gdcmHeader &header){
-   std::string s1,s2;
-
-   // Patient Name
-   s1=this->GetEntryByNumber(0x0010,0x0010);
-   s2=header.GetEntryByNumber(0x0010,0x0010);
-   if(s1 < s2)
-      return(true);
-   else if(s1 > s2)
-      return(false);
-   else
-   {
-      // Patient ID
-      s1=this->GetEntryByNumber(0x0010,0x0020);
-      s2=header.GetEntryByNumber(0x0010,0x0020);
-      if (s1 < s2)
-         return(true);
-      else if (s1 > s2)
-         return(1);
-      else
-      {
-         // Study Instance UID
-         s1=this->GetEntryByNumber(0x0020,0x000d);
-         s2=header.GetEntryByNumber(0x0020,0x000d);
-         if (s1 < s2)
-            return(true);
-         else if(s1 > s2)
-            return(false);
-         else
-         {
-            // Serie Instance UID
-            s1=this->GetEntryByNumber(0x0020,0x000e);
-            s2=header.GetEntryByNumber(0x0020,0x000e);
-            if (s1 < s2)
-               return(true);
-            else if(s1 > s2)
-               return(false);
-         }
-      }
-   }
-   return(false);
-}
-
-bool gdcmHeader::WriteEntry(gdcmHeaderEntry *tag, FILE *_fp,FileType type)
-{
-   guint32 length = tag->GetLength();
-                                                                                
-   // The value of a tag MUST (see the DICOM norm) be an odd number of
-   // bytes. When this is not the case, pad with an additional byte:
-   if(length%2==1)
-   {
-      tag->SetValue(tag->GetValue()+"\0");
-      tag->SetLength(tag->GetReadLength()+1);
-   }
-                                                                                
-   WriteEntryTagVRLength(tag, _fp, type);
-                                                                                
-   // Pixels are never loaded in the element !
-   // we stop writting when Pixel are processed
-   // FIX : we loose trailing elements (RAB, right now)
-   guint16 el     = tag->GetElement();
-   guint16 group  = tag->GetGroup();
-   int compte =0;
-   if ((group == GrPixel) && (el == NumPixel) ) {
-      compte++;
-      if (compte == countGrPixel) {// we passed *all* the GrPixel,NumPixel
-         return false;
-      }
-   }
-   WriteEntryValue(tag, _fp, type);
-   return true;
-}
-
 //-----------------------------------------------------------------------------
 // Protected
 
 /**
- * \ingroup   gdcmHeader
  * \brief anonymize a Header (removes Patient's personal info)
  *        (read the code to see which ones ...)
  */
 bool gdcmHeader::anonymizeHeader() {
 
-  gdcmHeaderEntry *patientNameHE = GetHeaderEntryByNumber (0x0010, 0x0010);
- // gdcmHeaderEntry *patientIDHE   = GetHeaderEntryByNumber (0x0010, 0x0020); 
+  gdcmDocEntry *patientNameHE = GetDocEntryByNumber (0x0010, 0x0010);
     
   ReplaceIfExistByNumber ("  ",0x0010, 0x2154); // Telephone   
   ReplaceIfExistByNumber ("  ",0x0010, 0x1040); // Adress