1 /*=========================================================================
4 Module: $RCSfile: PrintDicomDir.cxx,v $
6 Date: $Date: 2005/01/17 11:01:55 $
7 Version: $Revision: 1.14 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
18 #include "gdcmDocument.h"
19 #include "gdcmDicomDir.h"
20 #include "gdcmValEntry.h"
21 #include "gdcmDicomDirPatient.h"
22 #include "gdcmDicomDirStudy.h"
23 #include "gdcmDicomDirSerie.h"
24 #include "gdcmDicomDirImage.h"
26 #include "gdcmDebug.h"
31 int main(int argc, char* argv[])
36 gdcm::DicomDirPatient *pa;
37 gdcm::DicomDirStudy *st;
38 gdcm::DicomDirSerie *se;
39 gdcm::DicomDirImage *im;
46 fileName = GDCM_DATA_ROOT;
47 fileName += "/DICOMDIR";
51 gdcm::Debug::SetDebugOn();
53 e1 = new gdcm::DicomDir( fileName );
58 detailLevel = atoi(argv[2]);
62 // Test if the DicomDir is readable
63 if( !e1->IsReadable() )
65 std::cout<<" DicomDir '"<<fileName
66 <<"' is not readable"<<std::endl
67 <<" ...Failed"<<std::endl;
73 // Test if the DicomDir contains any Patient
75 pa = e1->GetNextEntry();
78 std::cout<<" DicomDir '"<<fileName
79 <<" has no patient"<<std::endl
80 <<" ...Failed"<<std::endl;
86 // Structure use Examples
91 std::cout << std::endl << std::endl
92 << " = PATIENT List =========================================="
93 << std::endl<< std::endl;
96 pa = e1->GetNextEntry();
99 std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
100 pa = e1->GetNextEntry();
105 std::cout << std::endl << std::endl
106 << " = PATIENT/STUDY List ======================================="
107 << std::endl<< std::endl;
110 pa = e1->GetNextEntry();
111 while ( pa ) // on degouline la liste de PATIENT
113 std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
115 st = pa->GetNextEntry();
116 while ( st ) { // on degouline les STUDY de ce patient
117 std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
118 st = pa->GetNextEntry();
120 pa = e1->GetNextEntry();
125 std::cout << std::endl << std::endl
126 << " = PATIENT/STUDY/SERIE List =================================="
127 << std::endl<< std::endl;
130 pa = e1->GetNextEntry();
131 while ( pa ) // on degouline la liste de PATIENT
133 // Patient's Name, Patient ID
134 std::cout << "Pat.Name:[" << pa->GetEntry(0x0010, 0x0010) <<"]"; // Patient's Name
135 std::cout << " Pat.ID:[";
136 std::cout << pa->GetEntry(0x0010, 0x0020) << "]" << std::endl; // Patient ID
138 st = pa->GetNextEntry();
139 while ( st ) { // on degouline les STUDY de ce patient
140 std::cout << "--- Stud.descr:[" << st->GetEntry(0x0008, 0x1030) << "]";// Study Description
141 std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID
142 std::cout << "]" << std::endl;
144 se = st->GetNextEntry();
145 while ( se ) { // on degouline les SERIES de cette study
146 std::cout << "--- --- Ser.Descr:["<< se->GetEntry(0x0008, 0x103e)<< "]"; // Series Description
147 std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number
148 std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality
149 std::cout << std::endl;
150 se = st->GetNextEntry();
152 st = pa->GetNextEntry();
154 pa = e1->GetNextEntry();
159 std::cout << std::endl << std::endl
160 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
161 << std::endl<< std::endl;
164 pa = e1->GetNextEntry();
165 while ( pa ) { // on degouline la liste de PATIENT
166 std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
168 st = pa->GetNextEntry();
169 while ( st ) { // on degouline les STUDY de ce patient
170 std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
171 std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID
173 se = st->GetNextEntry();
174 while ( se ) { // on degouline les SERIES de cette study
175 std::cout << "--- --- "<< se->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
176 std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number
177 std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality
179 im = se->GetNextEntry();
180 while ( im ) { // on degouline les Images de cette serie
181 std::cout << "--- --- --- "<< im->GetEntry(0x0004, 0x1500) << std::endl; // File name
182 im = se->GetNextEntry();
184 se = st->GetNextEntry();
186 st = pa->GetNextEntry();
188 pa = e1->GetNextEntry();
193 std::cout << std::endl << std::endl
194 << " = DICOMDIR full content =========================================="
195 << std::endl<< std::endl;
204 // Kept as an example. Please don't remove
206 gdcm::ListDicomDirPatient::const_iterator itPatient;
207 gdcm::ListDicomDirStudy::const_iterator itStudy;
208 gdcm::ListDicomDirSerie::const_iterator itSerie;
209 gdcm::ListDicomDirImage::const_iterator itImage;
210 cout << std::endl << std::endl
211 << " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
212 << std::endl<< std::endl;
214 itPatient = e1->GetDicomDirPatients().begin();
215 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
216 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
217 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
218 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
219 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
220 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
221 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
222 std::cout << "--- --- "<< (*itSerie)->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
223 itImage = ((*itSerie)->GetDicomDirImages()).begin();
224 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les IMAGES de cette serie
225 std::cout << "--- --- --- "<< (*itImage)->GetEntry(0x0004, 0x1500) << std::endl; // File name
238 std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
240 std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
241 std::cout<<std::flush;