1 /*=========================================================================
4 Module: $RCSfile: PrintDicomDir.cxx,v $
6 Date: $Date: 2005/01/18 07:55:16 $
7 Version: $Revision: 1.16 $
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
74 pa = e1->GetFirstEntry();
77 std::cout<<" DicomDir '"<<fileName
78 <<" has no patient"<<std::endl
79 <<" ...Failed"<<std::endl;
85 // Structure use Examples
90 std::cout << std::endl << std::endl
91 << " = PATIENT List =========================================="
92 << std::endl<< std::endl;
94 pa = e1->GetFirstEntry();
97 std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
98 pa = e1->GetNextEntry();
103 std::cout << std::endl << std::endl
104 << " = PATIENT/STUDY List ======================================="
105 << std::endl<< std::endl;
107 pa = e1->GetFirstEntry();
108 while ( pa ) // on degouline les PATIENT de ce DICOMDIR
110 std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
111 st = pa->GetFirstEntry();
112 while ( st ) { // on degouline les STUDY de ce patient
113 std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
114 st = pa->GetNextEntry();
116 pa = e1->GetNextEntry();
121 std::cout << std::endl << std::endl
122 << " = PATIENT/STUDY/SERIE List =================================="
123 << std::endl<< std::endl;
125 pa = e1->GetFirstEntry();
126 while ( pa ) // on degouline les PATIENT de ce DICOMDIR
128 // Patient's Name, Patient ID
129 std::cout << "Pat.Name:[" << pa->GetEntry(0x0010, 0x0010) <<"]"; // Patient's Name
130 std::cout << " Pat.ID:[";
131 std::cout << pa->GetEntry(0x0010, 0x0020) << "]" << std::endl; // Patient ID
132 st = pa->GetFirstEntry();
133 while ( st ) { // on degouline les STUDY de ce patient
134 std::cout << "--- Stud.descr:[" << st->GetEntry(0x0008, 0x1030) << "]";// Study Description
135 std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID
136 std::cout << "]" << std::endl;
137 se = st->GetFirstEntry();
138 while ( se ) { // on degouline les SERIES de cette study
139 std::cout << "--- --- Ser.Descr:["<< se->GetEntry(0x0008, 0x103e)<< "]"; // Series Description
140 std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number
141 std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality
142 std::cout << std::endl;
143 se = st->GetNextEntry();
145 st = pa->GetNextEntry();
147 pa = e1->GetNextEntry();
152 std::cout << std::endl << std::endl
153 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
154 << std::endl<< std::endl;
156 pa = e1->GetFirstEntry();
157 while ( pa ) { // les PATIENT de ce DICOMDIR
158 std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
159 st = pa->GetFirstEntry();
160 while ( st ) { // on degouline les STUDY de ce patient
161 std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
162 std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID
163 se = st->GetFirstEntry();
164 while ( se ) { // on degouline les SERIES de cette study
165 std::cout << "--- --- "<< se->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
166 std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number
167 std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality
168 im = se->GetFirstEntry();
169 while ( im ) { // on degouline les Images de cette serie
170 std::cout << "--- --- --- "<< im->GetEntry(0x0004, 0x1500) << std::endl; // File name
171 im = se->GetNextEntry();
173 se = st->GetNextEntry();
175 st = pa->GetNextEntry();
177 pa = e1->GetNextEntry();
182 std::cout << std::endl << std::endl
183 << " = DICOMDIR full content =========================================="
184 << std::endl<< std::endl;
193 // Kept as an example. Please don't remove
195 gdcm::ListDicomDirPatient::const_iterator itPatient;
196 gdcm::ListDicomDirStudy::const_iterator itStudy;
197 gdcm::ListDicomDirSerie::const_iterator itSerie;
198 gdcm::ListDicomDirImage::const_iterator itImage;
199 cout << std::endl << std::endl
200 << " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
201 << std::endl<< std::endl;
203 itPatient = e1->GetDicomDirPatients().begin();
204 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline les PATIENT de ce DICOMDIR
205 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
206 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
207 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
208 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
209 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
210 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
211 std::cout << "--- --- "<< (*itSerie)->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
212 itImage = ((*itSerie)->GetDicomDirImages()).begin();
213 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les IMAGES de cette serie
214 std::cout << "--- --- --- "<< (*itImage)->GetEntry(0x0004, 0x1500) << std::endl; // File name
227 std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
229 std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
230 std::cout<<std::flush;