creaImageIO_lib
itkImageToVTKImageFilter.txx
Go to the documentation of this file.
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/15 12:45:28 $
34  Version: $Revision: 1.2 $
35 
36  Copyright (c) 2002 Insight Consortium. All rights reserved.
37  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
38 
39  This software is distributed WITHOUT ANY WARRANTY; without even
40  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
41  PURPOSE. See the above copyright notices for more information.
42 
43 =========================================================================*/
44 #ifndef _itkImageToVTKImageFilter_txx
45 #define _itkImageToVTKImageFilter_txx
46 
48 
49 namespace itk
50 {
51 
52 
53 
57 template <class TInputImage>
60 {
61 
62  m_Importer = vtkImageImport::New();
63 
64  m_Exporter = ExporterFilterType::New();
65 
66  m_Importer->SetUpdateInformationCallback(m_Exporter->GetUpdateInformationCallback());
67  m_Importer->SetPipelineModifiedCallback(m_Exporter->GetPipelineModifiedCallback());
68  m_Importer->SetWholeExtentCallback(m_Exporter->GetWholeExtentCallback());
69  m_Importer->SetSpacingCallback(m_Exporter->GetSpacingCallback());
70  m_Importer->SetOriginCallback(m_Exporter->GetOriginCallback());
71  m_Importer->SetScalarTypeCallback(m_Exporter->GetScalarTypeCallback());
72  m_Importer->SetNumberOfComponentsCallback(m_Exporter->GetNumberOfComponentsCallback());
73  m_Importer->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback());
74  m_Importer->SetUpdateDataCallback(m_Exporter->GetUpdateDataCallback());
75  m_Importer->SetDataExtentCallback(m_Exporter->GetDataExtentCallback());
76  m_Importer->SetBufferPointerCallback(m_Exporter->GetBufferPointerCallback());
77  m_Importer->SetCallbackUserData(m_Exporter->GetCallbackUserData());
78 
79 }
80 
81 
82 
83 
87 template <class TInputImage>
90 {
91  if( m_Importer )
92  {
93  m_Importer->Delete();
94  m_Importer = 0;
95  }
96 }
97 
98 
99 
103 template <class TInputImage>
104 void
106 ::SetInput( const InputImageType * inputImage )
107 {
108  m_Exporter->SetInput( inputImage );
109 }
110 
111 
112 
116 template <class TInputImage>
117 vtkImageData *
119 ::GetOutput() const
120 {
121  return m_Importer->GetOutput();
122 }
123 
124 
125 
126 
130 template <class TInputImage>
131 vtkImageImport *
134 {
135  return m_Importer;
136 }
137 
138 
139 
143 template <class TInputImage>
147 {
148  return m_Exporter.GetPointer();
149 }
150 
151 
152 
156 template <class TInputImage>
157 void
160 {
161  m_Importer->Update();
162 }
163 
164 
165 
166 
167 
168 } // end namespace itk
169 
170 #endif
171