+ void gdcmSQItem::Print(std::ostream & os)
+ {
+ std::ostringstream s;
+
+ if (SQDepthLevel > 0)
+ {
+ for (int i = 0; i < SQDepthLevel; ++i)
+ {
+ s << " | " ;
+ }
+ }
+ std::cout << s.str() << " --- SQItem number " << SQItemNumber << std::endl;
+ for (ListDocEntry::iterator i = docEntries.begin();
+ i != docEntries.end();
+ ++i)
+ {
+ gdcmDocEntry* Entry = *i;
+ bool PrintEndLine = true;
+
+ os << s.str();
+ Entry->SetPrintLevel(2);
+ Entry->Print(os);
+ if ( gdcmSeqEntry* SeqEntry = dynamic_cast<gdcmSeqEntry*>(Entry) )
+ {
+ (void)SeqEntry; //not used
+ PrintEndLine = false;
+ }
+ if (PrintEndLine)
+ {
+ os << std::endl;
+ }
+ }
+}
+
+/*
+ * \ingroup gdcmSQItem
+ * \brief canonical Writer
+ */
+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)
+ {
+ // we skip delimitors (start and end one) because
+ // we force them as 'no length'
+ if ( (*i)->GetGroup() == 0xfffe )
+ {
+ continue;
+ }
+
+ // Fix in order to make some MR PHILIPS images e-film readable
+ // see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
+ // we just *always* ignore spurious fffe|0000 tag !
+ if ( (*i)->GetGroup() == 0xfffe && (*i)->GetElement() == 0x0000 )
+ {
+ break; // FIXME : continue; ?!?
+ }
+
+ (*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
+
+}