KWStyle - itkTranslationTransform.txx
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkTranslationTransform.txx.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:48 $
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      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 DEF #ifndef _itkTranslationTransform_txx
18 DEF #define _itkTranslationTransform_txx
19
20 #include "itkTranslationTransform.h"
21
22
23 namespace itk
24 {
25
26 // Constructor with default arguments
27 template<class TScalarType, unsigned int NDimensions>
28 TranslationTransform<TScalarType, NDimensions>::
29 TranslationTransform():Superclass(SpaceDimension,ParametersDimension)
30 {
31   m_Offset.Fill( 0 );
32 }
33     
34
35 // Destructor
36 template<class TScalarType, unsigned int NDimensions>
37 TranslationTransform<TScalarType, NDimensions>::
38 ~TranslationTransform()
39 {
40   return;
41 }
42
43
44 // Set the parameters
45 template <class TScalarType, unsigned int NDimensions>
46 void
47 TranslationTransform<TScalarType, NDimensions>
48 ::SetParameters( const ParametersType & parameters )
49 {
50   bool modified = false;
51   for( unsigned int i=0; i<SpaceDimension; i++ )
52     {
53     if (m_Offset[i] != parameters[i])
54       {
55       m_Offset[i] = parameters[i];
56       modified = true;
57       }
58     }
59   if (modified)
60     {
61     this->Modified();
62     }
63 }
64
65
66 EML
67 EML
68 // Get the parameters
69 template <class TScalarType, unsigned int NDimensions>
70 const typename TranslationTransform<TScalarType, NDimensions>::ParametersType &
71 TranslationTransform<TScalarType, NDimensions>
72 ::GetParameters( void ) const
73 {
74   for( unsigned int i=0; i<SpaceDimension; i++ )
75     {
76     this->m_Parameters[i] = this->m_Offset[i];
77     }  
78   return this->m_Parameters;
79 }
80
81
82 EML
83 // Print self
84 template<class TScalarType, unsigned int NDimensions>
85 void
86 TranslationTransform<TScalarType, NDimensions>::
87 PrintSelf(std::ostream &os, Indent indent) const
88 {
89   Superclass::PrintSelf(os,indent);
90   
91   os << indent << "Offset: " << m_Offset << std::endl;
92 }
93
94
95 // Compose with another affine transformation
96 template<class TScalarType, unsigned int NDimensions>
97 void
98 TranslationTransform<TScalarType, NDimensions>::
99 Compose(const Self * other, bool )
100 {
101   this->Translate(other->m_Offset);
102   return;
103 }
104
105
106 // Compose with a translation
107 template<class TScalarType, unsigned int NDimensions>
108 void
109 TranslationTransform<TScalarType, NDimensions>::
110 Translate(const OutputVectorType &offset, bool )
111 {
112   ParametersType newOffset(SpaceDimension);
113   for( unsigned int i=0; i<SpaceDimension; i++ )
114     {
115     newOffset[i] = m_Offset[i] + offset[i];
116     }
117   this->SetParameters (newOffset);
118   return;
119 }
120
121
122 EML
123 // Transform a point
124 template<class TScalarType, unsigned int NDimensions>
125 typename TranslationTransform<TScalarType, NDimensions>::OutputPointType
126 TranslationTransform<TScalarType, NDimensions>::
127 TransformPoint(const InputPointType &point) const 
128 {
129   return point + m_Offset;
130 }
131
132
133 // Transform a vector
134 template<class TScalarType, unsigned int NDimensions>
135 typename TranslationTransform<TScalarType, NDimensions>::OutputVectorType
136 TranslationTransform<TScalarType, NDimensions>::
137 TransformVector(const InputVectorType &vect) const 
138 {
139   return  vect;
140 }
141
142
143 // Transform a vnl_vector_fixed
144 template<class TScalarType, unsigned int NDimensions>
145 typename TranslationTransform<TScalarType, NDimensions>::OutputVnlVectorType
146 TranslationTransform<TScalarType, NDimensions>::
147 TransformVector(const InputVnlVectorType &vect) const 
148 {
149   return  vect;
150 }
151
152
153 // Transform a CovariantVector
154 template<class TScalarType, unsigned int NDimensions>
155 LEN typename TranslationTransform<TScalarType, NDimensions>::OutputCovariantVectorType
156 TranslationTransform<TScalarType, NDimensions>::
157 TransformCovariantVector(const InputCovariantVectorType &vect) const 
158 {
159   return  vect;
160 }
161
162
163 EML
164 // Back transform a point
165 template<class TScalarType, unsigned int NDimensions>
166 typename TranslationTransform<TScalarType, NDimensions>::InputPointType
167 TranslationTransform<TScalarType, NDimensions>::
168 BackTransform(const OutputPointType &point) const {
169   return point - m_Offset;
170 }
171
172
173 EML
174 EML
175 // Back transform a vector
176 template<class TScalarType, unsigned int NDimensions>
177 typename TranslationTransform<TScalarType, NDimensions>::InputVectorType
178 TranslationTransform<TScalarType, NDimensions>::
179 BackTransform(const OutputVectorType &vect ) const 
180 {
181   return  vect;
182 }
183
184
185 EML
186 EML
187 // Back transform a vnl_vector
188 template<class TScalarType, unsigned int NDimensions>
189 typename TranslationTransform<TScalarType, NDimensions>::InputVnlVectorType
190 TranslationTransform<TScalarType, NDimensions>::
191 BackTransform(const OutputVnlVectorType &vect ) const 
192 {
193   return  vect;
194 }
195
196
197 // Back Transform a CovariantVector
198 template<class TScalarType, unsigned int NDimensions>
199 LEN typename TranslationTransform<TScalarType, NDimensions>::InputCovariantVectorType
200 TranslationTransform<TScalarType, NDimensions>::
201 BackTransform(const OutputCovariantVectorType &vect) const 
202 {
203   return vect;
204 }
205
206 // return an inverse transformation
207 template<class TScalarType, unsigned int NDimensions>
208 bool
209 TranslationTransform<TScalarType, NDimensions>::
210 GetInverse( Self* inverse) const
211 {
212   if(!inverse)
213     {
214     return false;
215     }
216
217   inverse->m_Offset   = - m_Offset;
218   return true;
219 }
220
221 // Compute the Jacobian in one position 
222 template<class TScalarType, unsigned int NDimensions>
223 const typename TranslationTransform<TScalarType, NDimensions>::JacobianType & 
224 TranslationTransform< TScalarType, NDimensions >::
225 GetJacobian( const InputPointType & ) const
226 {
227
228   this->m_Jacobian.Fill( 0.0 );
229
230   for(unsigned int i=0; i<NDimensions; i++)
231     {
232     this->m_Jacobian(i,i) = 1.0;
233     }
234
235   return this->m_Jacobian;
236
237 }
238
239
240 EML
241 // Set the parameters for an Identity transform of this class
242 template<class TScalarType, unsigned int NDimensions>
243 void
244 TranslationTransform<TScalarType, NDimensions>::
245 SetIdentity()
246 {
247   m_Offset.Fill( 0.0 );
248 }
249  
250   
251 // namespace
252
253 #endif
254

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