]> Creatis software - creaBruker.git/blob - appli/Dcm2VtkImageData/Dcm2VtkImageData.cxx
Added CMake configuration to enable CDash tests.
[creaBruker.git] / appli / Dcm2VtkImageData / Dcm2VtkImageData.cxx
1 /*
2         # ---------------------------------------------------------------------
3         #
4         # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5         #                        pour la Santé)
6         # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7         # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8         # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9         #
10         #  This software is governed by the CeCILL-B license under French law and 
11         #  abiding by the rules of distribution of free software. You can  use, 
12         #  modify and/ or redistribute the software under the terms of the CeCILL-B 
13         #  license as circulated by CEA, CNRS and INRIA at the following URL 
14         #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
15         #  or in the file LICENSE.txt.
16         #
17         #  As a counterpart to the access to the source code and  rights to copy,
18         #  modify and redistribute granted by the license, users are provided only
19         #  with a limited warranty  and the software's author,  the holder of the
20         #  economic rights,  and the successive licensors  have only  limited
21         #  liability. 
22         #
23         #  The fact that you are presently reading this means that you have had
24         #  knowledge of the CeCILL-B license and that you accept its terms.
25         # ------------------------------------------------------------------------
26 */
27 /*=========================================================================
28                                                                                 
29   Program:   creaBruker
30   Module:    $RCSfile: Dcm2VtkImageData.cxx,v $
31   Language:  C++
32   Date:      $Date: 2012/11/15 13:31:39 $
33   Version:   $Revision: 1.2 $
34                                                                                 
35      This software is distributed WITHOUT ANY WARRANTY; without even
36      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
37      PURPOSE.  See the above copyright notices for more information.
38                                       
39 =========================================================================*/
40
41 /** 
42  * 
43  */
44
45 #include "gdcmCommon.h"
46 #include "gdcmDebug.h"
47 #include "gdcmUtil.h"
48 #include "gdcmDirList.h"
49
50 #include "gdcmArgMgr.h"
51 #include "vtkGdcmReader.h"
52
53 // ===================================================================================================
54
55
56 int main(int argc, char *argv[])
57 {
58    START_USAGE(usage)
59    " \n Dcm2VtkImageData : \n                                                 ",
60    " usage: Dcm2VtkImageData dirin=rootDirectoryName                          ",
61    "                         nb=number of Slices                              ",
62    "                   [debug] [verbose]                                      ",
63    "                                                                          ",
64    "  debug      : developper wants to run the program in 'debug mode'        ",
65    FINISH_USAGE
66    
67    // ------------ Initialize Arguments Manager ---------------- 
68     
69    GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
70   
71    if (argc == 1 || am->ArgMgrDefined("usage") )
72    {
73       am->ArgMgrUsage(usage); // Display 'usage'
74       delete am;
75       return 1;
76    }
77
78    const char *dirNamein;   
79    dirNamein  = am->ArgMgrGetString("dirin",".");
80    int nb = am->ArgMgrGetInt("nb",1);
81
82    if (am->ArgMgrDefined("debug"))
83       GDCM_NAME_SPACE::Debug::DebugOn();
84
85    bool verbose  = am->ArgMgrDefined("verbose");      
86              
87    /* if unused Param we give up */
88    if ( am->ArgMgrPrintUnusedLabels() )
89    {
90       am->ArgMgrUsage(usage);
91       delete am;
92       return 1;
93    } 
94       
95    delete am;  // we don't need Argument Manager any longer  
96
97    // ----------- End Arguments Manager ---------
98    
99 //2dseq_Slice_0.dcm   
100
101    // ----- Begin Processing -----
102    vtkGdcmReader *reader = vtkGdcmReader::New();
103    std::vector <vtkImageData *> output;
104    char nomFich[1024]; // Hope it's enough !
105
106    for (int i = 0; i < nb; i++)
107    {
108       sprintf(nomFich, "%s%c2dseq_Slice_%d.dcm", 
109          dirNamein, 
110          GDCM_NAME_SPACE::GDCM_FILESEPARATOR, 
111          i);
112       if (verbose)
113          std::cout << "file to be processed : [" << nomFich << ")" << std::endl;
114       reader->SetFileName(nomFich);
115       reader->Update();
116       output.push_back(reader->GetOutput());    
117    }
118    
119    // Here you call the function that processes the vtkImageData vector  
120
121
122