Medical Imaging Interaction Toolkit  2018.4.99-1640525a
Medical Imaging Interaction Toolkit
mitkImageToImageFilter.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkImageToImageFilter.h"
14 
16 {
17  // Modify superclass default values, can be overridden by subclasses
18  this->SetNumberOfRequiredInputs(1);
19 }
20 
22 {
23 }
24 
29 {
30  // Process object is not const-correct so the const_cast is required here
31  this->ProcessObject::SetNthInput(0, const_cast<mitk::ImageToImageFilter::InputImageType *>(input));
32 }
33 
38 {
39  if (index + 1 > this->GetNumberOfInputs())
40  {
41  this->SetNumberOfRequiredInputs(index + 1);
42  }
43  // Process object is not const-correct so the const_cast is required here
44  this->ProcessObject::SetNthInput(index, const_cast<mitk::ImageToImageFilter::InputImageType *>(image));
45 }
46 
51 {
52  if (this->GetNumberOfInputs() < 1)
53  {
54  return nullptr;
55  }
56 
57  return static_cast<mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(0));
58 }
59 
64 {
65  return static_cast<mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(idx));
66 }
67 
69 {
70  if (this->GetNumberOfInputs() < 1)
71  {
72  return nullptr;
73  }
74 
75  return static_cast<const mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(0));
76 }
77 
82 {
83  return static_cast<const mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(idx));
84 }
85 
86 //-----------------------------------------------------------------------
87 //
89 {
90  Superclass::GenerateInputRequestedRegion();
91 
92  for (unsigned int idx = 0; idx < this->GetNumberOfInputs(); ++idx)
93  {
94  if (this->GetInput(idx))
95  {
97 
98  // Use the function object RegionCopier to copy the output region
99  // to the input. The default region copier has default implementations
100  // to handle the cases where the input and output are the same
101  // dimension, the input a higher dimension than the output, and the
102  // input a lower dimension than the output.
103  InputImageRegionType inputRegion;
104  // this->CallCopyRegion(inputRegion, this->GetOutput()->GetRequestedRegion()); @FIXME ??
105  // input->SetRequestedRegion( inputRegion ); @FIXME ??
106  input->SetRequestedRegion(this->GetOutput()); // ersatz. @FIXME ??
107  }
108  }
109 }
110 
111 void mitk::ImageToImageFilter::PrintSelf(std::ostream &os, itk::Indent indent) const
112 {
113  Superclass::PrintSelf(os, indent);
114 }
void PrintSelf(std::ostream &os, itk::Indent indent) const override
SlicedData::RegionType InputImageRegionType
virtual void SetInput(const InputImageType *image)
Image class for storing images.
Definition: mitkImage.h:72
mitk::Image::Pointer image
InputImageType * GetInput(void)
OutputType * GetOutput()
Get the output data of this image source object.
void GenerateInputRequestedRegion() override