3 #include "gdcmHeaderEntry.h"
4 #include "gdcmDicomDir.h"
7 #ifdef GDCM_NO_ANSI_STRING_STREAM
9 # define ostringstream ostrstream
16 #define ostringstream ostrstream
20 int testDicomDir(int argc, char* argv[])
23 ListTag::iterator deb , fin;
25 ListDicomDirPatient::iterator itPatient;
26 ListDicomDirStudy::iterator itStudy;
27 ListDicomDirSerie::iterator itSerie;
28 ListDicomDirImage::iterator itImage;
35 file += GDCM_DATA_ROOT;
39 e1 = new gdcmDicomDir(file.c_str());
41 int level = atoi(argv[2]);
42 e1->SetPrintLevel(level);
45 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
47 std::cout<<"Empty list"<<std::endl;
51 // Simple examples of structure exploitation
52 // DON'T REMOVE neither the folowing code, nor the commented out lines
55 cout << std::endl << std::endl
56 << " = Liste des PATIENT =========================================="
57 << std::endl<< std::endl;
60 itPatient = e1->GetDicomDirPatients().begin();
61 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
62 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
68 cout << std::endl << std::endl
69 << " = Liste des PATIENT/STUDY =========================================="
70 << std::endl<< std::endl;
72 itPatient = e1->GetDicomDirPatients().begin();
73 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
74 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
75 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
76 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
77 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
84 std::cout << std::endl << std::endl
85 << " = Liste des PATIENT/STUDY/SERIE =========================================="
86 << std::endl<< std::endl;
88 itPatient = e1->GetDicomDirPatients().begin();
89 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
90 // Patient's Name, Patient ID
91 std::cout << "Pat.Name:[" << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) <<"]";
92 std::cout << " Pat.ID:[";
93 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0020) << "]" << std::endl;
94 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
95 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
96 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << "]";// Study Description
97 std::cout << " Stud.ID:["<< (*itStudy)->GetEntryByNumber(0x0020, 0x0010); // Study ID
98 std::cout << "]" << std::endl;
99 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
100 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
101 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e)<< "]";// Serie Description
102 std::cout << " Ser.nb:[" << (*itSerie)->GetEntryByNumber(0x0020, 0x0011); // Serie number
103 std::cout << "] Mod.:[" << (*itSerie)->GetEntryByNumber(0x0008, 0x0060) << "]"; // Modality
104 std::cout << std::endl;
114 cout << std::endl << std::endl
115 << " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
116 << std::endl<< std::endl;
118 itPatient = e1->GetDicomDirPatients().begin();
119 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
120 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
121 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
122 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
123 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
124 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
125 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
126 std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
127 itImage = ((*itSerie)->GetDicomDirImages()).begin();
128 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
129 std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
140 std::cout << std::endl << std::endl
141 << " = Contenu Complet du DICOMDIR =========================================="
142 << std::endl<< std::endl;
145 std::cout<<std::flush;