]> Creatis software - creaMaracasVisu.git/blob - lib/Kernel/ITKVTK/itktovtkimageimport.h
bf2f9227396e3b67b097d11093793052ec52f1a1
[creaMaracasVisu.git] / lib / Kernel / ITKVTK / itktovtkimageimport.h
1 #ifndef __ITKToVTKImageImport_h_
2 #define __ITKToVTKImageImport_h_
3
4 #include "itkImage.h"
5 #include "itkVTKImageImport.h"
6 #include "itkVTKImageExport.h"
7 #include <itkProcessObject.h>
8
9 #include "vtkImageData.h"
10 #include "vtkImageImport.h"
11 #include "vtkImageExport.h"
12
13 #define DIM 3
14 #define TRY_CLAUSE_ITK          try{
15 #define CATCH_CLAUSE_ITK        }catch(itk::ExceptionObject &e){                \
16                                                                 std::cout<<e<<std::endl;                        \
17                                                                 std::string ex = e.GetDescription();}\
18
19 namespace itk{
20
21 //------------------------------------------------------------------------------------------------------------
22 // Includes
23 //------------------------------------------------------------------------------------------------------------
24 template<typename TypeImage>
25 class ITK_EXPORT ITKToVTKImageImport :
26 public ProcessObject
27 {
28
29     public:
30
31         /** Standard class typedefs. */
32         typedef ITKToVTKImageImport           Self;
33
34         /** Standard "Superclass" typedef */
35         typedef ProcessObject Superclass;
36
37         /** Smart pointer typedef support. */
38         typedef SmartPointer<Self>            Pointer;
39         typedef SmartPointer<const Self>      ConstPointer;
40
41         /** Method for creation through the object factory. */
42         itkNewMacro(Self);
43
44         /** Run-time type information (and related methods). */
45         itkTypeMacro( ITKToVTKImageImport, ProcessObject );
46
47         /** InputImageType typedef support. */
48         typedef TypeImage                                   InputImageType;
49         typedef typename InputImageType::Pointer            InputImagePointerType;
50         typedef typename InputImageType::PixelType          PixelType;
51         typedef typename InputImageType::IndexType          IndexType;
52
53         /*
54         *       type definition for the itk image import
55         */
56         typedef itk::VTKImageImport<InputImageType> ImageImportType;
57
58         typedef typename ImageImportType::Pointer ImageImportPointer;
59         /*
60         *       type definition for the itk image import
61         */
62         typedef itk::VTKImageExport<InputImageType> ImageExportType;
63         /*
64         *       type definition for the pointer of the image import
65         */
66         typedef typename ImageExportType::Pointer ImageExportPointer;
67
68         /*
69         *       set the vtkImage data to connect to itk pipeline
70         */
71         void SetVTKImage(vtkImageData* img);
72
73         /*
74         *       Get the vtkImageData from the itk image
75         */
76         vtkImageData* GetOutputVTKImage();
77
78
79         void SetITKImage(InputImagePointerType itkimage);
80         /*
81         *
82         */
83         InputImagePointerType GetOutputITKImage() ;
84
85 //------------------------------------------------------------------------------------------------------------
86 // Attributes
87 //------------------------------------------------------------------------------------------------------------
88 protected:
89         /**
90         ** Default constructor, allocates the vtkImageExport and itkImageImport
91         **      Connects the pipelines and set them ready to be use
92         **/
93         ITKToVTKImageImport();
94         ~ITKToVTKImageImport();
95
96
97 private:
98
99
100         vtkImageData* m_VTKImage;
101
102         InputImagePointerType m_ITKImage;
103
104         /*
105         *       Pointer to vtkImageExport
106         */
107         vtkImageExport * vtkimageexport;
108         /*
109         *       itk::VTKImageImport pointer
110         */
111         ImageImportPointer imageimportpointer;
112         /*
113         *       Pointer to vtkImageExport
114         */
115         vtkImageImport * vtkimageimport;
116         /*
117         *       Pointer to Export the itk image into vtk
118         */
119         ImageExportPointer imageexportpointer;
120 };
121
122 }
123
124 #ifndef ITK_MANUAL_INSTANTIATION
125 #include "itktovtkimageimport.txx"
126 #endif
127
128
129 #endif