1 /*=========================================================================
4 Module: $RCSfile: PrintDicomDir.cxx,v $
6 Date: $Date: 2005/01/13 14:56:39 $
7 Version: $Revision: 1.13 $
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]);
62 if( !e1->IsReadable() )
64 std::cout<<" DicomDir '"<<fileName
65 <<"' is not readable"<<std::endl
66 <<" ...Failed"<<std::endl;
72 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
74 std::cout<<" DicomDir '"<<fileName
75 <<" has no patients"<<std::endl
76 <<" ...Failed"<<std::endl;
82 // Structure use Examples
87 std::cout << std::endl << std::endl
88 << " = PATIENT List =========================================="
89 << std::endl<< std::endl;
91 itPatient = e1->GetDicomDirPatients().begin();
92 while ( itPatient != e1->GetDicomDirPatients().end() ) // on degouline la liste de PATIENT
94 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
100 std::cout << std::endl << std::endl
101 << " = PATIENT/STUDY List ======================================="
102 << std::endl<< std::endl;
104 itPatient = e1->GetDicomDirPatients().begin();
105 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
106 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
107 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
108 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
109 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
117 std::cout << std::endl << std::endl
118 << " = PATIENT/STUDY/SERIE List =================================="
119 << std::endl<< std::endl;
121 itPatient = e1->GetDicomDirPatients().begin();
122 while ( itPatient != e1->GetDicomDirPatients().end() ) // on degouline la liste de PATIENT
124 // Patient's Name, Patient ID
125 std::cout << "Pat.Name:[" << (*itPatient)->GetEntry(0x0010, 0x0010) <<"]"; // Patient's Name
126 std::cout << " Pat.ID:[";
127 std::cout << (*itPatient)->GetEntry(0x0010, 0x0020) << "]" << std::endl; // Patient ID
128 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
129 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
130 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntry(0x0008, 0x1030) << "]";// Study Description
131 std::cout << " Stud.ID:[" << (*itStudy)->GetEntry(0x0020, 0x0010); // Study ID
132 std::cout << "]" << std::endl;
133 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
134 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
135 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntry(0x0008, 0x103e)<< "]"; // Series Description
136 std::cout << " Ser.nb:[" << (*itSerie)->GetEntry(0x0020, 0x0011); // Series number
137 std::cout << "] Mod.:[" << (*itSerie)->GetEntry(0x0008, 0x0060) << "]"; // Modality
138 std::cout << std::endl;
148 std::cout << std::endl << std::endl
149 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
150 << std::endl<< std::endl;
152 itPatient = e1->GetDicomDirPatients().begin();
153 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
154 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
155 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
156 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
157 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
158 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
159 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
160 std::cout << "--- --- "<< (*itSerie)->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
161 itImage = ((*itSerie)->GetDicomDirImages()).begin();
162 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
163 std::cout << "--- --- --- "<< (*itImage)->GetEntry(0x0004, 0x1500) << std::endl; // File name
175 std::cout << std::endl << std::endl
176 << " = DICOMDIR full content =========================================="
177 << std::endl<< std::endl;
186 std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
188 std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
189 std::cout<<std::flush;