1 /*=========================================================================
4 Module: $RCSfile: PrintDicomDir.cxx,v $
6 Date: $Date: 2004/11/16 04:26:17 $
7 Version: $Revision: 1.6 $
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 =========================================================================*/
20 #include "gdcmDocument.h"
21 #include "gdcmDicomDir.h"
22 #include "gdcmValEntry.h"
28 int main(int argc, char* argv[])
32 gdcm::ListDicomDirPatient::const_iterator itPatient;
33 gdcm::ListDicomDirStudy::const_iterator itStudy;
34 gdcm::ListDicomDirSerie::const_iterator itSerie;
35 gdcm::ListDicomDirImage::const_iterator itImage;
42 file += GDCM_DATA_ROOT;
46 e1 = new gdcm::DicomDir( file );
49 int level = atoi(argv[2]);
50 e1->SetPrintLevel(level);
53 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
55 std::cout<<"Empty list"<<std::endl;
59 // Structure use Examples
60 // DON'T REMOVE neither the following code, nor the commented out lines
63 cout << std::endl << std::endl
64 << " = PATIENT List =========================================="
65 << std::endl<< std::endl;
67 itPatient = e1->GetDicomDirPatients().begin();
68 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
69 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
75 cout << std::endl << std::endl
76 << " = PATIENT/STUDY List ======================================="
77 << std::endl<< std::endl;
79 itPatient = e1->GetDicomDirPatients().begin();
80 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
81 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
82 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
83 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
84 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
93 cout << std::endl << std::endl
94 << " = PATIENT/STUDY/SERIE List =================================="
95 << std::endl<< std::endl;
97 itPatient = e1->GetDicomDirPatients().begin();
98 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
99 // Patient's Name, Patient ID
100 std::cout << "Pat.Name:[" << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) <<"]"; // Patient's Name
101 std::cout << " Pat.ID:[";
102 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0020) << "]" << std::endl; // Patient ID
103 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
104 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
105 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << "]";// Study Description
106 std::cout << " Stud.ID:[" << (*itStudy)->GetEntryByNumber(0x0020, 0x0010); // Study ID
107 std::cout << "]" << std::endl;
108 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
109 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
110 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e)<< "]"; // Series Description
111 std::cout << " Ser.nb:[" << (*itSerie)->GetEntryByNumber(0x0020, 0x0011); // Series number
112 std::cout << "] Mod.:[" << (*itSerie)->GetEntryByNumber(0x0008, 0x0060) << "]"; // Modality
113 std::cout << std::endl;
123 cout << std::endl << std::endl
124 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
125 << std::endl<< std::endl;
127 itPatient = e1->GetDicomDirPatients().begin();
128 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
129 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
130 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
131 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
132 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
133 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
134 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
135 std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
136 itImage = ((*itSerie)->GetDicomDirImages()).begin();
137 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
138 std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
150 // cout << std::endl << std::endl
151 // << " = DICOMDIR full content =========================================="
152 // << std::endl<< std::endl;
155 std::cout<<std::flush;