]> Creatis software - gdcm.git/commitdiff
ENH : now parsing creates a Vitual DictEntry for Pixels Element,
authorjpr <jpr>
Wed, 5 Jan 2005 16:53:23 +0000 (16:53 +0000)
committerjpr <jpr>
Wed, 5 Jan 2005 16:53:23 +0000 (16:53 +0000)
      in order to allow further VR modification by user

src/gdcmDocument.cxx
src/gdcmDocument.h

index 6d5841a82f76ac4fbafeece947c4b0ac0ec2595e..53535b8be0e1911d2390aa47ab1683ff38c66fa8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/12/16 13:46:37 $
-  Version:   $Revision: 1.151 $
+  Date:      $Date: 2005/01/05 16:53:23 $
+  Version:   $Revision: 1.152 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -2213,8 +2213,7 @@ bool Document::IsDocEntryAnInteger(DocEntry *entry)
    if ( vr == "UL" || vr == "US" || vr == "SL" || vr == "SS" )
    {
       return true;
-   }
-   
+   }   
    return false;
 }
 
@@ -3127,6 +3126,56 @@ bool Document::operator<(Document &document)
    return false;
 }
 
+
+/**
+ * \brief   Re-computes the length of a ACR-NEMA/Dicom group from a DcmHeader
+ * @param filetype Type of the File to be written 
+ */
+int Document::ComputeGroup0002Length( FileType filetype ) 
+{
+   uint16_t gr, el;
+   std::string vr;
+   
+   int groupLength = 0;
+   bool found0002 = false;   
+  
+   // for each zero-level Tag in the DCM Header
+   DocEntry *entry;
+
+   Initialize();
+   
+   for (;;)
+   {
+      entry = GetNextEntry();
+
+      if ( entry == 0 )
+         break;
+
+      gr = entry->GetGroup();
+
+      if (gr == 0x0002)
+         found0002 = true;
+      else 
+         if (found0002 )
+            break;
+         else
+            continue;
+
+      el = entry->GetElement();
+      vr = entry->GetVR();            
+      if (filetype == ExplicitVR) 
+      {
+         if ( (vr == "OB") || (vr == "OW") || (vr == "SQ") ) 
+         {
+            groupLength +=  4; // explicit VR AND OB, OW, SQ : 4 more bytes
+         }
+      }
+      groupLength += 2 + 2 + 4 + entry->GetLength();   
+   }
+   return groupLength; 
+}
+
 } // end namespace gdcm
 
 //-----------------------------------------------------------------------------
index 490fbc74c867d851c11e82847660bcfa08a709e6..ad5d48b1094b8005a2609ccf171c062e2baeefce 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/05 15:38:28 $
-  Version:   $Revision: 1.70 $
+  Date:      $Date: 2005/01/05 16:53:23 $
+  Version:   $Revision: 1.71 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -267,6 +267,9 @@ public:
    int GetSwapCode() { return SwapCode; }
    
    bool operator<(Document &document);
+
+   int ComputeGroup0002Length( FileType filetype );
+
 };
 } // end namespace gdcm