]> Creatis software - creaImageIO.git/blob - src/itkImageToVTKImageFilter.txx
c74c9cf8646dfe674e7b70a4bec9046c2b48b70e
[creaImageIO.git] / src / itkImageToVTKImageFilter.txx
1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkImageToVTKImageFilter.txx,v $
5   Language:  C++
6   Date:      $Date: 2011/04/27 19:12:20 $
7   Version:   $Revision: 1.1 $
8
9   Copyright (c) 2002 Insight Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 #ifndef _itkImageToVTKImageFilter_txx
18 #define _itkImageToVTKImageFilter_txx
19
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     {
66     m_Importer->Delete();
67     m_Importer = 0;
68     }
69 }
70
71
72
73 /**
74  * Set an itk::Image as input 
75  */
76 template <class TInputImage>
77 void
78 ImageToVTKImageFilter<TInputImage>
79 ::SetInput( const InputImageType * inputImage )
80 {
81   m_Exporter->SetInput( inputImage );
82 }
83
84
85
86 /**
87  * Get a vtkImage as output
88  */
89 template <class TInputImage>
90 vtkImageData *
91 ImageToVTKImageFilter<TInputImage>
92 ::GetOutput() const
93 {
94   return m_Importer->GetOutput();
95 }
96
97
98
99
100 /**
101  * Get the importer filter
102  */
103 template <class TInputImage>
104 vtkImageImport *
105 ImageToVTKImageFilter<TInputImage>
106 ::GetImporter() const
107 {
108   return m_Importer;
109 }
110
111
112
113 /**
114  * Get the exporter filter
115  */
116 template <class TInputImage>
117 typename ImageToVTKImageFilter<TInputImage>::ExporterFilterType *
118 ImageToVTKImageFilter<TInputImage>
119 ::GetExporter() const
120 {
121   return m_Exporter.GetPointer();
122 }
123
124
125
126 /**
127  * Delegate the Update to the importer
128  */
129 template <class TInputImage>
130 void
131 ImageToVTKImageFilter<TInputImage>
132 ::Update()
133 {
134   m_Importer->Update();
135 }
136
137
138
139
140
141 } // end namespace itk
142
143 #endif
144