]> Creatis software - gdcm.git/commitdiff
- now gdcmHeader has its own Write methods (in order to split
authorjpr <jpr>
Mon, 28 Jun 2004 09:51:02 +0000 (09:51 +0000)
committerjpr <jpr>
Mon, 28 Jun 2004 09:51:02 +0000 (09:51 +0000)
      the job that has not to be done for gdcmDicomDir)

src/gdcmDocument.cxx
src/gdcmHeader.cxx
src/gdcmHeader.h

index 74f0069e75321c7912585a8cd92b860086b8de8b..4123b5e703cad5e096163dc82d98b04ed474ae33 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/28 09:30:58 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2004/06/28 09:51:02 $
+  Version:   $Revision: 1.37 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -518,12 +518,6 @@ bool gdcmDocument::CloseFile(void) {
  * \return Always true.
  */
 void gdcmDocument::Write(FILE* fp,FileType filetype) {
-///
-/// ==============
-///      The stuff is rewritten using the SeQuence based 
-///       tree-like stucture (cf : Print )
-///      To be checked
-/// =============
 
    /// \todo move the following lines (and a lot of others, to be written)
    /// to a future function CheckAndCorrectHeader
@@ -541,7 +535,7 @@ void gdcmDocument::Write(FILE* fp,FileType filetype) {
       /// \todo Refer to standards on page 21, chapter 6.2
       ///       "Value representation": values with a VR of UI shall be
       ///       padded with a single trailing null
-      ///       Dans le cas suivant on doit pader manuellement avec un 0
+      ///       in the following case we have to padd manually with a 0
       
       SetEntryLengthByNumber(18, 0x0002, 0x0010);
    } 
@@ -558,72 +552,12 @@ void gdcmDocument::Write(FILE* fp,FileType filetype) {
       
       SetEntryLengthByNumber(20, 0x0002, 0x0010);
    }
-
-// TODO : move to gdcmHeader::Write
-// -----------------------------------------------------
-   // Bits Allocated
-   if ( GetEntryByNumber(0x0028,0x0100) ==  "12") {
-      SetEntryByNumber("16", 0x0028,0x0100);
-   }
-
-  // correct Pixel group Length if necessary
-
-   guint16 GrPixel  = 0x7fe0;
-   guint16 NumPixel = 0x0010;
-
-   // 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
-   
-   // FIXME : Why is it always false ???
-
-   // std::cout << "entry 0x0028,0x0002 " << GetEntryByNumber(0x0028,0x0002).c_str() << std::endl;
-
- /*  if ( GetEntryByNumber(0x0028,0x0002).c_str() == "3" ) */{
-    
-    // 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);
- } 
-
-// ----------- end move to gdcmHeader::Write -----------------
   
 /**
  * \todo rewrite later, if really usefull
- *               ('Group Length' element is optional in DICOM)
- *
- *       --> Warning : un-updated odd groups lengthes can causes pb
- *       -->           (xmedcon breaker)
+ *       - 'Group Length' element is optional in DICOM
+ *       - but un-updated odd groups lengthes can causes pb
+ *         (xmedcon breaker)
  *
  * if ( (filetype == ImplicitVR) || (filetype == ExplicitVR) )
  *    UpdateGroupLength(false,filetype);
index a3e68cec9f572f7c25258e2af5e8d320501f7f35..243b59cc94cf89e707ea9547a1b6e63ead51c899 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/06/28 09:30:58 $
-  Version:   $Revision: 1.170 $
+  Date:      $Date: 2004/06/28 09:51:02 $
+  Version:   $Revision: 1.171 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -86,6 +86,74 @@ gdcmHeader::gdcmHeader(bool exception_on_error) :
 gdcmHeader::~gdcmHeader () {
 }
 
+
+/**
+ * \brief Writes in a file all the Header Entries (Dicom Elements) 
+ * @param fp file pointer on an already open file
+ * @param filetype Type of the File to be written 
+ *          (ACR-NEMA, ExplicitVR, ImplicitVR)
+ * \return Always true.
+ */
+void gdcmHeader::Write(FILE* fp,FileType filetype) {
+   
+   // Bits Allocated
+   if ( GetEntryByNumber(0x0028,0x0100) ==  "12") {
+      SetEntryByNumber("16", 0x0028,0x0100);
+   }
+
+  // correct Pixel group Length if necessary
+
+   //guint16 GrPixel  = 0x7fe0;
+   //guint16 NumPixel = 0x0010;
+
+   // 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
+   
+   // FIXME : Why is it always false ???
+
+   // std::cout << "entry 0x0028,0x0002 " << GetEntryByNumber(0x0028,0x0002).c_str() << std::endl;
+
+ /*  if ( GetEntryByNumber(0x0028,0x0002).c_str() == "3" ) */{
+    
+    // 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);
+}
+// ----------- end move to gdcmHeader::Write -----------------
+
 //-----------------------------------------------------------------------------
 // Print
 
index e67769cde3d89dddae4f47af9f46baebbb3936db..2b01cc81b1405e769e67d09d45eb13ea5d5381a4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmHeader.h,v $
   Language:  C++
-  Date:      $Date: 2004/06/28 09:30:58 $
-  Version:   $Revision: 1.78 $
+  Date:      $Date: 2004/06/28 09:51:02 $
+  Version:   $Revision: 1.79 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -183,6 +183,8 @@ public:
    /// Read (used in gdcmFile)
    void SetImageDataSize(size_t expectedSize);
 
+   void gdcmHeader::Write(FILE* fp,FileType filetype);
 protected:
    bool AnonymizeHeader();
    void GetImageOrientationPatient( float* iop );