]> Creatis software - gdcm.git/blob - Example/makeDicomDir.cxx
ENH: gdcm now compiles on borland
[gdcm.git] / Example / makeDicomDir.cxx
1 #include <iostream>
2 #include "gdcm.h"
3 #include "gdcmDocEntry.h"
4 #include "gdcmDicomDir.h"
5 #include "gdcmDicomDirPatient.h"
6 #include "gdcmDirList.h"
7
8 // ---
9 void StartMethod(void *toto) {
10   (void)toto;
11    std::cout<<"Start parsing"<<std::endl;
12 }
13
14 void EndMethod(void *toto) {
15   (void)toto;
16    std::cout<<"End parsing"<<std::endl;
17 }
18 // ---
19
20 /**
21   * \ingroup Test
22   * \brief   Explores recursively the given directory (or GDCM_DATA_ROOT by default)
23   *          orders the gdcm-readable found Files
24   *          according their Patient/Study/Serie/Image characteristics
25   *          makes the gdcmDicomDir 
26   *          and writes a file named NewDICOMDIR..
27   */  
28
29 int main(int argc, char* argv[]) {
30   gdcm::DicomDir *dcmdir;
31    std::string dirName;   
32
33    if (argc > 1)
34       dirName = argv[1];
35    else
36       dirName = GDCM_DATA_ROOT;
37
38    dcmdir = new gdcm::DicomDir(dirName, true); // we ask for Directory parsing
39
40    dcmdir->SetStartMethod(StartMethod, (void *) NULL);
41    dcmdir->SetEndMethod(EndMethod);
42    
43    gdcm::ListDicomDirPatient lp = dcmdir->GetDicomDirPatients();
44    if (! lp.size() ) 
45    {
46       std::cout << "makeDicomDir: no patient list present. Exiting."
47                 << std::endl;
48       return 1;
49    }
50     
51    dcmdir->WriteDicomDir("NewDICOMDIR");
52    std::cout<<std::flush;
53
54    delete dcmdir;
55    return 0;
56 }