]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/DataObjects/itkVTKImageToImageFilter.hxx
334b02bb7700350eec040f8bd56dc0adea6459c8
[cpPlugins.git] / lib / cpPlugins / DataObjects / itkVTKImageToImageFilter.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
19 #ifndef itkVTKImageToImageFilter_hxx
20 #define itkVTKImageToImageFilter_hxx
21
22 #include "itkVTKImageToImageFilter.h"
23
24 #include "vtkVersion.h"
25
26 namespace itk
27 {
28
29 /**
30  * Constructor
31  */
32 template <typename TOutputImage>
33 VTKImageToImageFilter<TOutputImage>
34 ::VTKImageToImageFilter()
35 {
36
37   m_Exporter = vtkImageExport::New();
38
39   this->SetUpdateInformationCallback( m_Exporter->GetUpdateInformationCallback());
40   this->SetPipelineModifiedCallback( m_Exporter->GetPipelineModifiedCallback());
41   this->SetWholeExtentCallback( m_Exporter->GetWholeExtentCallback());
42   this->SetSpacingCallback( m_Exporter->GetSpacingCallback());
43   this->SetOriginCallback( m_Exporter->GetOriginCallback());
44   this->SetScalarTypeCallback( m_Exporter->GetScalarTypeCallback());
45   this->SetNumberOfComponentsCallback( m_Exporter->GetNumberOfComponentsCallback());
46   this->SetPropagateUpdateExtentCallback( m_Exporter->GetPropagateUpdateExtentCallback());
47   this->SetUpdateDataCallback( m_Exporter->GetUpdateDataCallback());
48   this->SetDataExtentCallback( m_Exporter->GetDataExtentCallback());
49   this->SetBufferPointerCallback( m_Exporter->GetBufferPointerCallback());
50   this->SetCallbackUserData( m_Exporter->GetCallbackUserData());
51
52 }
53
54 /**
55  * Destructor
56  */
57 template <typename TOutputImage>
58 VTKImageToImageFilter<TOutputImage>
59 ::~VTKImageToImageFilter()
60 {
61   if( m_Exporter )
62     {
63     m_Exporter->Delete();
64     m_Exporter = 0;
65     }
66 }
67
68 /**
69  * Set a vtkImageData as input
70  */
71 template <typename TOutputImage>
72 void
73 VTKImageToImageFilter<TOutputImage>
74 ::SetInput( vtkImageData * inputImage )
75 {
76 #if VTK_MAJOR_VERSION <= 5
77   m_Exporter->SetInput( inputImage );
78 #else
79   m_Exporter->SetInputData( inputImage );
80 #endif
81 }
82
83 /**
84  * Get the exporter filter
85  */
86 template <typename TOutputImage>
87 vtkImageExport *
88 VTKImageToImageFilter<TOutputImage>
89 ::GetExporter() const
90 {
91   return m_Exporter;
92 }
93
94 /**
95  * Get the importer filter
96  */
97 template <typename TOutputImage>
98 const typename VTKImageToImageFilter<TOutputImage>::Superclass *
99 VTKImageToImageFilter<TOutputImage>
100 ::GetImporter() const
101 {
102   return this;
103 }
104
105 } // end namespace itk
106
107 #endif