1 /*=========================================================================
4 Module: $RCSfile: PrintDicomDir.cxx,v $
6 Date: $Date: 2005/01/13 11:05:26 $
7 Version: $Revision: 1.11 $
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 );
56 int level = atoi(argv[2]);
57 e1->SetPrintLevel(level);
60 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
62 std::cout<<"Empty list"<<std::endl;
66 // Structure use Examples
67 // DON'T REMOVE neither the following code, nor the commented out lines
70 cout << std::endl << std::endl
71 << " = PATIENT List =========================================="
72 << std::endl<< std::endl;
74 itPatient = e1->GetDicomDirPatients().begin();
75 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
76 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
82 cout << std::endl << std::endl
83 << " = PATIENT/STUDY List ======================================="
84 << std::endl<< std::endl;
86 itPatient = e1->GetDicomDirPatients().begin();
87 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
88 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
89 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
90 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
91 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
100 std::cout << std::endl << std::endl
101 << " = PATIENT/STUDY/SERIE List =================================="
102 << std::endl<< std::endl;
104 itPatient = e1->GetDicomDirPatients().begin();
105 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
106 // Patient's Name, Patient ID
107 std::cout << "Pat.Name:[" << (*itPatient)->GetEntry(0x0010, 0x0010) <<"]"; // Patient's Name
108 std::cout << " Pat.ID:[";
109 std::cout << (*itPatient)->GetEntry(0x0010, 0x0020) << "]" << std::endl; // Patient ID
110 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
111 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
112 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntry(0x0008, 0x1030) << "]";// Study Description
113 std::cout << " Stud.ID:[" << (*itStudy)->GetEntry(0x0020, 0x0010); // Study ID
114 std::cout << "]" << std::endl;
115 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
116 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
117 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntry(0x0008, 0x103e)<< "]"; // Series Description
118 std::cout << " Ser.nb:[" << (*itSerie)->GetEntry(0x0020, 0x0011); // Series number
119 std::cout << "] Mod.:[" << (*itSerie)->GetEntry(0x0008, 0x0060) << "]"; // Modality
120 std::cout << std::endl;
130 cout << std::endl << std::endl
131 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
132 << std::endl<< std::endl;
134 itPatient = e1->GetDicomDirPatients().begin();
135 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
136 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
137 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
138 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
139 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
140 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
141 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
142 std::cout << "--- --- "<< (*itSerie)->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
143 itImage = ((*itSerie)->GetDicomDirImages()).begin();
144 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
145 std::cout << "--- --- --- "<< (*itImage)->GetEntry(0x0004, 0x1500) << std::endl; // File name
157 // cout << std::endl << std::endl
158 // << " = DICOMDIR full content =========================================="
159 // << std::endl<< std::endl;
163 std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
165 std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
166 std::cout<<std::flush;