]> Creatis software - creaBruker.git/blob - appli/Dcm2VtkImageData/Dcm2VtkImageData.cxx
Uodates
[creaBruker.git] / appli / Dcm2VtkImageData / Dcm2VtkImageData.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: Dcm2VtkImageData.cxx,v $
5   Language:  C++
6   Date:      $Date: 2009/07/17 14:14:04 $
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
19 /** 
20  * 
21  */
22
23 #include "gdcmCommon.h"
24 #include "gdcmDebug.h"
25 #include "gdcmUtil.h"
26 #include "gdcmDirList.h"
27
28 #include "gdcmArgMgr.h"
29 #include "vtkGdcmReader.h"
30
31 // ===================================================================================================
32
33
34 int main(int argc, char *argv[])
35 {
36    START_USAGE(usage)
37    " \n Dcm2VtkImageData : \n                                                 ",
38    " usage: Dcm2VtkImageData dirin=rootDirectoryName                          ",
39    "                         nb=number of Slices                              ",
40    "                   [debug] [verbose]                                      ",
41    "                                                                          ",
42    "  debug      : developper wants to run the program in 'debug mode'        ",
43    FINISH_USAGE
44    
45    // ------------ Initialize Arguments Manager ---------------- 
46     
47    GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
48   
49    if (argc == 1 || am->ArgMgrDefined("usage") )
50    {
51       am->ArgMgrUsage(usage); // Display 'usage'
52       delete am;
53       return 1;
54    }
55
56    const char *dirNamein;   
57    dirNamein  = am->ArgMgrGetString("dirin",".");
58    int nb = am->ArgMgrGetInt("nb",1);
59
60    if (am->ArgMgrDefined("debug"))
61       GDCM_NAME_SPACE::Debug::DebugOn();
62
63    bool verbose  = am->ArgMgrDefined("verbose");      
64              
65    /* if unused Param we give up */
66    if ( am->ArgMgrPrintUnusedLabels() )
67    {
68       am->ArgMgrUsage(usage);
69       delete am;
70       return 1;
71    } 
72       
73    delete am;  // we don't need Argument Manager any longer  
74
75    // ----------- End Arguments Manager ---------
76    
77 //2dseq_Slice_0.dcm   
78
79    // ----- Begin Processing -----
80    vtkGdcmReader *reader = vtkGdcmReader::New();
81    std::vector <vtkImageData *> output;
82    char nomFich[1024]; // Hope it's enough !
83
84    for (int i = 0; i < nb; i++)
85    {
86       sprintf(nomFich, "%s%c2dseq_Slice_%d.dcm", 
87          dirNamein, 
88          GDCM_NAME_SPACE::GDCM_FILESEPARATOR, 
89          i);
90       if (verbose)
91          std::cout << "file to be processed : [" << nomFich << ")" << std::endl;
92       reader->SetFileName(nomFich);
93       reader->Update();
94       output.push_back(reader->GetOutput());    
95    }
96    
97    // Here you call the function that processes the vtkImageData vector  
98
99
100