]> Creatis software - gdcm.git/blob - Example/MakeDicomDir.cxx
Strange name gdcm::SerieHeader turned to gdcm::SerieHelper
[gdcm.git] / Example / MakeDicomDir.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: MakeDicomDir.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/02/02 14:26:30 $
7   Version:   $Revision: 1.1 $
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 {
48    gdcm::DicomDir *dcmdir;
49    std::string dirName;   
50
51    if (argc > 1)
52       dirName = argv[1];
53    else
54       dirName = GDCM_DATA_ROOT;
55
56    dcmdir = new gdcm::DicomDir(dirName, true); // we ask for Directory parsing
57
58    dcmdir->SetStartMethod(StartMethod, (void *) NULL);
59    dcmdir->SetEndMethod(EndMethod);
60    
61    if ( !dcmdir->GetFirstEntry() ) 
62    {
63       std::cout << "makeDicomDir: no patient list present. Exiting."
64                 << std::endl;
65       return 1;
66    }
67     
68    dcmdir->WriteDicomDir("NewDICOMDIR");
69    std::cout<<std::flush;
70
71    delete dcmdir;
72    return 0;
73 }