]> Creatis software - gdcm.git/blobdiff - src/gdcmHeader.cxx
Doxygenation
[gdcm.git] / src / gdcmHeader.cxx
index 9a3e9cf531243ac674e2e7b0b23a71a048e2c2ba..0dc8ef974d96b8c77a945cc488067f18b0438e7a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/23 09:30:22 $
-  Version:   $Revision: 1.169 $
+  Date:      $Date: 2004/06/28 16:00:18 $
+  Version:   $Revision: 1.174 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -29,7 +29,7 @@
 // Constructor / Destructor
 /**
  * \brief  Constructor 
- * @param  InFilename name of the file whose header we want to analyze
+ * @param  filename name of the file whose header we want to analyze
  * @param  exception_on_error whether we want to throw an exception or not
  * @param  enable_sequences = true to allow the header 
  *         to be parsed *inside* the SeQuences, when they have an actual length 
@@ -86,6 +86,67 @@ gdcmHeader::gdcmHeader(bool exception_on_error) :
 gdcmHeader::~gdcmHeader () {
 }
 
+
+/**
+ * \brief Performs some consistency checking on various 'File related' 
+ *       (as opposed to 'DicomDir related') entries 
+ *       then writes in a file all the (Dicom Elements) included the Pixels 
+ * @param fp file pointer on an already open file
+ * @param filetype Type of the File to be written 
+ *          (ACR-NEMA, ExplicitVR, ImplicitVR)
+ */
+void gdcmHeader::Write(FILE* fp,FileType filetype) {
+   
+   // Bits Allocated
+   if ( GetEntryByNumber(0x0028,0x0100) ==  "12") {
+      SetEntryByNumber("16", 0x0028,0x0100);
+   }
+
+  // correct Pixel group Length if necessary
+
+   // TODO : create a gdcmHeader::Write method and move this part.
+   //        (only gdcmHeader knows GrPixel, NumPixel)
+
+   int i_lgPix = GetEntryLengthByNumber(GrPixel, NumPixel);
+   if (i_lgPix != -2) { // no (GrPixel, NumPixel) element
+      char * dumm = new char[20];
+      sprintf(dumm ,"%d", i_lgPix+12);
+      std::string s_lgPix = dumm;
+      delete dumm;
+      ReplaceOrCreateByNumber(s_lgPix,GrPixel, 0x0000);
+   }
+
+   // Drop Palette Color, if necessary
+   
+   if ( GetEntryByNumber(0x0028,0x0002).c_str()[0] == '3' ) {
+    // if SamplesPerPixel = 3, sure we don't need any LUT !   
+    // Drop 0028|1101, 0028|1102, 0028|1103
+    // Drop 0028|1201, 0028|1202, 0028|1203
+
+     gdcmDocEntry *e;
+     e=GetDocEntryByNumber(0x0028,0x01101);
+     if (e) 
+        RemoveEntry(e);
+     e=GetDocEntryByNumber(0x0028,0x1102);
+     if (e) 
+        RemoveEntry(e);
+     e=GetDocEntryByNumber(0x0028,0x1103);
+
+     if (e) 
+        RemoveEntry(e);
+     e=GetDocEntryByNumber(0x0028,0x01201);
+     if (e) 
+        RemoveEntry(e);
+     e=GetDocEntryByNumber(0x0028,0x1202);
+     if (e) 
+        RemoveEntry(e);
+     e=GetDocEntryByNumber(0x0028,0x1203);
+     if (e) 
+       RemoveEntry(e);
+   }
+   gdcmDocument::Write(fp,filetype);
+}
+
 //-----------------------------------------------------------------------------
 // Print