From: jpr Date: Wed, 19 Jan 2005 15:24:28 +0000 (+0000) Subject: Fix bug on DicomDir utilities X-Git-Tag: Version1.0.bp~245 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ed0cb816b9fbe45a5dfead3f7d95194e0cbbd3a4;p=gdcm.git Fix bug on DicomDir utilities --- diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index cc41e96d..ebbbfde8 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/01/19 08:57:14 $ - Version: $Revision: 1.106 $ + Date: $Date: 2005/01/19 15:24:28 $ + Version: $Revision: 1.107 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -952,7 +952,8 @@ void DicomDir::MoveSQItem(SQItem *dst,SQItem *src) { src->RemoveEntryNoDestroy(entry); dst->AddEntry(entry); - entry = src->GetNextEntry(); + // we destroyed -> the current iterator is not longer valid + entry = src->GetFirstEntry(); } } diff --git a/src/gdcmElementSet.cxx b/src/gdcmElementSet.cxx index 8f81f255..44044e4f 100644 --- a/src/gdcmElementSet.cxx +++ b/src/gdcmElementSet.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmElementSet.cxx,v $ Language: C++ - Date: $Date: 2005/01/18 14:28:32 $ - Version: $Revision: 1.45 $ + Date: $Date: 2005/01/19 15:24:28 $ + Version: $Revision: 1.46 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -69,9 +69,8 @@ void ElementSet::Print(std::ostream &os, std::string const & ) entry->SetPrintLevel(PrintLevel); entry->Print(os); - if ( /*SeqEntry *seqEntry = */dynamic_cast(entry) ) + if ( dynamic_cast(entry) ) { - //(void)seqEntry; // Avoid the newline for a sequence: continue; } diff --git a/src/gdcmSQItem.cxx b/src/gdcmSQItem.cxx index 6a3ea461..e82ad45d 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/01/19 08:55:09 $ - Version: $Revision: 1.54 $ + Date: $Date: 2005/01/19 15:24:28 $ + Version: $Revision: 1.55 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -221,7 +221,7 @@ bool SQItem::SetEntry(std::string const &val, uint16_t group, } /** - * \brief Clear the hash table from given entry AND delete the entry. + * \brief Clear the std::list from given entry AND delete the entry. * @param entryToRemove Entry to remove AND delete. * \warning Some problems when using under Windows... prefer the use of * Initialize / GetNext methods @@ -236,17 +236,17 @@ bool SQItem::RemoveEntry( DocEntry* entryToRemove) if( *it == entryToRemove) { DocEntries.erase(it); - gdcmVerboseMacro( "One element erased."); + gdcmVerboseMacro( "One element erased: " << entryToRemove->GetKey() ); delete entryToRemove; return true; } } - gdcmVerboseMacro( "Value not present."); + gdcmVerboseMacro( "Entry not found: " << entryToRemove->GetKey() ); return false ; } /** - * \brief Clear the hash table from given entry BUT keep the entry. + * \brief Clear the std::list from given entry BUT keep the entry. * @param entryToRemove Entry to remove. * @return true if the entry was found and removed; false otherwise */ @@ -259,12 +259,13 @@ bool SQItem::RemoveEntryNoDestroy(DocEntry* entryToRemove) if( *it == entryToRemove) { DocEntries.erase(it); - gdcmVerboseMacro( "One element erased."); + gdcmVerboseMacro( "One element erased, no destroyed: " + << entryToRemove->GetKey() ); return true; } } - gdcmVerboseMacro( "Value not present."); + gdcmVerboseMacro( "Entry not found:" << entryToRemove->GetKey() ); return false ; } @@ -286,7 +287,7 @@ DocEntry * SQItem::GetFirstEntry() */ DocEntry *SQItem::GetNextEntry() { - gdcmAssertMacro (ItDocEntries != DocEntries.end()); + // gdcmAssertMacro (ItDocEntries != DocEntries.end()); { ++ItDocEntries; if (ItDocEntries != DocEntries.end()) @@ -371,13 +372,27 @@ SeqEntry* SQItem::GetSeqEntry(uint16_t group, uint16_t elem) std::string SQItem::GetEntry(uint16_t group, uint16_t elem) { + +/* + DocEntry *e = GetFirstEntry(); + while (e) + { + if ( e->GetGroup() == group && e->GetElement() == elem) + { + + if (ValEntry *ve = dynamic_cast(e)) + return ve->GetValue(); + } + e = GetNextEntry(); + } +*/ for(ListDocEntry::iterator i = DocEntries.begin(); i != DocEntries.end(); ++i) { if ( (*i)->GetGroup() == group && (*i)->GetElement() == elem) { - if (ValEntry *e = dynamic_cast(*i)) - return e->GetValue(); + if (ValEntry *ve = dynamic_cast(*i)) + return ve->GetValue(); } } return GDCM_UNFOUND;