1 /*=========================================================================
4 Module: $RCSfile: PrintDicomDir.cxx,v $
6 Date: $Date: 2004/12/03 20:16:55 $
7 Version: $Revision: 1.7 $
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"
30 int main(int argc, char* argv[])
34 gdcm::ListDicomDirPatient::const_iterator itPatient;
35 gdcm::ListDicomDirStudy::const_iterator itStudy;
36 gdcm::ListDicomDirSerie::const_iterator itSerie;
37 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 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
57 std::cout<<"Empty list"<<std::endl;
61 // Structure use Examples
62 // DON'T REMOVE neither the following code, nor the commented out lines
65 cout << std::endl << std::endl
66 << " = PATIENT List =========================================="
67 << std::endl<< std::endl;
69 itPatient = e1->GetDicomDirPatients().begin();
70 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
71 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
77 cout << std::endl << std::endl
78 << " = PATIENT/STUDY List ======================================="
79 << std::endl<< std::endl;
81 itPatient = e1->GetDicomDirPatients().begin();
82 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
83 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
84 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
85 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
86 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
95 std::cout << std::endl << std::endl
96 << " = PATIENT/STUDY/SERIE List =================================="
97 << std::endl<< std::endl;
99 itPatient = e1->GetDicomDirPatients().begin();
100 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
101 // Patient's Name, Patient ID
102 std::cout << "Pat.Name:[" << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) <<"]"; // Patient's Name
103 std::cout << " Pat.ID:[";
104 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0020) << "]" << std::endl; // Patient ID
105 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
106 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
107 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << "]";// Study Description
108 std::cout << " Stud.ID:[" << (*itStudy)->GetEntryByNumber(0x0020, 0x0010); // Study ID
109 std::cout << "]" << std::endl;
110 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
111 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
112 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e)<< "]"; // Series Description
113 std::cout << " Ser.nb:[" << (*itSerie)->GetEntryByNumber(0x0020, 0x0011); // Series number
114 std::cout << "] Mod.:[" << (*itSerie)->GetEntryByNumber(0x0008, 0x0060) << "]"; // Modality
115 std::cout << std::endl;
125 cout << std::endl << std::endl
126 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
127 << std::endl<< std::endl;
129 itPatient = e1->GetDicomDirPatients().begin();
130 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
131 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
132 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
133 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
134 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
135 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
136 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
137 std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
138 itImage = ((*itSerie)->GetDicomDirImages()).begin();
139 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
140 std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
152 // cout << std::endl << std::endl
153 // << " = DICOMDIR full content =========================================="
154 // << std::endl<< std::endl;
157 std::cout<<std::flush;