]> Creatis software - gdcm.git/blob - Example/makeDicomDir.cxx
948e24f7e38758ba7cb6d09f5b0f9b5aef3819df
[gdcm.git] / Example / makeDicomDir.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: makeDicomDir.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/18 07:55:16 $
7   Version:   $Revision: 1.11 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18 #include "gdcmDocEntry.h"
19 #include "gdcmDicomDir.h"
20 #include "gdcmDicomDirPatient.h"
21 #include "gdcmDirList.h"
22
23 #include <iostream>
24
25 // ---
26 void StartMethod(void *toto) {
27   (void)toto;
28    std::cout<<"Start parsing"<<std::endl;
29 }
30
31 void EndMethod(void *toto) {
32   (void)toto;
33    std::cout<<"End parsing"<<std::endl;
34 }
35 // ---
36
37 /**
38   * \ingroup Test
39   * \brief   Explores recursively the given directory (or GDCM_DATA_ROOT by default)
40   *          orders the gdcm-readable found Files
41   *          according their Patient/Study/Serie/Image characteristics
42   *          makes the gdcmDicomDir 
43   *          and writes a file named NewDICOMDIR..
44   */  
45
46 int main(int argc, char* argv[]) {
47    gdcm::DicomDir *dcmdir;
48    std::string dirName;   
49
50    if (argc > 1)
51       dirName = argv[1];
52    else
53       dirName = GDCM_DATA_ROOT;
54
55    dcmdir = new gdcm::DicomDir(dirName, true); // we ask for Directory parsing
56
57    dcmdir->SetStartMethod(StartMethod, (void *) NULL);
58    dcmdir->SetEndMethod(EndMethod);
59    
60    if ( !dcmdir->GetFirstEntry() ) 
61    {
62       std::cout << "makeDicomDir: no patient list present. Exiting."
63                 << std::endl;
64       return 1;
65    }
66     
67    dcmdir->WriteDicomDir("NewDICOMDIR");
68    std::cout<<std::flush;
69
70    delete dcmdir;
71    return 0;
72 }