]> Creatis software - gdcm.git/blobdiff - src/gdcmSQItem.cxx
* bug fix in the Python demos, due to the recent changes
[gdcm.git] / src / gdcmSQItem.cxx
index c4af8e33be42709c3053d26ac523e548161f133c..0ed62981aeec4deb87fe99b01256ed36350abb12 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/04 23:49:23 $
-  Version:   $Revision: 1.68 $
+  Date:      $Date: 2005/10/18 08:35:50 $
+  Version:   $Revision: 1.76 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,8 +18,6 @@
 
 #include "gdcmSQItem.h"
 #include "gdcmSeqEntry.h"
-#include "gdcmValEntry.h"
-#include "gdcmBinEntry.h"
 #include "gdcmGlobal.h"
 #include "gdcmDictSet.h"
 #include "gdcmUtil.h"
@@ -85,7 +83,9 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
       // we just *always* ignore spurious fffe|0000 tag ! 
       if ( (*it)->GetGroup() == 0xfffe && (*it)->GetElement() == 0x0000 )
       {
-         break; // FIXME : continue; ?!?
+          break; // FIXME : break or continue; ?!?  
+                 // --> makes no difference since the only bugged file we have
+                 // contains 'impossible tag' fffe|0000 in last position !                            
       }
 
       (*it)->WriteContent(fp, filetype);
@@ -103,6 +103,7 @@ void SQItem::WriteContent(std::ofstream *fp, FileType filetype)
  * \brief   Inserts *in the right place* any Entry (Dicom Element)
  *          into the Sequence Item
  * @param entry Entry to add
+ * @return always true 
  */
 bool SQItem::AddEntry(DocEntry *entry)
 {   
@@ -147,15 +148,15 @@ bool SQItem::RemoveEntry( DocEntry *entryToRemove )
                               it != DocEntries.end();
                             ++it)
    {
-      if( *it == entryToRemove )
+      if ( *it == entryToRemove )
       {
          DocEntries.erase(it);
-         gdcmVerboseMacro( "One element erased: " << entryToRemove->GetKey() );
+         gdcmWarningMacro( "One element erased: " << entryToRemove->GetKey() );
          delete entryToRemove;
          return true;
       }
    }
-   gdcmVerboseMacro( "Entry not found: " << entryToRemove->GetKey() );
+   gdcmWarningMacro( "Entry not found: " << entryToRemove->GetKey() );
    return false ;
 }
 
@@ -170,16 +171,16 @@ bool SQItem::RemoveEntryNoDestroy(DocEntry *entryToRemove)
                               it != DocEntries.end();
                             ++it)
    {
-      if( *it == entryToRemove )
+      if ( *it == entryToRemove )
       {
          DocEntries.erase(it);
-         gdcmVerboseMacro( "One element erased, no destroyed: "
+         gdcmWarningMacro( "One element removed, no destroyed: "
                             << entryToRemove->GetKey() );
          return true;
       }
    }
                                                                                 
-   gdcmVerboseMacro( "Entry not found:" << entryToRemove->GetKey() );
+   gdcmWarningMacro( "Entry not found:" << entryToRemove->GetKey() );
    return false ;
 }
                                                                                 
@@ -197,6 +198,24 @@ void SQItem::ClearEntry()
    DocEntries.clear();
 }
 
+/**
+ * \brief  Clear the std::list from given Sequence Item  BUT keep the entries
+ */
+void SQItem::ClearEntryNoDestroy()
+{
+   DocEntries.clear();
+}
+
+
+/**
+ * \brief  Move all the entries from a given Sequence Item 
+ */
+void SQItem::MoveObject(SQItem *source)
+{
+   DocEntries = source->DocEntries;
+   source->ClearEntryNoDestroy();
+}
+
 /**
  * \brief   Get the first Dicom entry while visiting the SQItem
  * \return  The first DocEntry if found, otherwhise 0
@@ -204,7 +223,7 @@ void SQItem::ClearEntry()
 DocEntry *SQItem::GetFirstEntry()
 {
    ItDocEntries = DocEntries.begin();
-   if( ItDocEntries != DocEntries.end() )
+   if ( ItDocEntries != DocEntries.end() )
       return *ItDocEntries;
    return 0;   
 }
@@ -216,47 +235,11 @@ DocEntry *SQItem::GetFirstEntry()
 DocEntry *SQItem::GetNextEntry()
 {
    ++ItDocEntries;
-   if( ItDocEntries != DocEntries.end() )
+   if ( ItDocEntries != DocEntries.end() )
       return  *ItDocEntries;
    return NULL;
 }
 
-/**
- * \brief   Get the first ValEntry while visiting theSQItem
- *              This method is designed for Python users
- * \return  The first ValEntry if found, otherwhise NULL
- */
-ValEntry *SQItem::GetFirstValEntry()
-{
-   gdcm::ValEntry *valEntry;
-   gdcm::DocEntry *d = GetFirstEntry();
-   // an other iterator is needed to allow user iterate 
-   // at the same time both on DocEntries and ValEntries 
-   ItValEntries = ItDocEntries;
-   if ( (valEntry = dynamic_cast<gdcm::ValEntry*>(d)))
-      return valEntry;
-   return  GetNextValEntry();
-}
-                                                                                
-/**
- * \brief   Get the next ValEntry while visiting the SQItem
- * \return  The next ValEntry if found, otherwhise NULL
- */
-ValEntry *SQItem::GetNextValEntry()
-{
-   gdcm::ValEntry *valEntry;
-   gdcm::DocEntry *d = *ItValEntries;
-   ++ItValEntries; 
-   while( d )
-   {
-      if ( (valEntry = dynamic_cast<gdcm::ValEntry*>(d)))
-         return valEntry;
-      else
-     return GetNextValEntry(); 
-   }
-   return 0;
-}
-
 /**
  * \brief   Gets a Dicom Element inside a SQ Item Entry
  * @param   group   Group number of the Entry