X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmSQItem.cxx;h=d34f7a9d640f622dd96e8f83d9783bea1d54ac7b;hb=dd0927eaa7e990832c45a1256f85de6148f35b93;hp=709456b363566e60feb1d23080c75ebc176bcebb;hpb=b1520ca5b7b3665aa40c14b63169bfab92eece55;p=gdcm.git diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 709456b3..d34f7a9d 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/22 13:47:33 $ - Version: $Revision: 1.11 $ + Date: $Date: 2004/07/17 22:47:01 $ + 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 @@ -59,52 +59,61 @@ 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) ) + { + (void)SeqEntry; //not used + 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,filetype); - return; - } - if (gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(Entry) ) { - ValEntry->Write(fp,filetype); - return; - } - if (gdcmSeqEntry* SeqEntry = dynamic_cast< gdcmSeqEntry* >(Entry) ) { - SeqEntry->Write(fp,filetype); - return; - } + // Item Delimitor Item IS the last one of a 'no length' SQItem + // (when it exists) we don't write it right now + // It will be written outside, because ALL the SQItems are written + // as 'no length' + if ( (*i)->isItemDelimitor() ) + break; + + // Fix in order to make some MR PHILIPS images e-film readable + // see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm: + // we just *always* ignore spurious fffe|0000 tag ! + if ( ((*i)->GetGroup() == 0xfffe) && ((*i)->GetElement() == 0x0000) ) + break; + + // It's up to the gdcmDocEntry Writter to write the SQItem begin element + // (fffe|e000) as a 'no length' one + (*i)->Write(fp, filetype); } } - //----------------------------------------------------------------------------- // Public /** @@ -130,8 +139,8 @@ bool gdcmSQItem::AddEntry(gdcmDocEntry *entry) * @return true if element was found or created successfully */ -bool gdcmSQItem::SetEntryByNumber(std::string val,guint16 group, - guint16 element) +bool gdcmSQItem::SetEntryByNumber(std::string val,uint16_t group, + uint16_t element) { for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) { @@ -144,8 +153,8 @@ bool gdcmSQItem::SetEntryByNumber(std::string val,guint16 group, // instead of ReplaceOrCreateByNumber // that is a method of gdcmDocument :-( gdcmValEntry* Entry = (gdcmValEntry*)0; - TagKey key = gdcmDictEntry::TranslateToKey(group, element); - + gdcmTagKey key = gdcmDictEntry::TranslateToKey(group, element); + if ( ! ptagHT->count(key)) { // we assume a Public Dictionnary *is* loaded @@ -179,7 +188,7 @@ bool gdcmSQItem::SetEntryByNumber(std::string val,guint16 group, Entry->SetLength(val.length()); docEntries.insert(i,Entry); return true; - } + } if (group == (*i)->GetGroup() && element == (*i)->GetElement() ) { if ( gdcmValEntry* Entry = dynamic_cast(*i) ) @@ -188,6 +197,7 @@ bool gdcmSQItem::SetEntryByNumber(std::string val,guint16 group, return true; } } + return false; } //----------------------------------------------------------------------------- // Protected @@ -197,10 +207,14 @@ bool gdcmSQItem::SetEntryByNumber(std::string val,guint16 group, * \brief Gets a Dicom Element inside a SQ Item Entry, by number * @return */ -gdcmDocEntry *gdcmSQItem::GetDocEntryByNumber(guint16 group, guint16 element) { - for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) { +gdcmDocEntry *gdcmSQItem::GetDocEntryByNumber(uint16_t group, uint16_t element) +{ + for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) + { if ( (*i)->GetGroup()==group && (*i)->GetElement()==element) + { return (*i); + } } return NULL; } @@ -210,9 +224,12 @@ gdcmDocEntry *gdcmSQItem::GetDocEntryByNumber(guint16 group, guint16 element) { * @return */ -std::string gdcmSQItem::GetEntryByNumber(guint16 group, guint16 element) { - for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) { - if ( (*i)->GetGroup()==group && (*i)->GetElement()==element) { +std::string gdcmSQItem::GetEntryByNumber(uint16_t group, uint16_t element) +{ + for(ListDocEntry::iterator i=docEntries.begin();i!=docEntries.end();++i) + { + if ( (*i)->GetGroup()==group && (*i)->GetElement()==element) + { return ((gdcmValEntry *)(*i))->GetValue(); } }