1 /*=========================================================================
4 Module: $RCSfile: TestDicomDir.cxx,v $
6 Date: $Date: 2005/01/13 14:39:02 $
7 Version: $Revision: 1.26 $
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 "gdcmDocEntry.h"
19 #include "gdcmDicomDir.h"
20 #include "gdcmDicomDirPatient.h"
21 #include "gdcmDicomDirStudy.h"
22 #include "gdcmDicomDirSerie.h"
23 #include "gdcmDicomDirImage.h"
29 int TestDicomDir(int argc, char* argv[])
33 gdcm::ListDicomDirPatient::const_iterator itPatient;
34 gdcm::ListDicomDirStudy::const_iterator itStudy;
35 gdcm::ListDicomDirSerie::const_iterator itSerie;
36 //gdcm::ListDicomDirImage::const_iterator itImage;
44 file += GDCM_DATA_ROOT;
48 e1 = new gdcm::DicomDir(file);
51 int level = atoi(argv[2]);
52 e1->SetPrintLevel(level);
55 // Test if the dicomDir is readable
56 if( !e1->IsReadable() )
58 std::cout<<" DicomDir '"<<file
59 <<"' is not readable"<<std::endl
60 <<" ...Failed"<<std::endl;
66 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
68 std::cout<<" DicomDir '"<<file
69 <<" has no patient"<<std::endl
70 <<" ...Failed"<<std::endl;
76 // Simple examples of structure exploitation
77 // DON'T REMOVE neither the following code, nor the commented out lines
80 cout << std::endl << std::endl
81 << " = Liste des PATIENT =========================================="
82 << std::endl<< std::endl;
85 itPatient = e1->GetDicomDirPatients().begin();
86 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
87 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
93 cout << std::endl << std::endl
94 << " = Liste des PATIENT/STUDY =========================================="
95 << std::endl<< std::endl;
97 itPatient = e1->GetDicomDirPatients().begin();
98 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
99 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
100 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
101 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
102 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
109 std::cout << std::endl << std::endl
110 << " = Liste des PATIENT/STUDY/SERIE =========================================="
111 << std::endl<< std::endl;
113 itPatient = e1->GetDicomDirPatients().begin();
114 while ( itPatient != e1->GetDicomDirPatients().end() ) // on degouline la liste de PATIENT
116 // Patient's Name, Patient ID
117 std::cout << "Pat.Name:[" << (*itPatient)->GetEntry(0x0010, 0x0010) <<"]";
118 std::cout << " Pat.ID:[";
119 std::cout << (*itPatient)->GetEntry(0x0010, 0x0020) << "]" << std::endl;
120 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
121 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
122 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntry(0x0008, 0x1030) << "]";// Study Description
123 std::cout << " Stud.ID:["<< (*itStudy)->GetEntry(0x0020, 0x0010); // Study ID
124 std::cout << "]" << std::endl;
125 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
126 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) // on degouline les SERIES de cette study
128 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntry(0x0008, 0x103e)<< "]";// Serie Description
129 std::cout << " Ser.nb:[" << (*itSerie)->GetEntry(0x0020, 0x0011); // Serie number
130 std::cout << "] Mod.:[" << (*itSerie)->GetEntry(0x0008, 0x0060) << "]"; // Modality
131 std::cout << std::endl;
141 cout << std::endl << std::endl
142 << " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
143 << std::endl<< std::endl;
145 itPatient = e1->GetDicomDirPatients().begin();
146 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
147 std::cout << (*itPatient)->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
148 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
149 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
150 std::cout << "--- "<< (*itStudy)->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
151 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
152 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
153 std::cout << "--- --- "<< (*itSerie)->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
154 itImage = ((*itSerie)->GetDicomDirImages()).begin();
155 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
156 std::cout << "--- --- --- "<< (*itImage)->GetEntry(0x0004, 0x1500) << std::endl; // File name
167 std::cout << std::endl << std::endl
168 << " = Contenu Complet du DICOMDIR =========================================="
169 << std::endl<< std::endl;
172 std::cout<<std::flush;