]> Creatis software - gdcm.git/commitdiff
Fix bug on DicomDir utilities
authorjpr <jpr>
Wed, 19 Jan 2005 15:24:28 +0000 (15:24 +0000)
committerjpr <jpr>
Wed, 19 Jan 2005 15:24:28 +0000 (15:24 +0000)
src/gdcmDicomDir.cxx
src/gdcmElementSet.cxx
src/gdcmSQItem.cxx

index cc41e96dd951fbe7bb27058dcc6448bd4ef11642..ebbbfde8843ba8e7df3db734a7fa51a6de722de7 100644 (file)
@@ -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();
    }
 }
 
index 8f81f255171b9690be8340ec7db9813e298200d9..44044e4f64da07765d8978fea65de7597a1cce73 100644 (file)
@@ -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<SeqEntry*>(entry) )
+      if ( dynamic_cast<SeqEntry*>(entry) )
       {
-         //(void)seqEntry;
          // Avoid the newline for a sequence:
          continue;
       }
index 6a3ea4611dd37e02ff8f7685526d4a5d43c434a2..e82ad45d9175a9a4ddc7cc7f5bbb595394b25468 100644 (file)
@@ -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<ValEntry*>(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<ValEntry*>(*i))
-            return e->GetValue();
+         if (ValEntry *ve = dynamic_cast<ValEntry*>(*i))
+           return ve->GetValue();
       }
    }
    return GDCM_UNFOUND;