]> Creatis software - gdcm.git/commitdiff
Add Method ComputeFullLength(), to allow further computaion of element 0x0000
authorjpr <jpr>
Mon, 7 Nov 2005 09:46:36 +0000 (09:46 +0000)
committerjpr <jpr>
Mon, 7 Nov 2005 09:46:36 +0000 (09:46 +0000)
(Group length) of each 'zero level' group.

src/gdcmDataEntry.cxx
src/gdcmDataEntry.h
src/gdcmDocEntry.h
src/gdcmSQItem.cxx
src/gdcmSQItem.h
src/gdcmSeqEntry.cxx
src/gdcmSeqEntry.h

index bec0d5f6d3b4893a7d7ba07ad8f5be0770a5d436..1fdb47e2d7563e75b3e3212f8f3aab257961c262 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/04 15:31:34 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2005/11/07 09:46:36 $
+  Version:   $Revision: 1.19 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -560,6 +560,15 @@ void DataEntry::WriteContent(std::ofstream *fp, FileType filetype)
       fp->seekp(1, std::ios::cur);  
 }
 
+/**
+ * \brief   Compute the full length of the elementary DataEntry (not only value
+ *          length) depending on the VR.
+ */
+uint32_t DataEntry::ComputeFullLength()
+{
+   return GetFullLength();
+}
+
 //-----------------------------------------------------------------------------
 // Protected
 void DataEntry::NewBinArea(void)
index 7a85bbf32cc3deb2227ada1564cae9aa8b57ef85..37d6d3e0644dbe2b64b1573063f0dbbfdfbc2066 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDataEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/26 15:56:51 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2005/11/07 09:46:36 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -46,7 +46,8 @@ public:
 
 // Write
    virtual void WriteContent(std::ofstream *fp, FileType filetype);
-
+   uint32_t ComputeFullLength();
+   
 // Set/Get data
    /// Sets the value (string) of the current Dicom entry
    //virtual void SetValue(std::string const &val);
index b779a89a5e54fb34d5e3ac723491a95a28665515..ff098d107c2b602457d367e8803aa1f3fb07c4ce 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:47 $
-  Version:   $Revision: 1.55 $
+  Date:      $Date: 2005/11/07 09:46:36 $
+  Version:   $Revision: 1.56 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -92,10 +92,11 @@ public:
    virtual void SetLength(uint32_t l) { Length = l; }
    /// \brief Returns the actual value length of the current Dicom entry
    /// \warning this value is not *always* the one stored in the Dicom header
-   ///          in case of well knowned bugs
+   ///          in case of well known bugs
    const uint32_t &GetLength() const { return Length; }
 
    uint32_t GetFullLength();
+   virtual uint32_t ComputeFullLength() = 0;
 
 // The following 3 members, for internal use only ! 
    /// \brief   Sets the offset of the Dicom entry
index 1dff9cd878cf60e9fe10554fe5152aa672376fff..431ac51e1702320ba439dc4557effbe70d50d815 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/10/27 09:52:33 $
-  Version:   $Revision: 1.78 $
+  Date:      $Date: 2005/11/07 09:46:37 $
+  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
@@ -99,6 +99,29 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
    } 
 }
 
+/**
+ * \brief   Compute the full length of the SQItem (not only value
+ *          length) depending on the VR.
+ */
+uint32_t SQItem::ComputeFullLength()
+{
+   uint32_t l = 8;  // Item Starter length
+   for (ListDocEntry::iterator it = DocEntries.begin();  
+                               it != DocEntries.end();
+                             ++it)
+   {   
+      // we skip delimitors (start and end one) because 
+      // we force them as 'no length'
+      if ( (*it)->GetGroup() == 0xfffe )
+      {
+         continue;
+      }
+      l += (*it)->ComputeFullLength();
+   }
+   l += 8; // 'Item Delimitation' item 
+   return l;  
+}
+
 /**
  * \brief   Inserts *in the right place* any Entry (Dicom Element)
  *          into the Sequence Item
index 0d8852258e9471ff5481c4fb87a026312dadb440..b76afb5a9aecd9220c9a206c4fb1ee2c2e227641 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/25 14:52:35 $
-  Version:   $Revision: 1.47 $
+  Date:      $Date: 2005/11/07 09:46:37 $
+  Version:   $Revision: 1.48 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -47,6 +47,7 @@ public:
 
    virtual void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
    void WriteContent(std::ofstream *fp, FileType filetype);
+   uint32_t ComputeFullLength();
 
    bool AddEntry(DocEntry *Entry); // add to the List
    bool RemoveEntry(DocEntry *EntryToRemove);
index 850b9858b06fb5c2aba7f28b1730c83258b64c26..fb0dfdfc2110af4526b38cd02d1ae2f2637a54ec 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/11/03 08:36:19 $
-  Version:   $Revision: 1.61 $
+  Date:      $Date: 2005/11/07 09:46:36 $
+  Version:   $Revision: 1.62 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -102,6 +102,23 @@ void SeqEntry::WriteContent(std::ofstream *fp, FileType filetype)
    binary_write(*fp, seq_term_lg);
 }
 
+/**
+ * \brief   Compute the full length of the SeqEntry (not only value
+ *          length) depending on the VR.
+ */
+uint32_t SeqEntry::ComputeFullLength()
+{
+   uint32_t l = 12; // Tag (4) + VR (explicit) 4 + 4 (length);   
+   for(ListSQItem::iterator cc  = Items.begin();
+                            cc != Items.end();
+                          ++cc)
+   {        
+      l += (*cc)->ComputeFullLength();
+   }   
+   l += 8; // seq_term Tag (4) +  seq_term_lg (4)
+   return l;
+}
+
 /**
  * \brief   adds the passed ITEM to the ITEM chained List for this SeQuence.
  * @param sqItem SQItem to be pushed back in the SeqEntry
index 7836f8c0afbe490bc47abebc07aa4a31938defbd..96a8740f94a905d8094f8773ff6a3afe3b3201b9 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/24 16:00:48 $
-  Version:   $Revision: 1.36 $
+  Date:      $Date: 2005/11/07 09:46:36 $
+  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
@@ -47,7 +47,8 @@ public:
 
    void Print(std::ostream &os = std::cout, std::string const &indent = "" ); 
    void WriteContent(std::ofstream *fp, FileType filetype);
-
+   uint32_t ComputeFullLength();
+     
    void AddSQItem(SQItem *it, int itemNumber);
    void ClearSQItem();
    SQItem *GetFirstSQItem();