]> Creatis software - clitk.git/blob - itk/itkImageToVTKImageFilter.txx
25fcf7c5d808d48f74471bcfd8a766261f8aa898
[clitk.git] / itk / itkImageToVTKImageFilter.txx
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to:
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
18 #ifndef _itkImageToVTKImageFilter_txx
19 #define _itkImageToVTKImageFilter_txx
20 #include "itkImageToVTKImageFilter.h"
21
22 namespace itk
23 {
24
25
26
27 /**
28  * Constructor
29  */
30 template <class TInputImage>
31 ImageToVTKImageFilter<TInputImage>
32 ::ImageToVTKImageFilter()
33 {
34
35   m_Importer = vtkImageImport::New();
36
37   m_Exporter = ExporterFilterType::New();
38
39   m_Importer->SetUpdateInformationCallback(m_Exporter->GetUpdateInformationCallback());
40   m_Importer->SetPipelineModifiedCallback(m_Exporter->GetPipelineModifiedCallback());
41   m_Importer->SetWholeExtentCallback(m_Exporter->GetWholeExtentCallback());
42   m_Importer->SetSpacingCallback(m_Exporter->GetSpacingCallback());
43   m_Importer->SetOriginCallback(m_Exporter->GetOriginCallback());
44   m_Importer->SetScalarTypeCallback(m_Exporter->GetScalarTypeCallback());
45   m_Importer->SetNumberOfComponentsCallback(m_Exporter->GetNumberOfComponentsCallback());
46   m_Importer->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback());
47   m_Importer->SetUpdateDataCallback(m_Exporter->GetUpdateDataCallback());
48   m_Importer->SetDataExtentCallback(m_Exporter->GetDataExtentCallback());
49   m_Importer->SetBufferPointerCallback(m_Exporter->GetBufferPointerCallback());
50   m_Importer->SetCallbackUserData(m_Exporter->GetCallbackUserData());
51
52 }
53
54
55
56
57 /**
58  * Destructor
59  */
60 template <class TInputImage>
61 ImageToVTKImageFilter<TInputImage>
62 ::~ImageToVTKImageFilter()
63 {
64   if ( m_Importer ) {
65     m_Importer->Delete();
66     m_Importer = 0;
67   }
68   if ( m_Exporter ) {
69     m_Exporter->Delete();
70     m_Exporter = 0;
71   }
72 }
73
74
75
76 /**
77  * Set an itk::Image as input
78  */
79 template <class TInputImage>
80 void
81 ImageToVTKImageFilter<TInputImage>
82 ::SetInput( const InputImageType * inputImage )
83 {
84   m_Exporter->SetInput( inputImage );
85 }
86
87
88
89 /**
90  * Get a vtkImage as output
91  */
92 template <class TInputImage>
93 vtkImageData *
94 ImageToVTKImageFilter<TInputImage>
95 ::GetOutput() const
96 {
97   return m_Importer->GetOutput();
98 }
99
100
101
102
103 /**
104  * Get the importer filter
105  */
106 template <class TInputImage>
107 vtkImageImport *
108 ImageToVTKImageFilter<TInputImage>
109 ::GetImporter() const
110 {
111   return m_Importer;
112 }
113
114
115
116 /**
117  * Get the exporter filter
118  */
119 template <class TInputImage>
120 typename ImageToVTKImageFilter<TInputImage>::ExporterFilterType *
121 ImageToVTKImageFilter<TInputImage>
122 ::GetExporter() const
123 {
124   return m_Exporter.GetPointer();
125 }
126
127
128
129 /**
130  * Delegate the Update to the importer
131  */
132 template <class TInputImage>
133 void
134 ImageToVTKImageFilter<TInputImage>
135 ::Update()
136 {
137   m_Importer->Update();
138 }
139
140
141
142
143
144 } // end namespace itk
145
146 #endif
147