]> Creatis software - cpPlugins.git/blob - lib/cpInstances/itkImageToVTKImageFilter.hxx
e134b3f4b9574895b7d37b5a7d906b14c29c88a9
[cpPlugins.git] / lib / cpInstances / itkImageToVTKImageFilter.hxx
1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkImageToVTKImageFilter_hxx
19 #define itkImageToVTKImageFilter_hxx
20
21 #include "itkImageToVTKImageFilter.h"
22
23 namespace itk
24 {
25
26 /**
27  * Constructor
28  */
29 template <typename TInputImage>
30 ImageToVTKImageFilter<TInputImage>
31 ::ImageToVTKImageFilter()
32 {
33   m_Importer = vtkImageImport::New();
34   m_Exporter = ExporterFilterType::New();
35
36   m_Importer->SetUpdateInformationCallback(m_Exporter->GetUpdateInformationCallback());
37   m_Importer->SetPipelineModifiedCallback(m_Exporter->GetPipelineModifiedCallback());
38   m_Importer->SetWholeExtentCallback(m_Exporter->GetWholeExtentCallback());
39   m_Importer->SetSpacingCallback(m_Exporter->GetSpacingCallback());
40   m_Importer->SetOriginCallback(m_Exporter->GetOriginCallback());
41   m_Importer->SetScalarTypeCallback(m_Exporter->GetScalarTypeCallback());
42   m_Importer->SetNumberOfComponentsCallback(m_Exporter->GetNumberOfComponentsCallback());
43   m_Importer->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback());
44   m_Importer->SetUpdateDataCallback(m_Exporter->GetUpdateDataCallback());
45   m_Importer->SetDataExtentCallback(m_Exporter->GetDataExtentCallback());
46   m_Importer->SetBufferPointerCallback(m_Exporter->GetBufferPointerCallback());
47   m_Importer->SetCallbackUserData(m_Exporter->GetCallbackUserData());
48
49 }
50
51 /**
52  * Destructor
53  */
54 template <typename TInputImage>
55 ImageToVTKImageFilter<TInputImage>
56 ::~ImageToVTKImageFilter()
57 {
58   if( m_Importer )
59     {
60     m_Importer->Delete();
61     m_Importer = 0;
62     }
63 }
64
65 /**
66  * Set an itk::Image as input
67  */
68 template <typename TInputImage>
69 void
70 ImageToVTKImageFilter<TInputImage>
71 ::SetInput( const InputImageType * inputImage )
72 {
73   m_Exporter->SetInput( inputImage );
74 }
75
76 template <typename TInputImage>
77 typename ImageToVTKImageFilter<TInputImage>::InputImageType *
78 ImageToVTKImageFilter<TInputImage>
79 ::GetInput()
80 {
81   return m_Exporter->GetInput();
82 }
83
84 /**
85  * Get a vtkImage as output
86  */
87 template <typename TInputImage>
88 vtkImageData *
89 ImageToVTKImageFilter<TInputImage>
90 ::GetOutput() const
91 {
92   return m_Importer->GetOutput();
93 }
94
95 /**
96  * Get the importer filter
97  */
98 template <typename TInputImage>
99 vtkImageImport *
100 ImageToVTKImageFilter<TInputImage>
101 ::GetImporter() const
102 {
103   return m_Importer;
104 }
105
106 /**
107  * Get the exporter filter
108  */
109 template <typename TInputImage>
110 typename ImageToVTKImageFilter<TInputImage>::ExporterFilterType *
111 ImageToVTKImageFilter<TInputImage>
112 ::GetExporter() const
113 {
114   return m_Exporter.GetPointer();
115 }
116
117 /**
118  * Delegate the Update to the importer
119  */
120 template <typename TInputImage>
121 void
122 ImageToVTKImageFilter<TInputImage>
123 ::Update()
124 {
125   m_Importer->Update();
126 }
127
128 /**
129  * Delegate the UpdateLargestPossibleRegion to the importer
130  */
131 template <typename TInputImage>
132 void
133 ImageToVTKImageFilter<TInputImage>
134 ::UpdateLargestPossibleRegion()
135 {
136   m_Importer->UpdateWholeExtent();
137 }
138
139 } // end namespace itk
140
141 #endif