KWStyle - itkImageToImageFilter.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkImageToImageFilter.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:40 $
7   Version:   $Revision: 1.4 $
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 IND *****PURPOSE.  See the above copyright notices for more information.
18
19 =========================================================================*/
20 DEF #ifndef _itkImageToImageFilter_txx
21 DEF #define _itkImageToImageFilter_txx
22 #include "itkImageToImageFilter.h"
23
24
25 namespace itk
26 {
27
28 /**
29  *
30  */
31 template <class TInputImage, class TOutputImage>
32 ImageToImageFilter<TInputImage,TOutputImage>
33 ::ImageToImageFilter()
34 {
35   // Modify superclass default values, can be overridden by subclasses
36   this->SetNumberOfRequiredInputs(1);
37 }
38
39 /**
40  *
41  */
42 template <class TInputImage, class TOutputImage>
43 ImageToImageFilter<TInputImage,TOutputImage>
44 ::~ImageToImageFilter()
45 {
46 }
47   
48
49 /**
50  *
51  */
52 template <class TInputImage, class TOutputImage>
53 void 
54 ImageToImageFilter<TInputImage,TOutputImage>
55 ::SetInput(const InputImageType *input)
56 {
57   // Process object is not const-correct so the const_cast is required here
58   this->ProcessObject::SetNthInput(0, 
59                                    const_cast< InputImageType * >( input ) );
60 }
61
62
63 /**
64  * Connect one of the operands for pixel-wise addition
65  */
66 template <class TInputImage, class TOutputImage>
67 void
68 ImageToImageFilter<TInputImage,TOutputImage>
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
76
77 EML
78 /**
79  *
80  */
81 template <class TInputImage, class TOutputImage>
82 const typename ImageToImageFilter<TInputImage,TOutputImage>::InputImageType *
83 ImageToImageFilter<TInputImage,TOutputImage>
84 ::GetInput(void) 
85 {
86   if (this->GetNumberOfInputs() < 1)
87     {
88     return 0;
89     }
90   
91   return static_cast<const TInputImage * >
92 IND ****(this->ProcessObject::GetInput(0) );
93 }
94   
95 /**
96  *
97  */
98 template <class TInputImage, class TOutputImage>
99 const typename ImageToImageFilter<TInputImage,TOutputImage>::InputImageType *
100 ImageToImageFilter<TInputImage,TOutputImage>
101 ::GetInput(unsigned int idx)
102 {
103   return static_cast< const TInputImage * >
104 IND ****(this->ProcessObject::GetInput(idx));
105 }
106
107
108 EML
109 //-----------------------------------------------------------------------
110 //
111 template<class TInputImage, class TOutputImage>
112 void 
113 ImageToImageFilter<TInputImage,TOutputImage>
114 ::GenerateInputRequestedRegion()
115 {
116   Superclass::GenerateInputRequestedRegion();
117
118   for (unsigned int idx = 0; idx < this->GetNumberOfInputs(); ++idx)
119     {
120     if (this->GetInput(idx))
121       {
122       // Check whether the input is an image of the appropriate
123       // dimension (use ProcessObject's version of the GetInput()
124       // method since it returns the input as a pointer to a
125       // DataObject as opposed to the subclass version which
126       // static_casts the input to an TInputImage).
127       typedef ImageBase<InputImageDimension> ImageBaseType;
128       typename ImageBaseType::ConstPointer constInput
129 LEN,IND ********= dynamic_cast< ImageBaseType const *>( this->ProcessObject::GetInput(idx) );
130
131       // If not an image, skip it, and let a subclass of
132       // ImageToImageFilter handle this input.
133       if (constInput.IsNull() )
134         {
135         continue;
136         }
137
138       // Input is an image, cast away the constness so we can set
139       // the requested region.
140       InputImagePointer input =
141 IND ********const_cast< TInputImage * > ( this->GetInput(idx) );
142
143       // Use the function object RegionCopier to copy the output region
144       // to the input.  The default region copier has default implementations
145       // to handle the cases where the input and output are the same
146       // dimension, the input a higher dimension than the output, and the
147       // input a lower dimension than the output.
148       InputImageRegionType inputRegion;
149 LEN       this->CallCopyOutputRegionToInputRegion(inputRegion, this->GetOutput()->GetRequestedRegion());
150       input->SetRequestedRegion( inputRegion );
151       }
152     }  
153 }
154
155 template<class TInputImage, class TOutputImage>
156 void 
157 ImageToImageFilter<TInputImage,TOutputImage>
158 ::CallCopyOutputRegionToInputRegion(InputImageRegionType &destRegion,
159                                     const OutputImageRegionType &srcRegion)
160 {
161   OutputToInputRegionCopierType regionCopier;
162   regionCopier(destRegion, srcRegion);
163 }
164
165
166 template<class TInputImage, class TOutputImage>
167 void 
168 ImageToImageFilter<TInputImage,TOutputImage>
169 ::CallCopyInputRegionToOutputRegion(OutputImageRegionType &destRegion,
170                                     const InputImageRegionType &srcRegion)
171 {
172   InputToOutputRegionCopierType regionCopier;
173   regionCopier(destRegion, srcRegion);
174 }
175
176
177 template<class TInputImage, class TOutputImage>
178 void 
179 ImageToImageFilter<TInputImage,TOutputImage>
180 ::PrintSelf(std::ostream& os, Indent indent) const
181 {
182   Superclass::PrintSelf(os, indent);
183 }
184
185
186 EML
187 // end namespace itk
188
189 #endif
190

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:17PM
© Kitware Inc.