+//-----------------------------------------------------------------------------
+/**
+ * \brief CallStartMethod
+ */
+void DicomDir::CallStartMethod()
+{
+ Progress = 0.0f;
+ Abort = false;
+ if( StartMethod )
+ {
+ StartMethod( StartArg );
+ }
+}
+
+//-----------------------------------------------------------------------------
+/**
+ * \ingroup DicomDir
+ * \brief CallProgressMethod
+ */
+void DicomDir::CallProgressMethod()
+{
+ if( ProgressMethod )
+ {
+ ProgressMethod( ProgressArg );
+ }
+}
+
+//-----------------------------------------------------------------------------
+/**
+ * \ingroup DicomDir
+ * \brief CallEndMethod
+ */
+void DicomDir::CallEndMethod()
+{
+ Progress = 1.0f;
+ if( EndMethod )
+ {
+ EndMethod( EndArg );
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Private
+/**
+ * \ingroup DicomDir
+ * \brief create a 'DicomDir' from a DICOMDIR Header
+ */
+void DicomDir::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
+ DocEntry *e = GetDocEntry(0x0004, 0x1220);
+ if ( !e )
+ {
+ gdcmVerboseMacro( "NO Directory record sequence (0x0004,0x1220)");
+ /// \todo FIXME: what to do when the parsed file IS NOT a DICOMDIR file ?
+ return;
+ }
+
+ SeqEntry *s = dynamic_cast<SeqEntry *>(e);
+ if ( !s )
+ {
+ gdcmVerboseMacro( "No SeqEntry present");
+ // useless : (0x0004,0x1220) IS a Sequence !
+ return;
+ }
+
+ MetaElems = NewMeta();
+
+ ListSQItem listItems = s->GetSQItems();
+
+ DocEntry *d;
+ std::string v;
+ SQItem *si;
+ for( ListSQItem::iterator i = listItems.begin();
+ i !=listItems.end(); ++i )
+ {
+ d = (*i)->GetDocEntry(0x0004, 0x1430); // Directory Record Type
+ if ( ValEntry* valEntry = dynamic_cast<ValEntry *>(d) )
+ {
+ v = valEntry->GetValue();
+ }
+ else
+ {
+ gdcmVerboseMacro( "Not a ValEntry.");
+ continue;
+ }
+
+ if( v == "PATIENT " )
+ {
+ si = new DicomDirPatient();
+ AddDicomDirPatientToEnd( static_cast<DicomDirPatient *>(si) );
+ }
+ else if( v == "STUDY " )
+ {
+ si = new DicomDirStudy();
+ AddDicomDirStudyToEnd( static_cast<DicomDirStudy *>(si) );
+ }
+ else if( v == "SERIES" )
+ {
+ si = new DicomDirSerie();
+ AddDicomDirSerieToEnd( static_cast<DicomDirSerie *>(si) );
+ }
+ else if( v == "IMAGE " )
+ {
+ si = new DicomDirImage();
+ AddDicomDirImageToEnd( static_cast<DicomDirImage *>(si) );
+ }
+ else
+ {
+ // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
+ // neither an 'IMAGE' SQItem. Skip to next item.
+ continue;
+ }
+ MoveSQItem(si,*i);
+ }
+ TagHT.clear();
+}