| 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_hxx |
| 20 |
#define itkVTKImageToImageFilter_hxx |
| 21 |
|
| 22 |
|
| 23 |
#include "vtkVersion.h" |
| 24 |
|
| 25 |
namespace itk |
| 26 |
{ |
| 27 |
|
| 28 |
template <typename TOutputImage> |
| 29 |
VTKImageToImageFilter<TOutputImage>::VTKImageToImageFilter() |
| 30 |
{ |
| 31 |
|
| 32 |
m_Exporter = vtkImageExport::New(); |
| 33 |
|
| 34 |
this->SetUpdateInformationCallback(m_Exporter->GetUpdateInformationCallback()); |
| 35 |
this->SetPipelineModifiedCallback(m_Exporter->GetPipelineModifiedCallback()); |
| 36 |
this->SetWholeExtentCallback(m_Exporter->GetWholeExtentCallback()); |
| 37 |
this->SetSpacingCallback(m_Exporter->GetSpacingCallback()); |
| 38 |
this->SetOriginCallback(m_Exporter->GetOriginCallback()); |
| 39 |
#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 90) |
| 40 |
this->SetDirectionCallback(m_Exporter->GetDirectionCallback()); |
| 41 |
#endif |
| 42 |
this->SetScalarTypeCallback(m_Exporter->GetScalarTypeCallback()); |
| 43 |
this->SetNumberOfComponentsCallback(m_Exporter->GetNumberOfComponentsCallback()); |
| 44 |
this->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback()); |
| 45 |
this->SetUpdateDataCallback(m_Exporter->GetUpdateDataCallback()); |
| 46 |
this->SetDataExtentCallback(m_Exporter->GetDataExtentCallback()); |
| 47 |
this->SetBufferPointerCallback(m_Exporter->GetBufferPointerCallback()); |
| 48 |
this->SetCallbackUserData(m_Exporter->GetCallbackUserData()); |
| 49 |
} |
| 50 |
|
| 51 |
template <typename TOutputImage> |
| 52 |
VTKImageToImageFilter<TOutputImage>::~VTKImageToImageFilter() |
| 53 |
{ |
| 54 |
if (m_Exporter) |
| 55 |
{ |
| 56 |
m_Exporter->Delete(); |
| 57 |
m_Exporter = nullptr; |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
template <typename TOutputImage> |
| 62 |
void |
| 63 |
VTKImageToImageFilter<TOutputImage>::SetInput(vtkImageData * inputImage) |
| 64 |
{ |
| 65 |
#if VTK_MAJOR_VERSION <= 5 |
| 66 |
m_Exporter->SetInput(inputImage); |
| 67 |
#else |
| 68 |
m_Exporter->SetInputData(inputImage); |
| 69 |
#endif |
| 70 |
} |
| 71 |
|
| 72 |
template <typename TOutputImage> |
| 73 |
vtkImageExport * |
| 74 |
VTKImageToImageFilter<TOutputImage>::GetExporter() const |
| 75 |
{ |
| 76 |
return m_Exporter; |
| 77 |
} |
| 78 |
|
| 79 |
template <typename TOutputImage> |
| 80 |
auto |
| 81 |
VTKImageToImageFilter<TOutputImage>::GetImporter() const -> const Superclass * |
| 82 |
{ |
| 83 |
return this; |
| 84 |
} |
| 85 |
|
| 86 |
} // end namespace itk |
| 87 |
|
| 88 |
#endif |