1 /*=========================================================================
4 Module: $RCSfile: TestDicomDir.cxx,v $
6 Date: $Date: 2004/11/16 04:28:20 $
7 Version: $Revision: 1.21 $
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 =========================================================================*/
19 #include "gdcmDocEntry.h"
20 #include "gdcmDicomDir.h"
25 int TestDicomDir(int argc, char* argv[])
29 gdcm::ListDicomDirPatient::const_iterator itPatient;
30 gdcm::ListDicomDirStudy::const_iterator itStudy;
31 gdcm::ListDicomDirSerie::const_iterator itSerie;
32 gdcm::ListDicomDirImage::const_iterator itImage;
39 file += GDCM_DATA_ROOT;
43 e1 = new gdcm::DicomDir(file);
45 int level = atoi(argv[2]);
46 e1->SetPrintLevel(level);
49 if(e1->GetDicomDirPatients().begin() == e1->GetDicomDirPatients().end() )
51 std::cout<<"Empty list"<<std::endl;
55 // Simple examples of structure exploitation
56 // DON'T REMOVE neither the following code, nor the commented out lines
59 cout << std::endl << std::endl
60 << " = Liste des PATIENT =========================================="
61 << std::endl<< std::endl;
64 itPatient = e1->GetDicomDirPatients().begin();
65 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
66 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
72 cout << std::endl << std::endl
73 << " = Liste des PATIENT/STUDY =========================================="
74 << std::endl<< std::endl;
76 itPatient = e1->GetDicomDirPatients().begin();
77 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
78 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
79 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
80 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
81 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
88 std::cout << std::endl << std::endl
89 << " = Liste des PATIENT/STUDY/SERIE =========================================="
90 << std::endl<< std::endl;
92 itPatient = e1->GetDicomDirPatients().begin();
93 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
94 // Patient's Name, Patient ID
95 std::cout << "Pat.Name:[" << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) <<"]";
96 std::cout << " Pat.ID:[";
97 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0020) << "]" << std::endl;
98 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
99 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
100 std::cout << "--- Stud.descr:[" << (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << "]";// Study Description
101 std::cout << " Stud.ID:["<< (*itStudy)->GetEntryByNumber(0x0020, 0x0010); // Study ID
102 std::cout << "]" << std::endl;
103 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
104 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
105 std::cout << "--- --- Ser.Descr:["<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e)<< "]";// Serie Description
106 std::cout << " Ser.nb:[" << (*itSerie)->GetEntryByNumber(0x0020, 0x0011); // Serie number
107 std::cout << "] Mod.:[" << (*itSerie)->GetEntryByNumber(0x0008, 0x0060) << "]"; // Modality
108 std::cout << std::endl;
118 cout << std::endl << std::endl
119 << " = Liste des PATIENT/STUDY/SERIE/IMAGE ==================================="
120 << std::endl<< std::endl;
122 itPatient = e1->GetDicomDirPatients().begin();
123 while ( itPatient != e1->GetDicomDirPatients().end() ) { // on degouline la liste de PATIENT
124 std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
125 itStudy = ((*itPatient)->GetDicomDirStudies()).begin();
126 while (itStudy != (*itPatient)->GetDicomDirStudies().end() ) { // on degouline les STUDY de ce patient
127 std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
128 itSerie = ((*itStudy)->GetDicomDirSeries()).begin();
129 while (itSerie != (*itStudy)->GetDicomDirSeries().end() ) { // on degouline les SERIES de cette study
130 std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
131 itImage = ((*itSerie)->GetDicomDirImages()).begin();
132 while (itImage != (*itSerie)->GetDicomDirImages().end() ) { // on degouline les SERIES de cette study
133 std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
144 std::cout << std::endl << std::endl
145 << " = Contenu Complet du DICOMDIR =========================================="
146 << std::endl<< std::endl;
149 std::cout<<std::flush;