2 #include "gdcmDocEntry.h"
3 #include "gdcmDicomDir.h"
8 int TestDicomDir(int argc, char* argv[])
12 gdcm::ListDicomDirPatient::iterator itPatient;
13 gdcm::ListDicomDirStudy::iterator itStudy;
14 gdcm::ListDicomDirSerie::iterator itSerie;
15 gdcm::ListDicomDirImage::iterator itImage;
22 file += GDCM_DATA_ROOT;
26 e1 = new gdcm::DicomDir(file);
28 int level = atoi(argv[2]);
29 e1->SetPrintLevel(level);
32 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
34 std::cout<<"Empty list"<<std::endl;
38 // Simple examples of structure exploitation
39 // DON'T REMOVE neither the following code, nor the commented out lines
42 cout << std::endl << std::endl
43 << " = Liste des PATIENT =========================================="
44 << std::endl<< std::endl;
47 itPatient = e1->GetDicomDirPatients().begin();
48 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
49 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
55 cout << std::endl << std::endl
56 << " = Liste des PATIENT/STUDY =========================================="
57 << std::endl<< std::endl;
59 itPatient = e1->GetDicomDirPatients().begin();
60 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
61 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
62 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
63 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
64 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
71 std::cout << std::endl << std::endl
72 << " = Liste des PATIENT/STUDY/SERIE =========================================="
73 << std::endl<< std::endl;
75 itPatient = e1->GetDicomDirPatients().begin();
76 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
77 // Patient's Name, Patient ID
78 std::cout << "Pat.Name:[" << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) <<"]";
79 std::cout << " Pat.ID:[";
80 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0020) << "]" << std::endl;
81 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
82 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
83 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << "]";// Study Description
84 std::cout << " Stud.ID:["<< (*itStudy)->GetEntryByNumber(0x0020, 0x0010); // Study ID
85 std::cout << "]" << std::endl;
86 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
87 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
88 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e)<< "]";// Serie Description
89 std::cout << " Ser.nb:[" << (*itSerie)->GetEntryByNumber(0x0020, 0x0011); // Serie number
90 std::cout << "] Mod.:[" << (*itSerie)->GetEntryByNumber(0x0008, 0x0060) << "]"; // Modality
91 std::cout << std::endl;
101 cout << std::endl << std::endl
102 << " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
103 << std::endl<< std::endl;
105 itPatient = e1->GetDicomDirPatients().begin();
106 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
107 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
108 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
109 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
110 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
111 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
112 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
113 std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
114 itImage = ((*itSerie)->GetDicomDirImages()).begin();
115 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
116 std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
127 std::cout << std::endl << std::endl
128 << " = Contenu Complet du DICOMDIR =========================================="
129 << std::endl<< std::endl;
132 std::cout<<std::flush;