/* # --------------------------------------------------------------------- # # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image # pour la Santé) # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton # Previous Authors : Laurent Guigues, Jean-Pierre Roux # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil # # This software is governed by the CeCILL-B license under French law and # abiding by the rules of distribution of free software. You can use, # modify and/ or redistribute the software under the terms of the CeCILL-B # license as circulated by CEA, CNRS and INRIA at the following URL # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # or in the file LICENSE.txt. # # As a counterpart to the access to the source code and rights to copy, # modify and redistribute granted by the license, users are provided only # with a limited warranty and the software's author, the holder of the # economic rights, and the successive licensors have only limited # liability. # # The fact that you are presently reading this means that you have had # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ /*========================================================================= Program: creaBruker Module: $RCSfile: Dcm2VtkImageData.cxx,v $ Language: C++ Date: $Date: 2012/11/15 13:31:39 $ Version: $Revision: 1.2 $ This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * */ #include "gdcmCommon.h" #include "gdcmDebug.h" #include "gdcmUtil.h" #include "gdcmDirList.h" #include "gdcmArgMgr.h" #include "vtkGdcmReader.h" // =================================================================================================== int main(int argc, char *argv[]) { START_USAGE(usage) " \n Dcm2VtkImageData : \n ", " usage: Dcm2VtkImageData dirin=rootDirectoryName ", " nb=number of Slices ", " [debug] [verbose] ", " ", " debug : developper wants to run the program in 'debug mode' ", FINISH_USAGE // ------------ Initialize Arguments Manager ---------------- GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv); if (argc == 1 || am->ArgMgrDefined("usage") ) { am->ArgMgrUsage(usage); // Display 'usage' delete am; return 1; } const char *dirNamein; dirNamein = am->ArgMgrGetString("dirin","."); int nb = am->ArgMgrGetInt("nb",1); if (am->ArgMgrDefined("debug")) GDCM_NAME_SPACE::Debug::DebugOn(); bool verbose = am->ArgMgrDefined("verbose"); /* if unused Param we give up */ if ( am->ArgMgrPrintUnusedLabels() ) { am->ArgMgrUsage(usage); delete am; return 1; } delete am; // we don't need Argument Manager any longer // ----------- End Arguments Manager --------- //2dseq_Slice_0.dcm // ----- Begin Processing ----- vtkGdcmReader *reader = vtkGdcmReader::New(); std::vector output; char nomFich[1024]; // Hope it's enough ! for (int i = 0; i < nb; i++) { sprintf(nomFich, "%s%c2dseq_Slice_%d.dcm", dirNamein, GDCM_NAME_SPACE::GDCM_FILESEPARATOR, i); if (verbose) std::cout << "file to be processed : [" << nomFich << ")" << std::endl; reader->SetFileName(nomFich); reader->Update(); output.push_back(reader->GetOutput()); } // Here you call the function that processes the vtkImageData vector }