| 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_hxx |
| 19 |
#define itkImageToVTKImageFilter_hxx |
| 20 |
|
| 21 |
|
| 22 |
namespace itk |
| 23 |
{ |
| 24 |
|
| 25 |
template <typename TInputImage> |
| 26 |
ImageToVTKImageFilter<TInputImage>::ImageToVTKImageFilter() |
| 27 |
{ |
| 28 |
m_Importer = vtkImageImport::New(); |
| 29 |
m_Exporter = ExporterFilterType::New(); |
| 30 |
|
| 31 |
m_Importer->SetUpdateInformationCallback(m_Exporter->GetUpdateInformationCallback()); |
| 32 |
m_Importer->SetPipelineModifiedCallback(m_Exporter->GetPipelineModifiedCallback()); |
| 33 |
m_Importer->SetWholeExtentCallback(m_Exporter->GetWholeExtentCallback()); |
| 34 |
m_Importer->SetSpacingCallback(m_Exporter->GetSpacingCallback()); |
| 35 |
m_Importer->SetOriginCallback(m_Exporter->GetOriginCallback()); |
| 36 |
#if VTK_MAJOR_VERSION >= 9 || (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 90) |
| 37 |
m_Importer->SetDirectionCallback(m_Exporter->GetDirectionCallback()); |
| 38 |
#endif |
| 39 |
m_Importer->SetScalarTypeCallback(m_Exporter->GetScalarTypeCallback()); |
| 40 |
m_Importer->SetNumberOfComponentsCallback(m_Exporter->GetNumberOfComponentsCallback()); |
| 41 |
m_Importer->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback()); |
| 42 |
m_Importer->SetUpdateDataCallback(m_Exporter->GetUpdateDataCallback()); |
| 43 |
m_Importer->SetDataExtentCallback(m_Exporter->GetDataExtentCallback()); |
| 44 |
m_Importer->SetBufferPointerCallback(m_Exporter->GetBufferPointerCallback()); |
| 45 |
m_Importer->SetCallbackUserData(m_Exporter->GetCallbackUserData()); |
| 46 |
} |
| 47 |
|
| 48 |
template <typename TInputImage> |
| 49 |
ImageToVTKImageFilter<TInputImage>::~ImageToVTKImageFilter() |
| 50 |
{ |
| 51 |
if (m_Importer) |
| 52 |
{ |
| 53 |
m_Importer->Delete(); |
| 54 |
m_Importer = nullptr; |
| 55 |
} |
| 56 |
} |
| 57 |
|
| 58 |
template <typename TInputImage> |
| 59 |
void |
| 60 |
ImageToVTKImageFilter<TInputImage>::SetInput(const InputImageType * inputImage) |
| 61 |
{ |
| 62 |
m_Exporter->SetInput(inputImage); |
| 63 |
} |
| 64 |
|
| 65 |
template <typename TInputImage> |
| 66 |
auto |
| 67 |
ImageToVTKImageFilter<TInputImage>::GetInput() -> InputImageType * |
| 68 |
{ |
| 69 |
return m_Exporter->GetInput(); |
| 70 |
} |
| 71 |
|
| 72 |
template <typename TInputImage> |
| 73 |
vtkImageData * |
| 74 |
ImageToVTKImageFilter<TInputImage>::GetOutput() const |
| 75 |
{ |
| 76 |
return m_Importer->GetOutput(); |
| 77 |
} |
| 78 |
|
| 79 |
template <typename TInputImage> |
| 80 |
vtkImageImport * |
| 81 |
ImageToVTKImageFilter<TInputImage>::GetImporter() const |
| 82 |
{ |
| 83 |
return m_Importer; |
| 84 |
} |
| 85 |
|
| 86 |
template <typename TInputImage> |
| 87 |
auto |
| 88 |
ImageToVTKImageFilter<TInputImage>::GetExporter() const -> ExporterFilterType * |
| 89 |
{ |
| 90 |
return m_Exporter.GetPointer(); |
| 91 |
} |
| 92 |
|
| 93 |
template <typename TInputImage> |
| 94 |
void |
| 95 |
ImageToVTKImageFilter<TInputImage>::Update() |
| 96 |
{ |
| 97 |
m_Importer->Update(); |
| 98 |
} |
| 99 |
|
| 100 |
template <typename TInputImage> |
| 101 |
void |
| 102 |
ImageToVTKImageFilter<TInputImage>::UpdateLargestPossibleRegion() |
| 103 |
{ |
| 104 |
m_Importer->UpdateWholeExtent(); |
| 105 |
} |
| 106 |
|
| 107 |
} // end namespace itk |
| 108 |
|
| 109 |
#endif |