]> Creatis software - gdcm.git/blobdiff - src/gdcmSQItem.cxx
Some improvements for Write problems
[gdcm.git] / src / gdcmSQItem.cxx
index 7d61d3cce28c878c633614ee0561903aa5fcc2ff..2299b946bc6af54bf7f2047e82c715c85f34ee51 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmSQItem.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/08/26 15:29:53 $
-  Version:   $Revision: 1.24 $
+  Date:      $Date: 2004/08/27 15:48:44 $
+  Version:   $Revision: 1.25 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -97,17 +97,22 @@ gdcmSQItem::~gdcmSQItem()
  */
 void gdcmSQItem::Write(FILE *fp,FileType filetype)
 {
+   uint16_t item[4] = { 0xfffe, 0xe000, 0xffff, 0xffff };
+   uint16_t itemt[4]= { 0xfffe, 0xe00d, 0xffff, 0xffff };
+
+    //we force the writting of an 'Item' Start Element
+    // because we want to write the Item as a 'no Length' item
+   fwrite(&item[0],8,1,fp);  // fffe e000 ffff ffff 
+     
    for (ListDocEntry::iterator i = docEntries.begin();  
         i != docEntries.end();
         ++i)
-   {
-      // Item Delimitor Item IS the last one of a 'no length' SQItem
-      // (when it exists) we don't write it right now
-      // It will be written outside, because ALL the SQItems are written
-      // as 'no length'
-      if ( (*i)->IsItemDelimitor() )
+   {   
+      // we skip delimitors (start and end one) because 
+      // we force them as 'no length'
+      if ( (*i)->GetGroup() == 0xfffe )
       {
-         break;
+         continue;
       }
 
       // Fix in order to make some MR PHILIPS images e-film readable
@@ -115,13 +120,16 @@ void gdcmSQItem::Write(FILE *fp,FileType filetype)
       // we just *always* ignore spurious fffe|0000 tag ! 
       if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0x0000 )
       {
-         break;
+         break; // FIXME : continue; ?!?
       }
 
-      // It's up to the gdcmDocEntry Writter to write the SQItem begin element
-      // (fffe|e000) as a 'no length' one
       (*i)->Write(fp, filetype);
-   } 
+   }
+      
+    //we force the writting of an 'Item Delimitation' item
+    // because we wrote the Item as a 'no Length' item
+   fwrite(&itemt[0],8,1,fp);  // fffe e000 ffff ffff 
+
 }
 
 //-----------------------------------------------------------------------------