1 /*=========================================================================
4 Module: $RCSfile: TestDicomDir.cxx,v $
6 Date: $Date: 2005/01/18 07:56:21 $
7 Version: $Revision: 1.30 $
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::DicomDirPatient *pa;
34 gdcm::DicomDirStudy *st;
35 gdcm::DicomDirSerie *se;
36 gdcm::DicomDirImage *im;
45 file += GDCM_DATA_ROOT;
49 e1 = new gdcm::DicomDir(file);
52 int level = atoi(argv[2]);
53 e1->SetPrintLevel(level);
56 // Test if the DicomDir is readable
57 if( !e1->IsReadable() )
59 std::cout<<" DicomDir '"<<file
60 <<"' is not readable"<<std::endl
61 <<" ...Failed"<<std::endl;
68 std::cout<<" DicomDir '"<<file
69 <<"' is readable"<<std::endl;
72 // Test if the DicomDir contains any Patient
73 if( !e1->GetFirstEntry() )
75 std::cout<<" DicomDir '"<<file
76 <<" has no patient"<<std::endl
77 <<" ...Failed"<<std::endl;
83 // step by step structure full exploitation
85 std::cout << std::endl << std::endl
86 << " = PATIENT/STUDY/SERIE/IMAGE List ============================"
87 << std::endl<< std::endl;
89 pa = e1->GetFirstEntry();
90 while ( pa ) { // we process all the PATIENT of this DICOMDIR
91 std::cout << pa->GetEntry(0x0010, 0x0010) << std::endl; // Patient's Name
92 st = pa->GetFirstEntry();
93 while ( st ) { // we process all the STUDY of this patient
94 std::cout << "--- "<< st->GetEntry(0x0008, 0x1030) << std::endl; // Study Description
95 std::cout << " Stud.ID:[" << st->GetEntry(0x0020, 0x0010); // Study ID
96 se = st->GetFirstEntry();
97 while ( se ) { // we process all the SERIES of this study
98 std::cout << "--- --- "<< se->GetEntry(0x0008, 0x103e) << std::endl; // Serie Description
99 std::cout << " Ser.nb:[" << se->GetEntry(0x0020, 0x0011); // Series number
100 std::cout << "] Mod.:[" << se->GetEntry(0x0008, 0x0060) << "]"; // Modality
101 im = se->GetFirstEntry();
102 while ( im ) { // we process all the IMAGE of this serie
103 std::cout << "--- --- --- "<< im->GetEntry(0x0004, 0x1500) << std::endl; // File name
104 im = se->GetNextEntry();
106 se = st->GetNextEntry();
108 st = pa->GetNextEntry();
110 pa = e1->GetNextEntry();
114 std::cout << std::endl << std::endl
115 << " = DICOMDIR full content ===================================="
116 << std::endl<< std::endl;
119 std::cout<<std::flush;