From: frog Date: Wed, 23 Jun 2004 13:02:35 +0000 (+0000) Subject: gdcmDocEntry::PrintCommonPart() and ::WriteCommonPart() removed. X-Git-Tag: Version0.5.bp~107 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=513f52eb83d002f898a8f0995e8525b269d9d225;p=gdcm.git gdcmDocEntry::PrintCommonPart() and ::WriteCommonPart() removed. Use the gdcmDocEntry::Print() and Write() instead. --- diff --git a/ChangeLog b/ChangeLog index f386e031..19137b56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-06-21 Eric Boix + * gdcmDocEntry::PrintCommonPart() and ::WriteCommonPart() removed. + Use the gdcmDocEntry::Print() and Write() instead. + 2004-06-22 Jean-Pierre Roux In order : to write Sequences, whatever their imbrication level, : to allow user to create his own Sequences diff --git a/src/gdcmBinEntry.cxx b/src/gdcmBinEntry.cxx index 0e37c125..dc8fa2db 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/22 14:42:01 $ - Version: $Revision: 1.15 $ + Date: $Date: 2004/06/23 13:02:35 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -64,9 +64,7 @@ gdcmBinEntry::~gdcmBinEntry(){ void gdcmBinEntry::Print(std::ostream &os) { - //gdcmValEntry::Print(os); // replaced by PrintCommonPart - // to avoid bugging the display - PrintCommonPart(os); + gdcmDocEntry::Print(os); std::ostringstream s; if (voidArea != NULL) { @@ -79,13 +77,13 @@ void gdcmBinEntry::Print(std::ostream &os) s << " [gdcm::Binary data NOT loaded]" << std::endl; } - os << s.str(); } /* * \brief canonical Writer */ -void gdcmBinEntry::Write(FILE *fp) { +void gdcmBinEntry::Write(FILE *fp, FileType filetype) { + gdcmDocEntry::Write(fp, filetype); void *voidArea = GetVoidArea(); int lgr=GetLength(); if (voidArea != NULL) diff --git a/src/gdcmBinEntry.h b/src/gdcmBinEntry.h index 90763e3b..53bf158a 100644 --- a/src/gdcmBinEntry.h +++ b/src/gdcmBinEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmBinEntry.h,v $ Language: C++ - Date: $Date: 2004/06/22 14:42:02 $ - Version: $Revision: 1.10 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,7 +41,7 @@ public: ~gdcmBinEntry(void); void Print(std::ostream &os = std::cout); - virtual void Write(FILE *fp); + virtual void Write(FILE*, FileType); /// \brief Returns the area value of the current Dicom Header Entry /// when it's not string-translatable (e.g : a LUT table) diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 5f8c5c17..7fbc137c 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2004/06/23 02:13:14 $ - Version: $Revision: 1.51 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.52 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -556,7 +556,6 @@ void gdcmDicomDir::SetElement(std::string &path,gdcmDicomDirType type, } for(it=elemList.begin();it!=elemList.end();++it) { - std::cout << "it " << std::endl; tmpGr=it->group; tmpEl=it->elem; dictEntry=GetPubDict()->GetDictEntryByNumber(tmpGr,tmpEl); diff --git a/src/gdcmDocEntry.cxx b/src/gdcmDocEntry.cxx index 6dff08d1..522b1667 100644 --- a/src/gdcmDocEntry.cxx +++ b/src/gdcmDocEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.cxx,v $ Language: C++ - Date: $Date: 2004/06/22 13:47:33 $ - Version: $Revision: 1.8 $ + Date: $Date: 2004/06/23 13:02:36 $ + 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 @@ -38,25 +38,14 @@ gdcmDocEntry::gdcmDocEntry(gdcmDictEntry* in) { entry = in; } -/** - * \ingroup gdcmDocEntry - * \brief Canonical Printer - * @param os ostream we want to print in - */ -void gdcmDocEntry::Print(std::ostream & os) { - std::ostringstream s; - s << std::endl; - PrintCommonPart(os); - os << s.str(); -} - //----------------------------------------------------------------------------- // Print /** * \ingroup gdcmDocEntry * \brief Prints the common part of gdcmValEntry, gdcmBinEntry, gdcmSeqEntry + * @param os ostream we want to print in */ -void gdcmDocEntry::PrintCommonPart(std::ostream & os) { +void gdcmDocEntry::Print(std::ostream & os) { printLevel=2; // FIXME @@ -117,15 +106,6 @@ void gdcmDocEntry::PrintCommonPart(std::ostream & os) { * \brief Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry */ void gdcmDocEntry::Write(FILE *fp, FileType filetype) { - std::cout << "gdcmDocEntry::Write : Is that what you wanted to do ? " << std::endl; - WriteCommonPart(fp, filetype); -} - -/** - * \ingroup gdcmDocEntry - * \brief Writes the common part of any gdcmValEntry, gdcmBinEntry, gdcmSeqEntry - */ -void gdcmDocEntry::WriteCommonPart(FILE *fp, FileType filetype) { guint16 group = GetGroup(); VRKey vr = GetVR(); diff --git a/src/gdcmDocEntry.h b/src/gdcmDocEntry.h index 11d2b0bf..9eafc568 100644 --- a/src/gdcmDocEntry.h +++ b/src/gdcmDocEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocEntry.h,v $ Language: C++ - Date: $Date: 2004/06/22 13:47:33 $ - Version: $Revision: 1.10 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.11 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -126,9 +126,6 @@ public: virtual void Print (std::ostream & os = std::cout); virtual void Write(FILE *fp, FileType filetype); - void gdcmDocEntry::PrintCommonPart(std::ostream & os); - void gdcmDocEntry::WriteCommonPart(FILE *fp, FileType filetype); - guint32 GetFullLength(void); void Copy(gdcmDocEntry *doc); diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index 43f9b0a1..92bf75e0 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/23 09:30:22 $ - Version: $Revision: 1.26 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.27 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -571,8 +571,8 @@ bool gdcmDocument::WriteF(FileType filetype) { * if ( filetype == ACR) * UpdateGroupLength(true,ACR); */ - - Write(fp,filetype); // the gdcmElementSet one ! + + gdcmElementSet::Write(fp,filetype); /// WriteEntries(fp,type); // old stuff return true; diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index 0b373346..50e40f35 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2004/06/22 14:42:02 $ - Version: $Revision: 1.12 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -60,11 +60,18 @@ gdcmElementSet::~gdcmElementSet() * from the H Table * @return */ -void gdcmElementSet::Print(std::ostream & os) { +void gdcmElementSet::Print(std::ostream & os) +{ + gdcmDocEntry* Entry; for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i) { - //(i)->second->SetPrintLevel(printLevel); - (i->second)->Print(os); + Entry = i->second; + Entry->Print(os); + bool PrintEndLine = true; + if ( gdcmSeqEntry* SeqEntry = dynamic_cast(Entry) ) + PrintEndLine = false; + if (PrintEndLine) + os << std::endl; } } @@ -73,35 +80,12 @@ void gdcmElementSet::Print(std::ostream & os) { * from the H Table * @return */ -void gdcmElementSet::Write(FILE *fp, FileType filetype) { - -// Troubles expected : BinEntries ARE ValEntries :-( -// BinEntry is checked first, then ValEntry; +void gdcmElementSet::Write(FILE *fp, FileType filetype) +{ - gdcmDocEntry *e; for (TagDocEntryHT::iterator i = tagHT.begin(); i != tagHT.end(); ++i) { - e=i->second; - e->WriteCommonPart(fp, filetype); - std::cout<GetKey() << " " << std::hex << e->GetVR() << " " - << e->GetName() - << std::endl; - -// e->Write(fp,filetype); // This will be the right way to proceed ! - - if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(e) ) { - BinEntry->Write(fp); - continue; - } - if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(e) ) { - ValEntry->Write(fp); - continue; - } - - if (gdcmSeqEntry* SeqEntry = dynamic_cast< gdcmSeqEntry* >(e) ) { - SeqEntry->Write(fp,filetype); - continue; - } + i->second->Write(fp, filetype); } } //----------------------------------------------------------------------------- @@ -112,7 +96,6 @@ void gdcmElementSet::Write(FILE *fp, FileType filetype) { //----------------------------------------------------------------------------- // Private - /** * \brief add a new Dicom Element pointer to the H Table * @param NewEntry entry to add diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 82c4ed3d..f0fa2503 100644 --- a/src/gdcmSQItem.cxx +++ b/src/gdcmSQItem.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSQItem.cxx,v $ Language: C++ - Date: $Date: 2004/06/23 02:13:14 $ - Version: $Revision: 1.15 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -59,52 +59,43 @@ gdcmSQItem::~gdcmSQItem() void gdcmSQItem::Print(std::ostream & os) { std::ostringstream s; - if (SQDepthLevel>0) { + if (SQDepthLevel>0) + { for (int i=0;iSetPrintLevel(printLevel); //self->GetPrintLevel() ? - (*i)->SetPrintLevel(2); - (*i)->Print(os); + gdcmDocEntry* Entry = *i; + bool PrintEndLine = true; + + os << s.str(); + Entry->SetPrintLevel(2); + Entry->Print(os); + if ( gdcmSeqEntry* SeqEntry = dynamic_cast(Entry) ) + PrintEndLine = false; + if (PrintEndLine) + os << std::endl; } } - /* * \ingroup gdcmSQItem * \brief canonical Writer */ - void gdcmSQItem::Write(FILE *fp,FileType filetype) { - gdcmDocEntry *Entry; +void gdcmSQItem::Write(FILE *fp,FileType filetype) +{ for (ListDocEntry::iterator i = docEntries.begin(); i != docEntries.end(); ++i) { - Entry=*i; - (Entry)->WriteCommonPart(fp, filetype); - - if (gdcmBinEntry* BinEntry = dynamic_cast< gdcmBinEntry* >(Entry) ) { - BinEntry->Write(fp); - return; - } - if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(Entry) ) { - ValEntry->Write(fp); - return; - } - if (gdcmSeqEntry* SeqEntry = dynamic_cast< gdcmSeqEntry* >(Entry) ) { - SeqEntry->Write(fp,filetype); - return; - } + (*i)->Write(fp, filetype); } } - //----------------------------------------------------------------------------- // Public /** diff --git a/src/gdcmSeqEntry.cxx b/src/gdcmSeqEntry.cxx index 94b3f9bc..a42f7f16 100644 --- a/src/gdcmSeqEntry.cxx +++ b/src/gdcmSeqEntry.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.cxx,v $ Language: C++ - Date: $Date: 2004/06/23 03:36:24 $ - Version: $Revision: 1.17 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -39,7 +39,6 @@ gdcmSeqEntry::gdcmSeqEntry(gdcmDictEntry* e, int depth) } /** - * \ingroup gdcmSeqEntry * \brief Canonical destructor. */ gdcmSeqEntry::~gdcmSeqEntry() { @@ -52,26 +51,21 @@ gdcmSeqEntry::~gdcmSeqEntry() { delete seq_term; } -//----------------------------------------------------------------------------- -// Print /* * \brief canonical Printer */ void gdcmSeqEntry::Print(std::ostream &os){ - std::ostringstream s,s2; - std::string vr; // First, Print the Dicom Element itself. SetPrintLevel(2); - PrintCommonPart(os); - s << std::endl; - os << s.str(); + gdcmDocEntry::Print(os); + os << std::endl; - if (GetReadLength() == 0) - return; + if (GetReadLength() == 0) + return; - // Then, Print each SQ Item - for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc) + // Then, Print each SQ Item + for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc) { (*cc)->Print(os); } @@ -79,30 +73,29 @@ void gdcmSeqEntry::Print(std::ostream &os){ // at end, print the sequence terminator item, if any if (delimitor_mode) { for (int i=0;iPrint(os); } else - std::cout - << " -------------- should have a sequence terminator item" - << std::endl; + os << " -------------- should have a sequence terminator item"; } - } - +} /* * \brief canonical Writer */ -void gdcmSeqEntry::Write(FILE *fp, FileType filetype) { - for(ListSQItem::iterator cc = GetSQItems().begin(); - cc != GetSQItems().end(); - ++cc) { - std::cout << "Et un SQItem !" << std::endl; - (*cc)->Write(fp, filetype); // Don't remove param filetype ! +void gdcmSeqEntry::Write(FILE *fp, FileType filetype) +{ + gdcmDocEntry::Write(fp, filetype); + for(ListSQItem::iterator cc = GetSQItems().begin(); + cc != GetSQItems().end(); + ++cc) + { + (*cc)->Write(fp, filetype); } } + //----------------------------------------------------------------------------- // Public diff --git a/src/gdcmSeqEntry.h b/src/gdcmSeqEntry.h index 764ab321..d5de81da 100644 --- a/src/gdcmSeqEntry.h +++ b/src/gdcmSeqEntry.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSeqEntry.h,v $ Language: C++ - Date: $Date: 2004/06/22 13:47:33 $ - Version: $Revision: 1.12 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -35,7 +35,7 @@ public: virtual ~gdcmSeqEntry(); virtual void Print(std::ostream &os = std::cout); - virtual void Write(FILE *fp,FileType filetype); + virtual void Write(FILE *fp, FileType); /// \brief returns the SQITEM chained List for this SeQuence. inline ListSQItem &GetSQItems() { return items; } diff --git a/src/gdcmValEntry.cxx b/src/gdcmValEntry.cxx index b5575cfe..c0082d83 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/22 14:37:04 $ - Version: $Revision: 1.12 $ + Date: $Date: 2004/06/23 13:02:36 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -69,24 +69,22 @@ gdcmValEntry::~gdcmValEntry (void) */ void gdcmValEntry::Print(std::ostream & os) { + guint16 g = GetGroup(); + guint16 e = GetElement(); + std::string vr = GetVR(); std::ostringstream s; - unsigned short int g, e; char st[20]; TSKey v; - std::string d2, vr; + std::string d2; - PrintCommonPart(os); + gdcmDocEntry::Print(os); - g = GetGroup(); - - if (g == 0xfffe) { - s << std::endl; - os << s.str(); - return; // just to avoid identing all the remaining code + if (g == 0xfffe) + { + // just to avoid identing all the remaining code + return; } - e = GetElement(); - vr = GetVR(); gdcmTS * ts = gdcmGlobal::GetTS(); v = GetValue(); // not applicable for SQ ... @@ -117,7 +115,8 @@ void gdcmValEntry::Print(std::ostream & os) } } //if (e == 0x0000) { // elem 0x0000 --> group length - if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) { + if ( (vr == "UL") || (vr == "US") || (vr == "SL") || (vr == "SS") ) + { if (v == "4294967295") // to avoid troubles in convertion sprintf (st," x(ffffffff)"); else { @@ -128,51 +127,51 @@ void gdcmValEntry::Print(std::ostream & os) } s << st; } - - s << std::endl; - os << s.str(); + os << s.str(); } - /* * \brief canonical Writer */ -void gdcmValEntry::Write(FILE *fp) { - std::string vr=GetVR(); - int lgr=GetLength(); - if (vr == "US" || vr == "SS") { - // some 'Short integer' fields may be mulivaluated - // each single value is separated from the next one by '\' - // 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 (GetValue(), tokens, "\\"); - for (unsigned int i=0; i tokens; + tokens.erase(tokens.begin(),tokens.end()); // clean any previous value + Tokenize (GetValue(), tokens, "\\"); + for (unsigned int i=0; i tokens; + tokens.erase(tokens.begin(),tokens.end()); // clean any previous value + Tokenize (GetValue(), tokens, "\\"); + for (unsigned int i=0; i tokens; - tokens.erase(tokens.begin(),tokens.end()); // clean any previous value - Tokenize (GetValue(), tokens, "\\"); - for (unsigned int i=0; i