+ // dicomdir->Print();
+
+ // ------------------------- second stage ---------------------------
+
+ // Write on disc what we read
+ dicomdir->WriteDicomDir("NewDICOMDIR");
+
+ std::cout << std::endl << std::endl
+ << "NewDICOMDIR written on disc ================================="
+ << std::endl<< std::endl;
+ // Read what we wrote
+ gdcm::DicomDir *d2 = new gdcm::DicomDir("NewDICOMDIR");
+ if (!d2)
+ {
+ 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::DicomDirPatient *pa2;
+ gdcm::DicomDirStudy *st2;
+ gdcm::DicomDirSerie *se2;
+ gdcm::DicomDirImage *im2;
+
+ pa1 = dicomdir->GetFirstPatient();
+ pa2 = d2->GetFirstPatient();
+
+ if (!d2)
+ {
+ std::cout << "NewDICOMDIR contains no Patient ?!?" << std::endl;
+ delete dicomdir;
+ delete d2;
+ return 1;
+ }
+
+ while ( pa1 && pa2 )
+ { // we process all the PATIENT of this DICOMDIR
+
+ if ( CompareSQItem(pa2,pa1) == 1 )
+ {
+ delete dicomdir;
+ delete d2;
+ return 1;
+ }
+
+ // just to allow human reader to be sure ...
+ std::cout << pa2->GetEntryValue(0x0010, 0x0010)
+ << std::endl; // Patient's Name
+
+ st1 = pa1->GetFirstStudy();
+ st2 = pa2->GetFirstStudy();
+
+ while ( st1 && st2 )
+ {
+ if ( CompareSQItem(st2,st1) == 1 )
+ {
+ delete dicomdir;
+ delete d2;
+ return 1;
+ }
+
+ // just to allow human reader to be sure ...
+ std::cout << "--- "<< st2->GetEntryValue(0x0008, 0x1030);
+ // << std::endl; // Study Description
+ std::cout << " Stud.ID:["
+ << st2->GetEntryValue(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->GetEntryValue(0x0008, 0x103e); // Serie Description
+ std::cout << " Ser.nb:["<< se2->GetEntryValue(0x0020, 0x0011); // Series number
+ std::cout << "] Mod.:[" << se2->GetEntryValue(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 )
+ {
+ delete dicomdir;
+ delete d2;
+ return 1;
+ }
+
+ im1 = se1->GetNextImage();
+ im2 = se2->GetNextImage();
+ }
+ se1 = st1->GetNextSerie();
+ se2 = st2->GetNextSerie();
+ }
+ st1 = pa1->GetNextStudy();
+ st2 = pa2->GetNextStudy();
+ }
+ pa1 = dicomdir->GetNextPatient();
+ pa2 = dicomdir->GetNextPatient();
+ }