+ case GDCM_DICOMDIR_IMAGE:
+ elemList = Global::GetDicomDirElements()->GetDicomDirImageElements();
+ si = DicomDirImage::New(true);
+ if ( !AddImageToEnd(static_cast<DicomDirImage *>(si)) )
+ {
+ si->Delete();
+ gdcmErrorMacro( "Add ImageToEnd failed");
+ }
+ break;
+ case GDCM_DICOMDIR_SERIE:
+ elemList = Global::GetDicomDirElements()->GetDicomDirSerieElements();
+ si = DicomDirSerie::New(true);
+ if ( !AddSerieToEnd(static_cast<DicomDirSerie *>(si)) )
+ {
+ si->Delete();
+ gdcmErrorMacro( "Add SerieToEnd failed");
+ }
+ break;
+ case GDCM_DICOMDIR_STUDY:
+ elemList = Global::GetDicomDirElements()->GetDicomDirStudyElements();
+ si = DicomDirStudy::New(true);
+ if ( !AddStudyToEnd(static_cast<DicomDirStudy *>(si)) )
+ {
+ si->Delete();
+ gdcmErrorMacro( "Add StudyToEnd failed");
+ }
+ break;
+ case GDCM_DICOMDIR_PATIENT:
+ elemList = Global::GetDicomDirElements()->GetDicomDirPatientElements();
+ si = DicomDirPatient::New(true);
+ if ( !AddPatientToEnd(static_cast<DicomDirPatient *>(si)) )
+ {
+ si->Delete();
+ gdcmErrorMacro( "Add PatientToEnd failed");
+ }
+ break;
+ case GDCM_DICOMDIR_META:
+ if ( MetaElems )
+ {
+ MetaElems->Delete();
+ gdcmErrorMacro( "MetaElements already exist, they will be destroyed");
+ }
+ elemList = Global::GetDicomDirElements()->GetDicomDirMetaElements();
+ MetaElems = DicomDirMeta::New(true);
+ si = MetaElems;
+ break;
+ default:
+ return;
+ }
+
+ // FIXME : troubles found when it's a SeqEntry
+
+ // removed all the seems-to-be-useless stuff about Referenced Image Sequence
+ // to avoid further troubles
+ // imageElem 0008 1140 "" // Referenced Image Sequence
+ // imageElem fffe e000 "" // 'no length' item : length to be set to 0xffffffff later
+ // imageElem 0008 1150 "" // Referenced SOP Class UID : to be set/forged later
+ // imageElem 0008 1155 "" // Referenced SOP Instance UID : to be set/forged later
+ // imageElem fffe e00d "" // Item delimitation : length to be set to ZERO later
+
+ std::string referencedVal;
+ // for all the relevant elements found in their own spot of the DicomDir.dic
+ for( it = elemList.begin(); it != elemList.end(); ++it)
+ {
+ tmpGr = it->Group;
+ tmpEl = it->Elem;
+ dictEntry = GetPubDict()->GetEntry(tmpGr, tmpEl);
+
+ entry = DataEntry::New( dictEntry );
+ entry->SetOffset(0); // just to avoid further missprinting
+
+ if ( header )
+ {
+ // NULL when we Build Up (ex nihilo) a DICOMDIR
+ // or when we add the META elems
+
+ val = header->GetEntryString(tmpGr, tmpEl);
+ }
+ else
+ {
+ val = GDCM_UNFOUND;
+ }