From: jpr Date: Mon, 7 Nov 2005 09:46:36 +0000 (+0000) Subject: Add Method ComputeFullLength(), to allow further computaion of element 0x0000 X-Git-Tag: OpenJPEG.Version1.2~36 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=af288a85afcf018ea938b95dc5c87284ee9b83d6;p=gdcm.git Add Method ComputeFullLength(), to allow further computaion of element 0x0000 (Group length) of each 'zero level' group. --- diff --git a/src/gdcmDataEntry.cxx b/src/gdcmDataEntry.cxx index bec0d5f6..1fdb47e2 100644 --- a/src/gdcmDataEntry.cxx +++ b/src/gdcmDataEntry.cxx @@ -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) diff --git a/src/gdcmDataEntry.h b/src/gdcmDataEntry.h index 7a85bbf3..37d6d3e0 100644 --- a/src/gdcmDataEntry.h +++ b/src/gdcmDataEntry.h @@ -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); diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index b779a89a..ff098d10 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -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 diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 1dff9cd8..431ac51e 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -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 diff --git a/src/gdcmSQItem.h b/src/gdcmSQItem.h index 0d885225..b76afb5a 100644 --- a/src/gdcmSQItem.h +++ b/src/gdcmSQItem.h @@ -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); diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index 850b9858..fb0dfdfc 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -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 diff --git a/src/gdcmSeqEntry.h b/src/gdcmSeqEntry.h index 7836f8c0..96a8740f 100644 --- a/src/gdcmSeqEntry.h +++ b/src/gdcmSeqEntry.h @@ -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();