]> Creatis software - gdcm.git/blobdiff - src/gdcmSeqEntry.cxx
Dealing first with the most frequently used cases should speed up the process.
[gdcm.git] / src / gdcmSeqEntry.cxx
index 815031811b443b9c86dc3c2ad1d7ac1cfb3fc919..850b9858b06fb5c2aba7f28b1730c83258b64c26 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/11 15:22:18 $
-  Version:   $Revision: 1.55 $
+  Date:      $Date: 2005/11/03 08:36:19 $
+  Version:   $Revision: 1.61 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -18,7 +18,6 @@
 
 #include "gdcmSeqEntry.h"
 #include "gdcmSQItem.h"
-#include "gdcmValEntry.h"
 #include "gdcmTS.h"
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
@@ -83,10 +82,11 @@ void SeqEntry::WriteContent(std::ofstream *fp, FileType filetype)
    uint16_t seq_term_gr = 0xfffe;
    uint16_t seq_term_el = 0xe0dd;
    uint32_t seq_term_lg = 0xffffffff;
-
-   //uint16_t item_term_gr = 0xfffe;
-   //uint16_t item_term_el = 0xe00d;
-   
+   // ignore 'Zero length' Sequences
+   if ( GetReadLength() == 0 )
+      return;
+       
    DocEntry::WriteContent(fp, filetype);
    for(ListSQItem::iterator cc  = Items.begin();
                             cc != Items.end();
@@ -117,6 +117,7 @@ void SeqEntry::AddSQItem(SQItem *sqItem, int itemNumber)
 //         Or we can add (or remove) anywhere, and SQItemNumber will be broken
    sqItem->SetSQItemNumber(itemNumber);
    Items.push_back(sqItem);
+   sqItem->Register();
 }
 
 /**
@@ -126,11 +127,11 @@ void SeqEntry::ClearSQItem()
 {
    for(ListSQItem::iterator cc = Items.begin(); cc != Items.end(); ++cc)
    {
-      delete *cc;
+      (*cc)->Unregister();
    }
    if (SeqTerm)
    {
-      delete SeqTerm;
+      SeqTerm->Unregister();
    }
 }
 
@@ -196,6 +197,22 @@ unsigned int SeqEntry::GetNumberOfSQItems()
    return Items.size();
 }
 
+/**
+ * \brief Sets the Sequence Delimitation Item
+ * \param e Delimitation item
+ */
+void SeqEntry::SetDelimitationItem(DocEntry *e)
+{
+   if( SeqTerm != e )
+   {
+      if( SeqTerm )
+         SeqTerm->Unregister();
+      SeqTerm = e;
+      if( SeqTerm )
+         SeqTerm->Register();
+   }
+}
+
 //-----------------------------------------------------------------------------
 // Protected
 
@@ -228,10 +245,12 @@ void SeqEntry::Print( std::ostream &os, std::string const & )
    // at end, print the sequence terminator item, if any
    if (DelimitorMode)
    {
-      for ( int i = 0; i < SQDepthLevel; i++ )
-      {
+      int i;
+      for ( i = 0; i < SQDepthLevel; i++ )
+         os << "   | " ;
+      os << " --- "  << std::endl;
+      for ( i = 0; i < SQDepthLevel; i++ )
          os << "   | " ;
-      }
       if (SeqTerm != NULL)
       {
          SeqTerm->SetPrintLevel(PrintLevel);