]> Creatis software - bbtk.git/blob - packages/itkvtk/src/itkImageToVTKImageFilter.txx
#3121 BBTK Bug New Normal - branch changestoITK3and4
[bbtk.git] / packages / itkvtk / src / itkImageToVTKImageFilter.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: itkImageToVTKImageFilter.txx,v $
32   Language:  C++
33   Date:      $Date: 2012/11/16 08:50:49 $
34   Version:   $Revision: 1.2 $
35
36
37 =========================================================================*/
38 #ifndef _itkImageToVTKImageFilter_txx
39 #define _itkImageToVTKImageFilter_txx
40
41 #include "itkImageToVTKImageFilter.h"
42
43 namespace itk
44 {
45
46 /**
47  * Constructor
48  */
49 template <class TInputImage>
50 ImageToVTKImageFilter<TInputImage>
51 ::ImageToVTKImageFilter()
52 {
53
54   m_Importer = vtkImageImport::New();
55
56   m_Exporter = ExporterFilterType::New();
57
58   m_Importer->SetUpdateInformationCallback(m_Exporter->GetUpdateInformationCallback());
59   m_Importer->SetPipelineModifiedCallback(m_Exporter->GetPipelineModifiedCallback());
60   m_Importer->SetWholeExtentCallback(m_Exporter->GetWholeExtentCallback());
61   m_Importer->SetSpacingCallback(m_Exporter->GetSpacingCallback());
62   m_Importer->SetOriginCallback(m_Exporter->GetOriginCallback());
63   m_Importer->SetScalarTypeCallback(m_Exporter->GetScalarTypeCallback());
64   m_Importer->SetNumberOfComponentsCallback(m_Exporter->GetNumberOfComponentsCallback());
65   m_Importer->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback());
66   m_Importer->SetUpdateDataCallback(m_Exporter->GetUpdateDataCallback());
67   m_Importer->SetDataExtentCallback(m_Exporter->GetDataExtentCallback());
68   m_Importer->SetBufferPointerCallback(m_Exporter->GetBufferPointerCallback());
69   m_Importer->SetCallbackUserData(m_Exporter->GetCallbackUserData());
70
71 }
72
73
74 /**
75  * Destructor
76  */
77 template <class TInputImage>
78 ImageToVTKImageFilter<TInputImage>
79 ::~ImageToVTKImageFilter()
80 {
81   if( m_Importer )
82     {
83     m_Importer->Delete();
84     m_Importer = 0;
85     }
86 }
87
88
89
90 /**
91  * Set an itk::Image as input 
92  */
93 template <class TInputImage>
94 void
95 ImageToVTKImageFilter<TInputImage>
96 ::SetInput( const InputImageType * inputImage )
97 {
98   m_Exporter->SetInput( inputImage );
99 }
100
101
102
103 /**
104  * Get a vtkImage as output
105  */
106 template <class TInputImage>
107 vtkImageData *
108 ImageToVTKImageFilter<TInputImage>
109 ::GetOutput() const
110 {
111   return m_Importer->GetOutput();
112 }
113
114
115
116
117 /**
118  * Get the importer filter
119  */
120 template <class TInputImage>
121 vtkImageImport *
122 ImageToVTKImageFilter<TInputImage>
123 ::GetImporter() const
124 {
125   return m_Importer;
126 }
127
128
129
130 /**
131  * Get the exporter filter
132  */
133 template <class TInputImage>
134 typename ImageToVTKImageFilter<TInputImage>::ExporterFilterType *
135 ImageToVTKImageFilter<TInputImage>
136 ::GetExporter() const
137 {
138   return m_Exporter.GetPointer();
139 }
140
141
142
143 /**
144  * Delegate the Update to the importer
145  */
146 template <class TInputImage>
147 void
148 ImageToVTKImageFilter<TInputImage>
149 ::Update()
150 {
151   m_Importer->Update();
152 }
153
154
155
156
157
158 } // end namespace itk
159
160 #endif
161