1 /*=========================================================================
4 Module: $RCSfile: PrintDicomDir.cxx,v $
6 Date: $Date: 2005/01/13 14:20:18 $
7 Version: $Revision: 1.12 $
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[])
35 gdcm::ListDicomDirPatient::const_iterator itPatient;
36 gdcm::ListDicomDirStudy::const_iterator itStudy;
37 gdcm::ListDicomDirSerie::const_iterator itSerie;
38 gdcm::ListDicomDirImage::const_iterator itImage;
46 fileName = GDCM_DATA_ROOT;
47 fileName += "/DICOMDIR";
51 gdcm::Debug::SetDebugOn();
53 e1 = new gdcm::DicomDir( fileName );
58 detailLevel = atoi(argv[2]);
63 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
65 std::cout<<"Empty list"<<std::endl;
69 // Structure use Examples
74 std::cout << std::endl << std::endl
75 << " = PATIENT List =========================================="
76 << std::endl<< std::endl;
78 itPatient = e1->GetDicomDirPatients().begin();
79 while ( itPatient != e1->GetDicomDirPatients().end() ) // on degouline la liste de PATIENT
81 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
87 std::cout << std::endl << std::endl
88 << " = PATIENT/STUDY List ======================================="
89 << std::endl<< std::endl;
91 itPatient = e1->GetDicomDirPatients().begin();
92 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
93 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
94 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
95 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
96 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
104 std::cout << std::endl << std::endl
105 << " = PATIENT/STUDY/SERIE List =================================="
106 << std::endl<< std::endl;
108 itPatient = e1->GetDicomDirPatients().begin();
109 while ( itPatient != e1->GetDicomDirPatients().end() ) // on degouline la liste de PATIENT
111 // Patient's Name, Patient ID
112 std::cout << "Pat.Name:[" << (*itPatient)->GetEntry(0x0010, 0x0010) <<"]"; // Patient's Name
113 std::cout << " Pat.ID:[";
114 std::cout << (*itPatient)->GetEntry(0x0010, 0x0020) << "]" << std::endl; // Patient ID
115 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
116 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
117 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntry(0x0008, 0x1030) << "]";// Study Description
118 std::cout << " Stud.ID:[" << (*itStudy)->GetEntry(0x0020, 0x0010); // Study ID
119 std::cout << "]" << std::endl;
120 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
121 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
122 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntry(0x0008, 0x103e)<< "]"; // Series Description
123 std::cout << " Ser.nb:[" << (*itSerie)->GetEntry(0x0020, 0x0011); // Series number
124 std::cout << "] Mod.:[" << (*itSerie)->GetEntry(0x0008, 0x0060) << "]"; // Modality
125 std::cout << std::endl;
135 std::cout << std::endl << std::endl
136 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
137 << std::endl<< std::endl;
139 itPatient = e1->GetDicomDirPatients().begin();
140 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
141 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
142 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
143 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
144 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
145 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
146 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
147 std::cout << "--- --- "<< (*itSerie)->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
148 itImage = ((*itSerie)->GetDicomDirImages()).begin();
149 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
150 std::cout << "--- --- --- "<< (*itImage)->GetEntry(0x0004, 0x1500) << std::endl; // File name
162 std::cout << std::endl << std::endl
163 << " = DICOMDIR full content =========================================="
164 << std::endl<< std::endl;
173 std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
175 std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
176 std::cout<<std::flush;