2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------
27 /*=========================================================================
30 Module: $RCSfile: Dcm2VtkImageData.cxx,v $
32 Date: $Date: 2012/11/15 13:31:39 $
33 Version: $Revision: 1.2 $
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.
39 =========================================================================*/
45 #include "gdcmCommon.h"
46 #include "gdcmDebug.h"
48 #include "gdcmDirList.h"
50 #include "gdcmArgMgr.h"
51 #include "vtkGdcmReader.h"
53 // ===================================================================================================
56 int main(int argc, char *argv[])
59 " \n Dcm2VtkImageData : \n ",
60 " usage: Dcm2VtkImageData dirin=rootDirectoryName ",
61 " nb=number of Slices ",
62 " [debug] [verbose] ",
64 " debug : developper wants to run the program in 'debug mode' ",
67 // ------------ Initialize Arguments Manager ----------------
69 GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
71 if (argc == 1 || am->ArgMgrDefined("usage") )
73 am->ArgMgrUsage(usage); // Display 'usage'
78 const char *dirNamein;
79 dirNamein = am->ArgMgrGetString("dirin",".");
80 int nb = am->ArgMgrGetInt("nb",1);
82 if (am->ArgMgrDefined("debug"))
83 GDCM_NAME_SPACE::Debug::DebugOn();
85 bool verbose = am->ArgMgrDefined("verbose");
87 /* if unused Param we give up */
88 if ( am->ArgMgrPrintUnusedLabels() )
90 am->ArgMgrUsage(usage);
95 delete am; // we don't need Argument Manager any longer
97 // ----------- End Arguments Manager ---------
101 // ----- Begin Processing -----
102 vtkGdcmReader *reader = vtkGdcmReader::New();
103 std::vector <vtkImageData *> output;
104 char nomFich[1024]; // Hope it's enough !
106 for (int i = 0; i < nb; i++)
108 sprintf(nomFich, "%s%c2dseq_Slice_%d.dcm",
110 GDCM_NAME_SPACE::GDCM_FILESEPARATOR,
113 std::cout << "file to be processed : [" << nomFich << ")" << std::endl;
114 reader->SetFileName(nomFich);
116 output.push_back(reader->GetOutput());
119 // Here you call the function that processes the vtkImageData vector