]> Creatis software - gdcm.git/blobdiff - src/gdcmSeqEntry.cxx
* src/gdcmFile.[h|cxx] : add the Print method
[gdcm.git] / src / gdcmSeqEntry.cxx
index bb5135594c4b8713fe6ba08cc7d086bfaadb274f..f7669d3660d15a1b71542719fa90724704c1ac7e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSeqEntry.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/10/22 03:05:42 $
-  Version:   $Revision: 1.32 $
+  Date:      $Date: 2004/12/02 15:14:18 $
+  Version:   $Revision: 1.39 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -42,8 +42,8 @@ SeqEntry::SeqEntry( DictEntry* e )
    ReadLength = 0xffffffff;
    SQDepthLevel = -1;
 
-   delimitor_mode = false;
-   seq_term  = NULL;
+   DelimitorMode = false;
+   SeqTerm  = NULL;
 }
 
 /**
@@ -54,24 +54,28 @@ SeqEntry::SeqEntry( DictEntry* e )
 SeqEntry::SeqEntry( DocEntry* e, int depth )
              : DocEntry( e->GetDictEntry() )
 {
-   this->UsableLength = 0;
-   this->ReadLength   = 0xffffffff;
+   UsableLength = 0;
+   ReadLength   = 0xffffffff;
    SQDepthLevel = depth;
 
-   this->ImplicitVR   = e->IsImplicitVR();
-   this->Offset       = e->GetOffset();
+   ImplicitVR   = e->IsImplicitVR();
+   Offset       = e->GetOffset();
+   SeqTerm = NULL;
 }
 
 /**
  * \brief   Canonical destructor.
  */
-SeqEntry::~SeqEntry() {
-   for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
+SeqEntry::~SeqEntry()
+{
+   for(ListSQItem::iterator cc = Items.begin(); cc != Items.end(); ++cc)
    {
       delete *cc;
    }
-   if (!seq_term)
-      delete seq_term;
+   if (SeqTerm)
+   {
+      delete SeqTerm;
+   }
 }
 
 /**
@@ -81,6 +85,8 @@ void SeqEntry::Print( std::ostream &os )
 {
    // First, Print the Dicom Element itself.
    SetPrintLevel(2);   
+
+   os << "S ";
    DocEntry::Print(os);
    os << std::endl;
 
@@ -88,20 +94,21 @@ void SeqEntry::Print( std::ostream &os )
       return;
 
    // Then, Print each SQ Item   
-   for(ListSQItem::iterator cc = items.begin();cc != items.end();++cc)
+   for(ListSQItem::iterator cc = Items.begin(); cc != Items.end(); ++cc)
    {
       (*cc)->Print(os);   
    }
 
    // at end, print the sequence terminator item, if any
-   if (delimitor_mode) {
+   if (DelimitorMode)
+   {
       for ( int i = 0; i < SQDepthLevel; i++ )
       {
          os << "   | " ;
       }
-      if (seq_term != NULL)
+      if (SeqTerm != NULL)
       {
-         seq_term->Print(os);
+         SeqTerm->Print(os);
          os << std::endl;
       } 
       else 
@@ -115,7 +122,7 @@ void SeqEntry::Print( std::ostream &os )
 /*
  * \brief   canonical Writer
  */
-void SeqEntry::Write(std::ofstream* fp, FileType filetype)
+void SeqEntry::WriteContent(std::ofstream* fp, FileType filetype)
 {
    uint16_t seq_term_gr = 0xfffe;
    uint16_t seq_term_el = 0xe0dd;
@@ -124,19 +131,19 @@ void SeqEntry::Write(std::ofstream* fp, FileType filetype)
    //uint16_t item_term_gr = 0xfffe;
    //uint16_t item_term_el = 0xe00d;
    
-   DocEntry::Write(fp, filetype);
-   for(ListSQItem::iterator cc  = GetSQItems().begin();
-                            cc != GetSQItems().end();
+   DocEntry::WriteContent(fp, filetype);
+   for(ListSQItem::iterator cc  = Items.begin();
+                            cc != Items.end();
                           ++cc)
    {        
-      (*cc)->Write(fp, filetype);
+      (*cc)->WriteContent(fp, filetype);
    }
    
    // we force the writting of a Sequence Delimitation item
    // because we wrote the Sequence as a 'no Length' sequence
-   fp->write ( (char*)&seq_term_gr,(size_t)2 );
-   fp->write ( (char*)&seq_term_el,(size_t)2 );
-   fp->write ( (char*)&seq_term_lg,(size_t)4 );
+   binary_write(*fp, seq_term_gr);
+   binary_write(*fp, seq_term_el);
+   binary_write(*fp, seq_term_lg);
 }
 
 //-----------------------------------------------------------------------------
@@ -146,7 +153,7 @@ void SeqEntry::Write(std::ofstream* fp, FileType filetype)
 void SeqEntry::AddEntry(SQItem *sqItem, int itemNumber)
 {
    sqItem->SetSQItemNumber(itemNumber);
-   items.push_back(sqItem);
+   Items.push_back(sqItem);
 }
 
 /**
@@ -158,15 +165,20 @@ void SeqEntry::AddEntry(SQItem *sqItem, int itemNumber)
 SQItem* SeqEntry::GetSQItemByOrdinalNumber(int nb)
 {
    if (nb<0)
-      return (*(items.begin()));
+   {
+      return *(Items.begin());
+   }
    int count = 0 ;
-   for(ListSQItem::iterator cc = items.begin();
-       cc != items.end();
-       count ++, ++cc){
-      if (count==nb)
+   for(ListSQItem::iterator cc = Items.begin();
+                           cc != Items.end();
+                           count ++, ++cc)
+   {
+      if (count == nb)
+      {
          return *cc;
+      }
    }
-   return (*(items.end())); // Euhhhhh ?!? Is this the last one . FIXME
+   return *(Items.end()); // Euhhhhh ?!? Is this the last one . FIXME
 }
 //-----------------------------------------------------------------------------
 // Protected