]> Creatis software - gdcm.git/blob - Testing/TestDicomDir.cxx
Ops! The last Meta tag was missing
[gdcm.git] / Testing / TestDicomDir.cxx
1 #include <iostream>
2 #include "gdcm.h"
3 #include "gdcmHeaderEntry.h"
4 #include "gdcmDicomDir.h"
5
6 #include <fstream>
7 #ifdef GDCM_NO_ANSI_STRING_STREAM
8 #  include <strstream>
9 #  define  ostringstream ostrstream
10 # else
11 #  include <sstream>
12 #endif
13 #include <string>
14 #include <iostream>
15
16 #define  ostringstream ostrstream
17 //extern "C"
18
19 using namespace std;
20
21 int main(int argc, char* argv[])
22 {  
23    gdcmDicomDir *e1;
24    ListTag::iterator deb , fin;
25    ListPatient::iterator  itPatient;
26    ListStudy::iterator itStudy;
27    ListSerie::iterator itSerie;
28    ListImage::iterator itImage;
29    TSKey v;
30     
31    std::string file; 
32    if (argc > 1) 
33       file = argv[1];    
34    else 
35       file = "../gdcmData/DICOMDIR";
36       
37    e1 = new gdcmDicomDir(file.c_str());
38         if (argc > 2) {
39            int level = atoi(argv[2]);   
40            e1->SetPrintLevel(level);
41         }
42
43    if(e1->GetPatients().begin() == e1->GetPatients().end() )
44    {
45       std::cout<<"Empty list"<<std::endl;
46       return(1);
47    }
48
49 // Exemples exploitation de la structure
50
51 // DON'T REMOVE neither the folowing code, nor the commented out lines
52
53
54   cout << std::endl << std::endl  
55              << " = Liste des PATIENT ==========================================" 
56              << std::endl<< std::endl;  
57
58
59    itPatient = e1->GetPatients().begin();       
60    while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
61       std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name   
62       itPatient ++;    
63    }
64
65 /*   
66      
67    cout << std::endl << std::endl  
68         << " = Liste des PATIENT/STUDY ==========================================" 
69         << std::endl<< std::endl;       
70
71    itPatient = e1->GetPatients().begin();       
72    while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
73       std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name 
74       itStudy = ((*itPatient)->GetStudies()).begin();   
75       while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient    
76          std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Stdy Description
77          ++itStudy;             
78       }
79       itPatient ++;    
80    }
81    
82  */
83  
84    cout << std::endl << std::endl  
85              << " = Liste des PATIENT/STUDY/SERIE ==========================================" 
86              << std::endl<< std::endl;  
87  
88    itPatient = e1->GetPatients().begin();       
89    while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
90       std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name 
91       itStudy = ((*itPatient)->GetStudies()).begin();   
92       while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient    
93          std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description 
94          itSerie = ((*itStudy)->GetSeries()).begin();
95          while (itSerie != (*itStudy)->GetSeries().end() ) { // on degouline les SERIES de cette study     
96             std::cout << "--- ---  "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
97             ++itSerie;   
98          }
99          ++itStudy;             
100       }
101       itPatient ++;    
102    } 
103    
104     
105  /*
106    cout << std::endl << std::endl  
107              << " = Liste des PATIENT/STUDY/SERIE/IMAGE ===================================" 
108              << std::endl<< std::endl;
109  
110    itPatient = e1->GetPatients().begin();       
111    while ( itPatient != e1->GetPatients().end() ) {  // on degouline la liste de PATIENT
112       std::cout << (*itPatient)->GetEntryByNumber(0x0010, 0x0010) << std::endl; // Patient's Name
113       itStudy = ((*itPatient)->GetStudies()).begin();   
114       while (itStudy != (*itPatient)->GetStudies().end() ) { // on degouline les STUDY de ce patient    
115          std::cout << "--- "<< (*itStudy)->GetEntryByNumber(0x0008, 0x1030) << std::endl; // Study Description
116          itSerie = ((*itStudy)->GetSeries()).begin();
117          while (itSerie != (*itStudy)->GetSeries().end() ) { // on degouline les SERIES de cette study     
118             std::cout << "--- --- "<< (*itSerie)->GetEntryByNumber(0x0008, 0x103e) << std::endl; // Serie Description
119             itImage = ((*itSerie)->GetImages()).begin();
120             while (itImage != (*itSerie)->GetImages().end() ) { // on degouline les SERIES de cette study          
121                std::cout << "--- --- --- "<< (*itImage)->GetEntryByNumber(0x0004, 0x1500) << std::endl; // File name
122                ++itImage;   
123             }
124             ++itSerie;   
125          }
126          ++itStudy;             
127       }  
128       itPatient ++;    
129    }
130    
131  */  
132
133    cout << std::endl << std::endl  
134         << " = Contenu Complet du DICOMDIR ==========================================" 
135         << std::endl<< std::endl;       
136    e1->Print();
137    
138    std::cout<<std::flush;
139    delete e1;
140
141    return(0);
142 }