Orfeo Toolbox  3.16
itkImageToImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkImageToImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2009-02-05 19:04:57 $
7  Version: $Revision: 1.37 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  Portions of this code are covered under the VTK copyright.
13  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
14 
15  This software is distributed WITHOUT ANY WARRANTY; without even
16  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17  PURPOSE. See the above copyright notices for more information.
18 
19 =========================================================================*/
20 #ifndef __itkImageToImageFilter_txx
21 #define __itkImageToImageFilter_txx
22 #include "itkImageToImageFilter.h"
23 
24 
25 namespace itk
26 {
27 
31 template <class TInputImage, class TOutputImage>
34 {
35  // Modify superclass default values, can be overridden by subclasses
36  this->SetNumberOfRequiredInputs(1);
37 }
38 
42 template <class TInputImage, class TOutputImage>
45 {
46 }
47 
48 
52 template <class TInputImage, class TOutputImage>
53 void
56 {
57  // Process object is not const-correct so the const_cast is required here
59  const_cast< InputImageType * >( input ) );
60 }
61 
62 
66 template <class TInputImage, class TOutputImage>
67 void
69 ::SetInput( unsigned int index, const TInputImage * image )
70 {
71  // Process object is not const-correct so the const_cast is required here
72  this->ProcessObject::SetNthInput(index,
73  const_cast< TInputImage *>( image ) );
74 }
75 
79 template <class TInputImage, class TOutputImage>
82 ::GetInput(void)
83 {
84  if (this->GetNumberOfInputs() < 1)
85  {
86  return 0;
87  }
88 
89  return static_cast<const TInputImage * >
90  (this->ProcessObject::GetInput(0) );
91 }
92 
96 template <class TInputImage, class TOutputImage>
99 ::GetInput(unsigned int idx)
100 {
101  return static_cast< const TInputImage * >
102  (this->ProcessObject::GetInput(idx));
103 }
104 
105 //-----------------------------------------------------------------------
106 //
107 template<class TInputImage, class TOutputImage>
108 void
111 {
112  Superclass::GenerateInputRequestedRegion();
113 
114  for (unsigned int idx = 0; idx < this->GetNumberOfInputs(); ++idx)
115  {
116  if (this->GetInput(idx))
117  {
118  // Check whether the input is an image of the appropriate
119  // dimension (use ProcessObject's version of the GetInput()
120  // method since it returns the input as a pointer to a
121  // DataObject as opposed to the subclass version which
122  // static_casts the input to an TInputImage).
123  typedef ImageBase<InputImageDimension> ImageBaseType;
124  typename ImageBaseType::ConstPointer constInput
125  = dynamic_cast< ImageBaseType const *>( this->ProcessObject::GetInput(idx) );
126 
127  // If not an image, skip it, and let a subclass of
128  // ImageToImageFilter handle this input.
129  if (constInput.IsNull() )
130  {
131  continue;
132  }
133 
134  // Input is an image, cast away the constness so we can set
135  // the requested region.
136  InputImagePointer input =
137  const_cast< TInputImage * > ( this->GetInput(idx) );
138 
139  // Use the function object RegionCopier to copy the output region
140  // to the input. The default region copier has default implementations
141  // to handle the cases where the input and output are the same
142  // dimension, the input a higher dimension than the output, and the
143  // input a lower dimension than the output.
144  InputImageRegionType inputRegion;
145  this->CallCopyOutputRegionToInputRegion(inputRegion, this->GetOutput()->GetRequestedRegion());
146  input->SetRequestedRegion( inputRegion );
147  }
148  }
149 }
150 
151 template<class TInputImage, class TOutputImage>
152 void
155  const OutputImageRegionType &srcRegion)
156 {
157  OutputToInputRegionCopierType regionCopier;
158  regionCopier(destRegion, srcRegion);
159 }
160 
161 
162 template<class TInputImage, class TOutputImage>
163 void
166  const InputImageRegionType &srcRegion)
167 {
168  InputToOutputRegionCopierType regionCopier;
169  regionCopier(destRegion, srcRegion);
170 }
171 
172 
173 template<class TInputImage, class TOutputImage>
174 void
176 ::PrintSelf(std::ostream& os, Indent indent) const
177 {
178  Superclass::PrintSelf(os, indent);
179 }
180 
181 template<class TInputImage, class TOutputImage>
182 void
185 {
186  // Forward to the protected method in the superclass
187  this->ProcessObject::PushBackInput(input);
188 }
189 
190 template<class TInputImage, class TOutputImage>
191 void
194 {
195  // Forward to the protected method in the superclass
197 }
198 
199 template<class TInputImage, class TOutputImage>
200 void
203 {
204  // Forward to the protected method in the superclass
205  this->ProcessObject::PushFrontInput(input);
206 }
207 
208 template<class TInputImage, class TOutputImage>
209 void
212 {
213  // Forward to the protected method in the superclass
215 }
216 
217 } // end namespace itk
218 
219 #endif

Generated at Sat Feb 2 2013 23:45:05 for Orfeo Toolbox with doxygen 1.8.1.1