1 /*=========================================================================
4 Module: $RCSfile: TestDicomDir.cxx,v $
6 Date: $Date: 2004/12/03 20:16:56 $
7 Version: $Revision: 1.22 $
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;
43 file += GDCM_DATA_ROOT;
47 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 // Simple examples of structure exploitation
60 // DON'T REMOVE neither the following code, nor the commented out lines
63 cout << std::endl << std::endl
64 << " = Liste des PATIENT =========================================="
65 << std::endl<< std::endl;
68 itPatient = e1->GetDicomDirPatients().begin();
69 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
70 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
76 cout << std::endl << std::endl
77 << " = Liste des PATIENT/STUDY =========================================="
78 << std::endl<< std::endl;
80 itPatient = e1->GetDicomDirPatients().begin();
81 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
82 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
83 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
84 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
85 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
92 std::cout << std::endl << std::endl
93 << " = Liste des PATIENT/STUDY/SERIE =========================================="
94 << std::endl<< std::endl;
96 itPatient = e1->GetDicomDirPatients().begin();
97 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
98 // Patient's Name, Patient ID
99 std::cout << "Pat.Name:[" << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) <<"]";
100 std::cout << " Pat.ID:[";
101 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0020) << "]" << std::endl;
102 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
103 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
104 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << "]";// Study Description
105 std::cout << " Stud.ID:["<< (*itStudy)->GetEntryByNumber(0x0020, 0x0010); // Study ID
106 std::cout << "]" << std::endl;
107 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
108 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
109 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e)<< "]";// Serie Description
110 std::cout << " Ser.nb:[" << (*itSerie)->GetEntryByNumber(0x0020, 0x0011); // Serie number
111 std::cout << "] Mod.:[" << (*itSerie)->GetEntryByNumber(0x0008, 0x0060) << "]"; // Modality
112 std::cout << std::endl;
122 cout << std::endl << std::endl
123 << " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
124 << std::endl<< std::endl;
126 itPatient = e1->GetDicomDirPatients().begin();
127 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
128 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
129 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
130 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
131 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
132 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
133 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
134 std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
135 itImage = ((*itSerie)->GetDicomDirImages()).begin();
136 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
137 std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
148 std::cout << std::endl << std::endl
149 << " = Contenu Complet du DICOMDIR =========================================="
150 << std::endl<< std::endl;
153 std::cout<<std::flush;