1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #ifndef __ITKToVTKImageImport_h_
27 #define __ITKToVTKImageImport_h_
30 #include "itkVTKImageImport.h"
31 #include "itkVTKImageExport.h"
32 #include <itkProcessObject.h>
34 #include "vtkImageData.h"
35 #include "vtkImageImport.h"
36 #include "vtkImageExport.h"
39 #define TRY_CLAUSE_ITK try{
40 #define CATCH_CLAUSE_ITK }catch(itk::ExceptionObject &e){ \
41 std::cout<<e<<std::endl; \
42 std::string ex = e.GetDescription();}\
46 //------------------------------------------------------------------------------------------------------------
48 //------------------------------------------------------------------------------------------------------------
49 template<typename TypeImage>
50 class ITK_EXPORT ITKToVTKImageImport :
56 /** Standard class typedefs. */
57 typedef ITKToVTKImageImport Self;
59 /** Standard "Superclass" typedef */
60 typedef ProcessObject Superclass;
62 /** Smart pointer typedef support. */
63 typedef SmartPointer<Self> Pointer;
64 typedef SmartPointer<const Self> ConstPointer;
66 /** Method for creation through the object factory. */
69 /** Run-time type information (and related methods). */
70 itkTypeMacro( ITKToVTKImageImport, ProcessObject );
72 /** InputImageType typedef support. */
73 typedef TypeImage InputImageType;
74 typedef typename InputImageType::Pointer InputImagePointerType;
75 typedef typename InputImageType::PixelType PixelType;
76 typedef typename InputImageType::IndexType IndexType;
79 * type definition for the itk image import
81 typedef itk::VTKImageImport<InputImageType> ImageImportType;
83 typedef typename ImageImportType::Pointer ImageImportPointer;
85 * type definition for the itk image import
87 typedef itk::VTKImageExport<InputImageType> ImageExportType;
89 * type definition for the pointer of the image import
91 typedef typename ImageExportType::Pointer ImageExportPointer;
94 * set the vtkImage data to connect to itk pipeline
96 void SetVTKImage(vtkImageData* img);
99 * Get the vtkImageData from the itk image
101 vtkImageData* GetOutputVTKImage();
104 void SetITKImage(InputImagePointerType itkimage);
108 InputImagePointerType GetOutputITKImage() ;
110 //------------------------------------------------------------------------------------------------------------
112 //------------------------------------------------------------------------------------------------------------
115 ** Default constructor, allocates the vtkImageExport and itkImageImport
116 ** Connects the pipelines and set them ready to be use
118 ITKToVTKImageImport();
119 ~ITKToVTKImageImport();
125 vtkImageData* m_VTKImage;
127 InputImagePointerType m_ITKImage;
130 * Pointer to vtkImageExport
132 vtkImageExport * vtkimageexport;
134 * itk::VTKImageImport pointer
136 ImageImportPointer imageimportpointer;
138 * Pointer to vtkImageExport
140 vtkImageImport * vtkimageimport;
142 * Pointer to Export the itk image into vtk
144 ImageExportPointer imageexportpointer;
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "itktovtkimageimport.txx"