From: jpr Date: Wed, 5 Jan 2005 16:53:23 +0000 (+0000) Subject: ENH : now parsing creates a Vitual DictEntry for Pixels Element, X-Git-Tag: Version1.0.bp~481 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a150a376b47fc0894b57d18a59e970b2b9f2889f;p=gdcm.git ENH : now parsing creates a Vitual DictEntry for Pixels Element, in order to allow further VR modification by user --- diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 6d5841a8..53535b8b 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -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 //----------------------------------------------------------------------------- diff --git a/src/gdcmDocument.h b/src/gdcmDocument.h index 490fbc74..ad5d48b1 100644 --- a/src/gdcmDocument.h +++ b/src/gdcmDocument.h @@ -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