]> Creatis software - cpPlugins.git/blob - lib/cpInstances/itkImageToVTKImageFilter.h
Cast image filter added. ROI filter modified.
[cpPlugins.git] / lib / cpInstances / itkImageToVTKImageFilter.h
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 #ifndef itkImageToVTKImageFilter_h
19 #define itkImageToVTKImageFilter_h
20
21 #include "itkVTKImageExport.h"
22 #include "vtkImageImport.h"
23 #include "vtkImageData.h"
24
25 namespace itk
26 {
27
28 /** \class ImageToVTKImageFilter
29  * \brief Converts an ITK image into a VTK image and plugs a
30  *  itk data pipeline to a VTK datapipeline.
31  *
32  *  This class puts together an itkVTKImageExporter and a vtkImageImporter.
33  *  It takes care of the details related to the connection of ITK and VTK
34  *  pipelines. The User will perceive this filter as an adaptor to which
35  *  an itk::Image can be plugged as input and a vtkImage is produced as
36  *  output.
37  *
38  * \ingroup   ITKVtkGlue
39  *
40  * \wiki
41  * \wikiexample{IO/ImageToVTKImageFilter,Display an ITK image}
42  * \wikiexample{IO/itkVtkImageConvertDICOM,Uses a custom user matrix to align the image with DICOM physical space}
43  * \endwiki
44  */
45 template <typename TInputImage >
46 class ImageToVTKImageFilter : public ProcessObject
47 {
48 public:
49   /** Standard class typedefs. */
50   typedef ImageToVTKImageFilter     Self;
51   typedef ProcessObject             Superclass;
52   typedef SmartPointer<Self>        Pointer;
53   typedef SmartPointer<const Self>  ConstPointer;
54
55   /** Method for creation through the object factory. */
56   itkNewMacro(Self);
57
58   /** Run-time type information (and related methods). */
59   itkTypeMacro(ImageToVTKImageFilter, ProcessObject);
60
61   /** Some typedefs. */
62   typedef TInputImage                            InputImageType;
63   typedef typename InputImageType::ConstPointer  InputImagePointer;
64
65   typedef VTKImageExport< InputImageType>        ExporterFilterType;
66   typedef typename ExporterFilterType::Pointer   ExporterFilterPointer;
67
68   /** Get the output in the form of a vtkImage.
69       This call is delegated to the internal vtkImageImporter filter  */
70   vtkImageData *  GetOutput() const;
71
72   /** Set the input in the form of an itk::Image */
73   using Superclass::SetInput;
74   void SetInput( const InputImageType * );
75   InputImageType * GetInput();
76
77   /** Return the internal VTK image importer filter.
78       This is intended to facilitate users the access
79       to methods in the importer */
80   vtkImageImport * GetImporter() const;
81
82   /** Return the internal ITK image exporter filter.
83       This is intended to facilitate users the access
84       to methods in the exporter */
85   ExporterFilterType * GetExporter() const;
86
87   /** This call delegates the update to the importer */
88   virtual void Update() ITK_OVERRIDE;
89
90   /** This call delegates the update to the importer */
91   virtual void UpdateLargestPossibleRegion() ITK_OVERRIDE;
92
93 protected:
94   ImageToVTKImageFilter();
95   virtual ~ImageToVTKImageFilter();
96
97 private:
98   ImageToVTKImageFilter(const Self&) ITK_DELETE_FUNCTION;
99   void operator=(const Self&) ITK_DELETE_FUNCTION;
100
101   ExporterFilterPointer       m_Exporter;
102   vtkImageImport *            m_Importer;
103 };
104
105 } // end namespace itk
106
107 #ifndef ITK_MANUAL_INSTANTIATION
108 #include "itkImageToVTKImageFilter.hxx"
109 #endif
110
111 #endif