]> Creatis software - bbtk.git/blob - packages/itkvtk/src/itkVTKImageToImageFilter.txx
#3107 BBTK Bug New Normal - branch vtk7itk4 compilation with vtk7
[bbtk.git] / packages / itkvtk / src / itkVTKImageToImageFilter.txx
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29
30   Program:   Insight Segmentation & Registration Toolkit
31   Module:    $RCSfile: itkVTKImageToImageFilter.txx,v $
32   Language:  C++
33   Date:      $Date: 2012/11/16 08:50:49 $
34   Version:   $Revision: 1.2 $
35
36
37 =========================================================================*/
38 #ifndef _itkVTKImageToImageFilter_txx
39 #define _itkVTKImageToImageFilter_txx
40
41 #include "itkVTKImageToImageFilter.h"
42
43 namespace itk
44 {
45
46
47
48 /**
49  * Constructor
50  */
51 template <class TOutputImage>
52 VTKImageToImageFilter<TOutputImage>
53 ::VTKImageToImageFilter()
54 {
55
56   m_Exporter = vtkImageExport::New();
57
58   m_Importer = ImporterFilterType::New();
59
60   m_Importer->SetUpdateInformationCallback( m_Exporter->GetUpdateInformationCallback());
61   m_Importer->SetPipelineModifiedCallback( m_Exporter->GetPipelineModifiedCallback());
62   m_Importer->SetWholeExtentCallback( m_Exporter->GetWholeExtentCallback());
63   m_Importer->SetSpacingCallback( m_Exporter->GetSpacingCallback());
64   m_Importer->SetOriginCallback( m_Exporter->GetOriginCallback());
65   m_Importer->SetScalarTypeCallback( m_Exporter->GetScalarTypeCallback());
66   m_Importer->SetNumberOfComponentsCallback( m_Exporter->GetNumberOfComponentsCallback());
67   m_Importer->SetPropagateUpdateExtentCallback( m_Exporter->GetPropagateUpdateExtentCallback());
68   m_Importer->SetUpdateDataCallback( m_Exporter->GetUpdateDataCallback());
69   m_Importer->SetDataExtentCallback( m_Exporter->GetDataExtentCallback());
70   m_Importer->SetBufferPointerCallback( m_Exporter->GetBufferPointerCallback());
71   m_Importer->SetCallbackUserData( m_Exporter->GetCallbackUserData());
72
73 }
74
75
76
77
78 /**
79  * Destructor
80  */
81 template <class TOutputImage>
82 VTKImageToImageFilter<TOutputImage>
83 ::~VTKImageToImageFilter()
84 {
85   if( m_Exporter )
86     {
87     m_Exporter->Delete();
88     m_Exporter = 0;
89     }
90 }
91
92
93
94 /**
95  * Set a vtkImageData as input 
96  */
97 template <class TOutputImage>
98 void
99 VTKImageToImageFilter<TOutputImage>
100 ::SetInput( vtkImageData * inputImage )
101 {
102 //EED 2017-01-01 Migration VTK7
103 #if VTK_MAJOR_VERSION <= 5
104   m_Exporter->SetInput( inputImage );
105 #else
106   m_Exporter->SetInputData( inputImage );
107 #endif
108 }
109
110
111
112 /**
113  * Get an itk::Image as output
114  */
115 template <class TOutputImage>
116 const typename VTKImageToImageFilter<TOutputImage>::OutputImageType *
117 VTKImageToImageFilter<TOutputImage>
118 ::GetOutput() const
119 {
120   return m_Importer->GetOutput();
121 }
122
123
124
125
126 /**
127  * Get the exporter filter
128  */
129 template <class TOutputImage>
130 vtkImageExport *
131 VTKImageToImageFilter<TOutputImage>
132 ::GetExporter() const
133 {
134   return m_Exporter;
135 }
136
137
138
139 /**
140  * Get the importer filter
141  */
142 template <class TOutputImage>
143 typename VTKImageToImageFilter<TOutputImage>::ImporterFilterType *
144 VTKImageToImageFilter<TOutputImage>
145 ::GetImporter() const
146 {
147   return m_Importer;
148 }
149
150
151
152
153 /**
154  * Delegate the Update to the importer
155  */
156 template <class TOutputImage>
157 void
158 VTKImageToImageFilter<TOutputImage>
159 ::Update()
160 {
161   m_Importer->Update();
162 }
163
164
165
166
167 } // end namespace itk
168
169 #endif
170