| 1 |
/*========================================================================= |
| 2 |
* |
| 3 |
* Copyright NumFOCUS |
| 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 |
* https://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 |
/** |
| 29 |
* \class ImageToVTKImageFilter |
| 30 |
* \brief Converts an ITK Image into a VTK image and plugs a |
| 31 |
* ITK data pipeline to a VTK data pipeline. |
| 32 |
* |
| 33 |
* This class puts together VTKImageExport and vtkImageImport objects. |
| 34 |
* It takes care of the details related to the connection of ITK and VTK |
| 35 |
* pipelines. The User will perceive this filter as an adaptor to which |
| 36 |
* an itk::Image can be plugged as input and a vtkImage is produced as |
| 37 |
* output. |
| 38 |
* |
| 39 |
* \ingroup ITKVtkGlue |
| 40 |
* |
| 41 |
* \sphinx |
| 42 |
* \sphinxexample{Bridge/VtkGlue/ConvertAnitkImageTovtkImageData,Convert an itk::Image to vtkImageData in a pipeline} |
| 43 |
* \sphinxexample{Bridge/VtkGlue/ConvertRGBvtkImageDataToAnitkImage,Convert RGB vtkImageData to an itk::Image} |
| 44 |
* \endsphinx |
| 45 |
*/ |
| 46 |
template <typename TInputImage> |
| 47 |
class ITK_TEMPLATE_EXPORT ImageToVTKImageFilter : public ProcessObject |
| 48 |
{ |
| 49 |
public: |
| 50 |
ITK_DISALLOW_COPY_AND_MOVE(ImageToVTKImageFilter); |
| 51 |
|
| 52 |
/** Standard class type aliases. */ |
| 53 |
using Self = ImageToVTKImageFilter; |
| 54 |
using Superclass = ProcessObject; |
| 55 |
using Pointer = SmartPointer<Self>; |
| 56 |
using ConstPointer = SmartPointer<const Self>; |
| 57 |
|
| 58 |
/** Method for creation through the object factory. */ |
| 59 |
itkNewMacro(Self); |
| 60 |
|
| 61 |
/** \see LightObject::GetNameOfClass() */ |
| 62 |
itkOverrideGetNameOfClassMacro(ImageToVTKImageFilter); |
| 63 |
|
| 64 |
/** Some type alias. */ |
| 65 |
using InputImageType = TInputImage; |
| 66 |
using InputImagePointer = typename InputImageType::ConstPointer; |
| 67 |
|
| 68 |
using ExporterFilterType = VTKImageExport<InputImageType>; |
| 69 |
using ExporterFilterPointer = typename ExporterFilterType::Pointer; |
| 70 |
|
| 71 |
/** Get the output in the form of a vtkImage. |
| 72 |
* |
| 73 |
* This call is delegated to the internal vtkImageImport filter. |
| 74 |
*/ |
| 75 |
vtkImageData * |
| 76 |
GetOutput() const; |
| 77 |
|
| 78 |
/** Set the input in the form of an itk::Image */ |
| 79 |
using Superclass::SetInput; |
| 80 |
void |
| 81 |
SetInput(const InputImageType *); |
| 82 |
InputImageType * |
| 83 |
GetInput(); |
| 84 |
|
| 85 |
/** Return the internal VTK image importer filter. |
| 86 |
* |
| 87 |
* Intended to facilitate users the access to methods in the importer. |
| 88 |
*/ |
| 89 |
vtkImageImport * |
| 90 |
GetImporter() const; |
| 91 |
|
| 92 |
/** Return the internal ITK image exporter filter. |
| 93 |
* |
| 94 |
* Intended to facilitate users the access to methods in the exporter. |
| 95 |
*/ |
| 96 |
ExporterFilterType * |
| 97 |
GetExporter() const; |
| 98 |
|
| 99 |
/** This call delegates the update to the importer. */ |
| 100 |
void |
| 101 |
Update() override; |
| 102 |
|
| 103 |
/** This call delegates the update to the importer. */ |
| 104 |
void |
| 105 |
UpdateLargestPossibleRegion() override; |
| 106 |
|
| 107 |
protected: |
| 108 |
ImageToVTKImageFilter(); |
| 109 |
~ImageToVTKImageFilter() override; |
| 110 |
|
| 111 |
private: |
| 112 |
ExporterFilterPointer m_Exporter{}; |
| 113 |
vtkImageImport * m_Importer{}; |
| 114 |
}; |
| 115 |
|
| 116 |
} // end namespace itk |
| 117 |
|
| 118 |
#ifndef ITK_MANUAL_INSTANTIATION |
| 119 |
# include "itkImageToVTKImageFilter.hxx" |
| 120 |
#endif |
| 121 |
|
| 122 |
#endif |