]> Creatis software - gdcm.git/commitdiff
* src/gdcmFile.cxx, gdcmDocument.cxx : fix the bug on the group|element
authorregrain <regrain>
Fri, 28 Jan 2005 10:34:27 +0000 (10:34 +0000)
committerregrain <regrain>
Fri, 28 Jan 2005 10:34:27 +0000 (10:34 +0000)
     0002|0000. The value was incorrect.
   -- BeNours

ChangeLog
src/gdcmDocument.cxx
src/gdcmFile.cxx

index ed1691c7a6ad97c45aacf7b496ec8982fb741b75..b81dbe60bb8f78ea5dc85488ca1008118d542df4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-01-28 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * src/gdcmFile.cxx, gdcmDocument.cxx : fix the bug on the group|element 
+     0002|0000. The value was incorrect.
+
 2005-01-28 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
    * vtk/vtkGdcmWriter.[h|cxx] : add the gestion of UID
 
index a252297e52f728abb71c16fadb83b91a4e18c491..f6b6f99daccce3e9f35bd05caa1e413c56494c39 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/28 09:31:51 $
-  Version:   $Revision: 1.215 $
+  Date:      $Date: 2005/01/28 10:34:28 $
+  Version:   $Revision: 1.216 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -2181,23 +2181,28 @@ int Document::ComputeGroup0002Length( FileType filetype )
   
    // for each zero-level Tag in the DCM Header
    DocEntry *entry = GetFirstEntry();
-   while(entry)
+   while( entry )
    {
       gr = entry->GetGroup();
 
-      if (gr == 0x0002)
+      if( gr == 0x0002 )
       {
          found0002 = true;
-         vr = entry->GetVR();            
-         if (filetype == ExplicitVR) 
+
+         if( entry->GetElement() != 0x0000 )
          {
-            if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) 
+            vr = entry->GetVR();
+            if( filetype == ExplicitVR )
             {
-               groupLength +=  4; // explicit VR AND OB, OW, SQ : 4 more bytes
+               if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) 
+               {
+                  // explicit VR AND OB, OW, SQ : 4 more bytes
+                  groupLength +=  4;
+               }
             }
+            groupLength += 2 + 2 + 4 + entry->GetLength();   
          }
-         groupLength += 2 + 2 + 4 + entry->GetLength();   
       }
       else if (found0002 )
          break;
index 9ba43132d36993af2ca089078c337e4afbace32a..6fc5a059a97cc4939eaaffde8bc6018c0af47efc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/28 09:37:29 $
-  Version:   $Revision: 1.203 $
+  Date:      $Date: 2005/01/28 10:34:28 $
+  Version:   $Revision: 1.204 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -157,14 +157,21 @@ bool File::Write(std::string fileName, FileType filetype)
       return false;
    }
 
+   // Entry : 0002|0000 = group length -> recalculated
+   ValEntry *e0002 = GetValEntry(0x0002,0x0000);
+   if( e0002 )
+   {
+      std::ostringstream sLen;
+      sLen << ComputeGroup0002Length(filetype);
+      e0002->SetValue(sLen.str());
+   }
+
    // Bits Allocated
    if ( GetEntryValue(0x0028,0x0100) ==  "12")
    {
       SetValEntry("16", 0x0028,0x0100);
    }
 
-  /// \todo correct 'Pixel group' Length if necessary
-
    int i_lgPix = GetEntryLength(GrPixel, NumPixel);
    if (i_lgPix != -2)
    {
@@ -178,7 +185,6 @@ bool File::Write(std::string fileName, FileType filetype)
    //         (or in future gdcmPixelData class)
 
    // Drop Palette Color, if necessary
-   
    if ( GetEntryValue(0x0028,0x0002).c_str()[0] == '3' )
    {
       // if SamplesPerPixel = 3, sure we don't need any LUT !