+
+ default:
+ return;
+ }
+ //int count=1; // find a trick to increment
+ //s->AddEntry(si, count); // Seg Faults
+
+}
+
+/**
+ * \brief CallStartMethod
+ */
+void gdcmDicomDir::CallStartMethod()
+{
+ progress = 0.0f;
+ abort = false;
+ if( startMethod )
+ {
+ startMethod( startArg );
+ }
+}
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief CallProgressMethod
+ */
+void gdcmDicomDir::CallProgressMethod()
+{
+ if( progressMethod )
+ {
+ progressMethod( progressArg );
+ }
+}
+
+/**
+ * \ingroup gdcmDicomDir
+ * \brief CallEndMethod
+ */
+void gdcmDicomDir::CallEndMethod()
+{
+ progress = 1.0f;
+ if( endMethod )
+ {
+ endMethod( endArg );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Private
+/**
+ * \ingroup gdcmDicomDir
+ * \brief create a 'gdcmDicomDir' from a DICOMDIR gdcmHeader
+ */
+void gdcmDicomDir::CreateDicomDir()
+{
+ // The list is parsed.
+ // When a DicomDir tag ("PATIENT", "STUDY", "SERIE", "IMAGE") is found :
+ // 1 - we save the beginning iterator
+ // 2 - we continue to parse
+ // 3 - we find an other tag
+ // + we create the object for the precedent tag
+ // + loop to 1 -
+
+ // Directory record sequence
+ gdcmDocEntry *e = GetDocEntryByNumber(0x0004, 0x1220);
+ if ( !e )
+ {
+ dbg.Verbose(0, "gdcmDicomDir::gdcmDicomDir : NO Directory record"
+ " sequence (0x0004,0x1220)");
+ /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ?
+ return;
+ }
+
+ gdcmSeqEntry* s = dynamic_cast<gdcmSeqEntry*>(e);
+ if ( !s )
+ {
+ dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: no SeqEntry present");
+ // useless : (0x0004,0x1220) IS a Sequence !
+ return;
+ }
+
+ gdcmDicomDirType type = gdcmDicomDir::GDCM_DICOMDIR_META;
+ metaElems = NewMeta();
+
+ ListSQItem listItems = s->GetSQItems();
+
+ gdcmDocEntry * d;
+ std::string v;
+ for( ListSQItem::iterator i = listItems.begin();
+ i !=listItems.end(); ++i )
+ {
+ d = (*i)->GetDocEntryByNumber(0x0004, 0x1430); // Directory Record Type
+ if ( gdcmValEntry* ValEntry = dynamic_cast< gdcmValEntry* >(d) )
+ {
+ v = ValEntry->GetValue();
+ }
+ else
+ {
+ dbg.Verbose(0, "gdcmDicomDir::CreateDicomDir: not a ValEntry.");
+ continue;
+ }
+
+ if( v == "PATIENT " )
+ {
+ AddDicomDirPatientToEnd( *i );
+ type = gdcmDicomDir::GDCM_DICOMDIR_PATIENT;
+ }
+ else if( v == "STUDY " )
+ {
+ AddDicomDirStudyToEnd( *i );
+ type = gdcmDicomDir::GDCM_DICOMDIR_STUDY;
+ }
+ else if( v == "SERIES" )
+ {
+ AddDicomDirSerieToEnd( *i );
+ type = gdcmDicomDir::GDCM_DICOMDIR_SERIE;
+ }
+ else if( v == "IMAGE " )
+ {
+ AddDicomDirImageToEnd( *i );
+ type = gdcmDicomDir::GDCM_DICOMDIR_IMAGE;
+ }
+ else
+ {
+ // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
+ // neither an 'IMAGE' SQItem. Skip to next item.
+ continue;
+ }