Medical Imaging Interaction Toolkit  2016.11.0
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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkImageToImageFilter.h"
18 
20 {
21  // Modify superclass default values, can be overridden by subclasses
22  this->SetNumberOfRequiredInputs(1);
23 }
24 
26 {
27 }
28 
33 {
34  // Process object is not const-correct so the const_cast is required here
35  this->ProcessObject::SetNthInput(0, const_cast<mitk::ImageToImageFilter::InputImageType *>(input));
36 }
37 
42 {
43  if (index + 1 > this->GetNumberOfInputs())
44  {
45  this->SetNumberOfRequiredInputs(index + 1);
46  }
47  // Process object is not const-correct so the const_cast is required here
48  this->ProcessObject::SetNthInput(index, const_cast<mitk::ImageToImageFilter::InputImageType *>(image));
49 }
50 
55 {
56  if (this->GetNumberOfInputs() < 1)
57  {
58  return nullptr;
59  }
60 
61  return static_cast<mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(0));
62 }
63 
68 {
69  return static_cast<mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(idx));
70 }
71 
73 {
74  if (this->GetNumberOfInputs() < 1)
75  {
76  return nullptr;
77  }
78 
79  return static_cast<const mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(0));
80 }
81 
86 {
87  return static_cast<const mitk::ImageToImageFilter::InputImageType *>(this->ProcessObject::GetInput(idx));
88 }
89 
90 //-----------------------------------------------------------------------
91 //
93 {
94  Superclass::GenerateInputRequestedRegion();
95 
96  for (unsigned int idx = 0; idx < this->GetNumberOfInputs(); ++idx)
97  {
98  if (this->GetInput(idx))
99  {
101  const_cast<mitk::ImageToImageFilter::InputImageType *>(this->GetInput(idx));
102 
103  // Use the function object RegionCopier to copy the output region
104  // to the input. The default region copier has default implementations
105  // to handle the cases where the input and output are the same
106  // dimension, the input a higher dimension than the output, and the
107  // input a lower dimension than the output.
108  InputImageRegionType inputRegion;
109  // this->CallCopyRegion(inputRegion, this->GetOutput()->GetRequestedRegion()); @FIXME ??
110  // input->SetRequestedRegion( inputRegion ); @FIXME ??
111  input->SetRequestedRegion(this->GetOutput()); // ersatz. @FIXME ??
112  }
113  }
114 }
115 
116 void mitk::ImageToImageFilter::PrintSelf(std::ostream &os, itk::Indent indent) const
117 {
118  Superclass::PrintSelf(os, indent);
119 }
virtual 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:76
InputImageType * GetInput(void)
virtual void GenerateInputRequestedRegion() override