]> Creatis software - creaMaracasVisu.git/blob - lib/Kernel/ITKVTK/itktovtkimageimport.h
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / Kernel / ITKVTK / itktovtkimageimport.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 #ifndef __ITKToVTKImageImport_h_
27 #define __ITKToVTKImageImport_h_
28
29 #include "itkImage.h"
30 #include "itkVTKImageImport.h"
31 #include "itkVTKImageExport.h"
32 #include <itkProcessObject.h>
33
34 #include "vtkImageData.h"
35 #include "vtkImageImport.h"
36 #include "vtkImageExport.h"
37
38 #define DIM 3
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();}\
43
44 namespace itk{
45
46 //------------------------------------------------------------------------------------------------------------
47 // Includes
48 //------------------------------------------------------------------------------------------------------------
49 template<typename TypeImage>
50 class ITK_EXPORT ITKToVTKImageImport :
51 public ProcessObject
52 {
53
54     public:
55
56         /** Standard class typedefs. */
57         typedef ITKToVTKImageImport           Self;
58
59         /** Standard "Superclass" typedef */
60         typedef ProcessObject Superclass;
61
62         /** Smart pointer typedef support. */
63         typedef SmartPointer<Self>            Pointer;
64         typedef SmartPointer<const Self>      ConstPointer;
65
66         /** Method for creation through the object factory. */
67         itkNewMacro(Self);
68
69         /** Run-time type information (and related methods). */
70         itkTypeMacro( ITKToVTKImageImport, ProcessObject );
71
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;
77
78         /*
79         *       type definition for the itk image import
80         */
81         typedef itk::VTKImageImport<InputImageType> ImageImportType;
82
83         typedef typename ImageImportType::Pointer ImageImportPointer;
84         /*
85         *       type definition for the itk image import
86         */
87         typedef itk::VTKImageExport<InputImageType> ImageExportType;
88         /*
89         *       type definition for the pointer of the image import
90         */
91         typedef typename ImageExportType::Pointer ImageExportPointer;
92
93         /*
94         *       set the vtkImage data to connect to itk pipeline
95         */
96         void SetVTKImage(vtkImageData* img);
97
98         /*
99         *       Get the vtkImageData from the itk image
100         */
101         vtkImageData* GetOutputVTKImage();
102
103
104         void SetITKImage(InputImagePointerType itkimage);
105         /*
106         *
107         */
108         InputImagePointerType GetOutputITKImage() ;
109
110 //------------------------------------------------------------------------------------------------------------
111 // Attributes
112 //------------------------------------------------------------------------------------------------------------
113 protected:
114         /**
115         ** Default constructor, allocates the vtkImageExport and itkImageImport
116         **      Connects the pipelines and set them ready to be use
117         **/
118         ITKToVTKImageImport();
119         ~ITKToVTKImageImport();
120
121
122 private:
123
124
125         vtkImageData* m_VTKImage;
126
127         InputImagePointerType m_ITKImage;
128
129         /*
130         *       Pointer to vtkImageExport
131         */
132         vtkImageExport * vtkimageexport;
133         /*
134         *       itk::VTKImageImport pointer
135         */
136         ImageImportPointer imageimportpointer;
137         /*
138         *       Pointer to vtkImageExport
139         */
140         vtkImageImport * vtkimageimport;
141         /*
142         *       Pointer to Export the itk image into vtk
143         */
144         ImageExportPointer imageexportpointer;
145 };
146
147 }
148
149 #ifndef ITK_MANUAL_INSTANTIATION
150 #include "itktovtkimageimport.txx"
151 #endif
152
153
154 #endif