From 57e3ee08a94dc1cd122a0b9c01f091e1b6913152 Mon Sep 17 00:00:00 2001 From: frog Date: Mon, 21 Jun 2004 12:38:28 +0000 Subject: [PATCH] * src/gdcmBinEntry.cxx, gdcmValEntry.cxx: gdcmBinEntry::Print() now properly calls gdcmValEntry::Print() (that was weed out from code related to gdcmBinEntry). --- ChangeLog | 3 +++ src/gdcmBinEntry.cxx | 32 +++++++++++++++++++++---------- src/gdcmDocument.cxx | 34 +++++++++++++-------------------- src/gdcmValEntry.cxx | 45 ++++++++++++++++++++------------------------ src/gdcmValEntry.h | 12 ++++++------ 5 files changed, 64 insertions(+), 62 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2253ee22..7d070723 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ * src/gdcmHeader.h: the declaration of gdcmHeader::gdcmHeader(bool) as explicit constructor didn't do the trick to fix the above problem. Could anyone explain why ? + * src/gdcmBinEntry.cxx, gdcmValEntry.cxx: gdcmBinEntry::Print() now + properly calls gdcmValEntry::Print() (that was weed out from + code related to gdcmBinEntry). 2004-06-20 Eric Boix * In order to fix memory leaks: diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx index 0a18e65f..aca20db6 100644 --- a/src/gdcmBinEntry.cxx +++ b/src/gdcmBinEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.cxx,v $ Language: C++ - Date: $Date: 2004/06/20 18:08:47 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/06/21 12:38:28 $ + Version: $Revision: 1.12 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -26,7 +26,8 @@ /** * \brief Constructor from a given gdcmBinEntry */ -gdcmBinEntry::gdcmBinEntry(gdcmDictEntry* e) : gdcmValEntry(e) { +gdcmBinEntry::gdcmBinEntry(gdcmDictEntry* e) : gdcmValEntry(e) +{ this->voidArea = NULL; } @@ -34,7 +35,8 @@ gdcmBinEntry::gdcmBinEntry(gdcmDictEntry* e) : gdcmValEntry(e) { * \brief Constructor from a given gdcmBinEntry * @param e Pointer to existing Doc entry */ -gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry()){ +gdcmBinEntry::gdcmBinEntry(gdcmDocEntry* e) : gdcmValEntry(e->GetDictEntry()) +{ this->UsableLength = e->GetLength(); this->ReadLength = e->GetReadLength(); this->ImplicitVR = e->IsImplicitVR(); @@ -57,15 +59,25 @@ gdcmBinEntry::~gdcmBinEntry(){ //----------------------------------------------------------------------------- // Print /* - * \ingroup gdcmDocEntry * \brief canonical Printer */ -void gdcmBinEntry::Print(std::ostream &os) { - PrintCommonPart(os); - /// \todo Write a true specialisation of Print i.e. display something - /// for BinEntry extension. - dbg.Verbose(1, "gdcmBinEntry::Print: so WHAT ?"); +void gdcmBinEntry::Print(std::ostream &os) +{ + gdcmValEntry::Print(os); + std::ostringstream s; + if (voidArea != NULL) + { + s << " [gdcm::Binary data loaded with lenght is " + << GetLength() << "]" + << std::endl; + } + else + { + s << " [gdcm::Binary data NOT loaded]" + << std::endl; + } + os << s.str(); } //----------------------------------------------------------------------------- // Public diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index a6bfec4f..fa1d4a7d 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/06/21 04:18:25 $ - Version: $Revision: 1.20 $ + Date: $Date: 2004/06/21 12:38:29 $ + Version: $Revision: 1.21 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -899,8 +899,7 @@ size_t gdcmDocument::GetEntryOffsetByNumber(guint16 Group, guint16 Elem) gdcmDocEntry* Entry = GetDocEntryByNumber(Group, Elem); if (!Entry) { - dbg.Verbose(1, "gdcmDocument::GetDocEntryByNumber", - "failed to Locate gdcmDocEntry"); + dbg.Verbose(1, "gdcmDocument::GetDocEntryByNumber: no entry present."); return (size_t)0; } return Entry->GetOffset(); @@ -918,8 +917,7 @@ void * gdcmDocument::GetEntryVoidAreaByNumber(guint16 Group, guint16 Elem) gdcmDocEntry* Entry = GetDocEntryByNumber(Group, Elem); if (!Entry) { - dbg.Verbose(1, "gdcmDocument::GetDocEntryByNumber", - "failed to Locate gdcmDocEntry"); + dbg.Verbose(1, "gdcmDocument::GetDocEntryByNumber: no entry"); return (NULL); } return ((gdcmBinEntry *)Entry)->GetVoidArea(); @@ -1160,12 +1158,12 @@ void gdcmDocument::WriteEntryTagVRLength(gdcmDocEntry *tag, */ // \todo TODO : to be re -written recursively ! -void gdcmDocument::WriteEntryValue(gdcmDocEntry *tag, FILE *_fp,FileType type) +void gdcmDocument::WriteEntryValue(gdcmDocEntry *Entry, FILE *_fp,FileType type) { (void)type; - guint16 group = tag->GetGroup(); - VRKey vr = tag->GetVR(); - guint32 lgr = tag->GetReadLength(); + guint16 group = Entry->GetGroup(); + VRKey vr = Entry->GetVR(); + guint32 lgr = Entry->GetReadLength(); if (vr == "SQ") // SeQuences have no value: @@ -1174,15 +1172,9 @@ void gdcmDocument::WriteEntryValue(gdcmDocEntry *tag, FILE *_fp,FileType type) // Delimiters have no associated value: return; - //-------------------------------- - // - // FIXME :right now, both value and voidArea belong to gdcmValue - // - // ------------------------------- - -// if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(tag) ) { +// if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(Entry) ) { void *voidArea; - gdcmBinEntry *BinEntry= (gdcmBinEntry *)tag;; + gdcmBinEntry *BinEntry= (gdcmBinEntry *)Entry;; voidArea = BinEntry->GetVoidArea(); if (voidArea != NULL) { // there is a 'non string' LUT, overlay, etc @@ -1198,7 +1190,7 @@ void gdcmDocument::WriteEntryValue(gdcmDocEntry *tag, FILE *_fp,FileType type) // we split the string and write each value as a short int std::vector tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value - Tokenize (((gdcmValEntry *)tag)->GetValue(), tokens, "\\"); + Tokenize (((gdcmValEntry *)Entry)->GetValue(), tokens, "\\"); for (unsigned int i=0; i tokens; tokens.erase(tokens.begin(),tokens.end()); // clean any previous value - Tokenize (((gdcmValEntry *)tag)->GetValue(), tokens, "\\"); + Tokenize (((gdcmValEntry *)Entry)->GetValue(), tokens, "\\"); for (unsigned int i=0; iGetValue().c_str(), + fwrite (((gdcmValEntry *)Entry)->GetValue().c_str(), (size_t)lgr ,(size_t)1, _fp); // Elem value } diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx index 7f9613dc..194bd88d 100644 --- a/src/gdcmValEntry.cxx +++ b/src/gdcmValEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmValEntry.cxx,v $ Language: C++ - Date: $Date: 2004/06/21 04:43:02 $ - Version: $Revision: 1.8 $ + Date: $Date: 2004/06/21 12:38:29 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -27,20 +27,20 @@ //----------------------------------------------------------------------------- // Constructor / Destructor /** - * \ingroup gdcmValEntry * \brief Constructor from a given gdcmDictEntry * @param e Pointer to existing dictionary entry */ -gdcmValEntry::gdcmValEntry(gdcmDictEntry* e) : gdcmDocEntry(e) { +gdcmValEntry::gdcmValEntry(gdcmDictEntry* e) : gdcmDocEntry(e) +{ voidArea = NULL; // will be in BinEntry ? } /** - * \ingroup gdcmValEntry * \brief Constructor from a given gdcmDocEntry * @param e Pointer to existing Doc entry */ -gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) : gdcmDocEntry(e->GetDictEntry()){ +gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) : gdcmDocEntry(e->GetDictEntry()) +{ this->UsableLength = e->GetLength(); this->ReadLength = e->GetReadLength(); this->ImplicitVR = e->IsImplicitVR(); @@ -55,7 +55,8 @@ gdcmValEntry::gdcmValEntry(gdcmDocEntry* e) : gdcmDocEntry(e->GetDictEntry()){ /** * \brief Canonical destructor. */ -gdcmValEntry::~gdcmValEntry (void) { +gdcmValEntry::~gdcmValEntry (void) +{ if (!voidArea) // will be in BinEntry free(voidArea); } @@ -64,13 +65,11 @@ gdcmValEntry::~gdcmValEntry (void) { //----------------------------------------------------------------------------- // Print /** - * \ingroup gdcmValEntry * \brief canonical Printer */ -void gdcmValEntry::Print(std::ostream & os) { - +void gdcmValEntry::Print(std::ostream & os) +{ std::ostringstream s; - //size_t o; //not used unsigned short int g, e; char st[20]; TSKey v; @@ -90,20 +89,16 @@ void gdcmValEntry::Print(std::ostream & os) { vr = GetVR(); gdcmTS * ts = gdcmGlobal::GetTS(); - if (voidArea != NULL) { // should be moved in gdcmBinEntry Printer (when any) - s << " [gdcm::Non String Data Loaded in Unsecure Area (" - << GetLength() << ") ]"; - } - - else { - v = GetValue(); // not applicable for SQ ... - d2 = CreateCleanString(v); // replace non printable characters by '.' - if( (GetLength()<=MAX_SIZE_PRINT_ELEMENT_VALUE) || - (printLevel>=3) || - (d2.find("gdcm::NotLoaded.") < d2.length()) ) - s << " [" << d2 << "]"; - else - s << " [gdcm::too long for print (" << GetLength() << ") ]"; + v = GetValue(); // not applicable for SQ ... + d2 = CreateCleanString(v); // replace non printable characters by '.' + if( (GetLength()<=MAX_SIZE_PRINT_ELEMENT_VALUE) || + (printLevel>=3) || (d2.find("gdcm::NotLoaded.") < d2.length()) ) + { + s << " [" << d2 << "]"; + } + else + { + s << " [gdcm::too long for print (" << GetLength() << ") ]"; } // Display the UID value (instead of displaying only the rough code) diff --git a/src/gdcmValEntry.h b/src/gdcmValEntry.h index 86f4f436..5a23a02a 100644 --- a/src/gdcmValEntry.h +++ b/src/gdcmValEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmValEntry.h,v $ Language: C++ - Date: $Date: 2004/06/21 04:43:02 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/06/21 12:38:29 $ + Version: $Revision: 1.12 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -55,11 +55,11 @@ protected: private: -// Variables +// Members : - /// \brief Document Entry value, stored as a std::string (VR will be used, - /// later, to decode) - + /// \brief Document Entry value, internaly represented as a std::string + /// The Value Representation (\ref gdcmVR) is indenpendently used + /// in order to interpret (decode) this field. std::string value; }; -- 2.48.1