- itPatient = e1->GetPatients().begin();
- while ( itPatient != e1->GetPatients().end() ) { // on degouline la liste de PATIENT
- std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
- itStudy = ((*itPatient)->GetStudies()).begin();
- while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient
- std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
- itSerie = ((*itStudy)->GetSeries()).begin();
- while (itSerie != (*itStudy)->GetSeries().end() ) { // on degouline les SERIES de cette study
- std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
- itImage = ((*itSerie)->GetImages()).begin();
- while (itImage != (*itSerie)->GetImages().end() ) { // on degouline les SERIES de cette study
- std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
- ++itImage;
+ GDCM_NAME_SPACE::Debug::DebugOn();
+
+
+ // Write on disc what we read
+ dicomdir->Write("NewDICOMDIR");
+
+ std::cout << std::endl << std::endl
+ << "NewDICOMDIR written on disc ================================="
+ << std::endl<< std::endl;
+ // Read what we wrote
+ GDCM_NAME_SPACE::DicomDir *d2 = GDCM_NAME_SPACE::DicomDir::New();
+ d2->SetFileName("NewDICOMDIR");
+ d2->Load();
+ if (!d2->IsReadable())
+ {
+ std::cout << std::endl << std::endl
+ << "Read NewDicomDir from disc failed ========================"
+ << std::endl<< std::endl;
+ return 1;
+ }
+ std::cout << std::endl << std::endl
+ << "NewDICOMDIR successfully read from disc ================================="
+ << std::endl<< std::endl;
+
+ GDCM_NAME_SPACE::DicomDirPatient *pa2;
+ GDCM_NAME_SPACE::DicomDirStudy *st2;
+ GDCM_NAME_SPACE::DicomDirSerie *se2;
+ GDCM_NAME_SPACE::DicomDirImage *im2;
+
+ pa1 = dicomdir->GetFirstPatient();
+ pa2 = d2->GetFirstPatient();
+
+ if (!d2)
+ {
+ std::cout << "NewDICOMDIR contains no Patient ?!?" << std::endl;
+ dicomdir->Delete();
+ d2->Delete();
+ return 1;
+ }
+
+ while ( pa1 && pa2 )
+ { // we process all the PATIENT of this DICOMDIR
+
+ if ( CompareSQItem(pa2,pa1) == 1 )
+ {
+ dicomdir->Delete();
+ d2->Delete();
+ return 1;
+ }
+
+ // just to allow human reader to be sure ...
+ std::cout << pa2->GetEntryString(0x0010, 0x0010)
+ << std::endl; // Patient's Name
+
+ st1 = pa1->GetFirstStudy();
+ st2 = pa2->GetFirstStudy();
+
+ while ( st1 && st2 )
+ {
+ if ( CompareSQItem(st2,st1) == 1 )
+ {
+ dicomdir->Delete();
+ d2->Delete();
+ return 1;
+ }
+
+ // just to allow human reader to be sure ...
+ std::cout << "--- "<< st2->GetEntryString(0x0008, 0x1030);
+ // << std::endl; // Study Description
+ std::cout << " Stud.ID:["
+ << st2->GetEntryString(0x0020, 0x0010)
+ << "]" << std::endl; // Study ID
+
+ se1 = st1->GetFirstSerie();
+ se2 = st2->GetFirstSerie();
+
+ while ( se1 && se2 )
+ { // we process all the SERIE of this study
+ if ( CompareSQItem(se2,se1) == 1 )
+ return 1;
+
+ std::cout << "--- --- " << se2->GetEntryString(0x0008, 0x103e); // Serie Description
+ std::cout << " Ser.nb:["<< se2->GetEntryString(0x0020, 0x0011); // Series number
+ std::cout << "] Mod.:[" << se2->GetEntryString(0x0008, 0x0060) << "]" << std::endl; // Modality
+ im1 = se1->GetFirstImage();
+ im2 = se2->GetFirstImage();
+
+ while ( im1 && im2 ) // we process all the IMAGE of this serie
+ {
+ if ( CompareSQItem(im2,im1) == 1 )
+ {
+ dicomdir->Delete();
+ d2->Delete();
+ return 1;
+ }
+
+ im1 = se1->GetNextImage();
+ im2 = se2->GetNextImage();