| 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 |
|
| 19 |
#ifndef itkVTKImageToImageFilter_h |
| 20 |
#define itkVTKImageToImageFilter_h |
| 21 |
|
| 22 |
#include "itkVTKImageImport.h" |
| 23 |
#include "vtkImageExport.h" |
| 24 |
#include "vtkImageData.h" |
| 25 |
#include "vtkSmartPointer.h" |
| 26 |
|
| 27 |
#ifndef vtkFloatingPointType |
| 28 |
# define vtkFloatingPointType float |
| 29 |
#endif |
| 30 |
|
| 31 |
namespace itk |
| 32 |
{ |
| 33 |
|
| 34 |
/** |
| 35 |
* \class VTKImageToImageFilter |
| 36 |
* \brief Converts a VTK image into an ITK image and plugs a |
| 37 |
* VTK data pipeline to an ITK datapipeline. |
| 38 |
* |
| 39 |
* This class puts together an itk::VTKImageImport and a vtk::ImageExport. |
| 40 |
* It takes care of the details related to the connection of ITK and VTK |
| 41 |
* pipelines. The User will perceive this filter as an adaptor to which |
| 42 |
* a vtkImageData can be plugged as input and an itk::Image is produced as |
| 43 |
* output. |
| 44 |
* |
| 45 |
* \ingroup ITKVtkGlue |
| 46 |
* \sphinx |
| 47 |
* \sphinxexample{Bridge/VtkGlue/VTKImageToITKImage,VTK Image To ITK Image} |
| 48 |
* \endsphinx |
| 49 |
*/ |
| 50 |
template <typename TOutputImage> |
| 51 |
class ITK_TEMPLATE_EXPORT VTKImageToImageFilter : public VTKImageImport<TOutputImage> |
| 52 |
{ |
| 53 |
public: |
| 54 |
ITK_DISALLOW_COPY_AND_MOVE(VTKImageToImageFilter); |
| 55 |
|
| 56 |
/** Standard class type aliases. */ |
| 57 |
using Self = VTKImageToImageFilter; |
| 58 |
using Superclass = VTKImageImport<TOutputImage>; |
| 59 |
using Pointer = SmartPointer<Self>; |
| 60 |
using ConstPointer = SmartPointer<const Self>; |
| 61 |
|
| 62 |
/** Method for creation through the object factory. */ |
| 63 |
itkNewMacro(Self); |
| 64 |
|
| 65 |
/** \see LightObject::GetNameOfClass() */ |
| 66 |
itkOverrideGetNameOfClassMacro(VTKImageToImageFilter); |
| 67 |
|
| 68 |
/** Some type alias. */ |
| 69 |
using OutputImageType = TOutputImage; |
| 70 |
using OutputImagePointer = typename OutputImageType::ConstPointer; |
| 71 |
|
| 72 |
/** Set the input in the form of a vtkImageData. */ |
| 73 |
void |
| 74 |
SetInput(vtkImageData *); |
| 75 |
using Superclass::SetInput; |
| 76 |
|
| 77 |
/** Get the internal VTK image exporter filter. |
| 78 |
* |
| 79 |
* Intended to facilitate users the access to methods in the exporter. |
| 80 |
*/ |
| 81 |
vtkImageExport * |
| 82 |
GetExporter() const; |
| 83 |
|
| 84 |
/** Get the internal ITK image importer filter. |
| 85 |
* |
| 86 |
* Intended to facilitate users the access to methods in the importer. |
| 87 |
*/ |
| 88 |
const Superclass * |
| 89 |
GetImporter() const; |
| 90 |
|
| 91 |
protected: |
| 92 |
VTKImageToImageFilter(); |
| 93 |
~VTKImageToImageFilter() override; |
| 94 |
|
| 95 |
private: |
| 96 |
using ImageExportPointer = vtkSmartPointer<vtkImageExport>; |
| 97 |
ImageExportPointer m_Exporter{}; |
| 98 |
}; |
| 99 |
|
| 100 |
} // end namespace itk |
| 101 |
|
| 102 |
#ifndef ITK_MANUAL_INSTANTIATION |
| 103 |
# include "itkVTKImageToImageFilter.hxx" |
| 104 |
#endif |
| 105 |
|
| 106 |
#endif |