ITK  4.4.0
Insight Segmentation and Registration Toolkit
itkTranslationTransform.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkTranslationTransform_h
19 #define __itkTranslationTransform_h
20 
21 #include <iostream>
22 #include "itkTransform.h"
23 #include "itkMacro.h"
24 #include "itkMatrix.h"
25 
26 namespace itk
27 {
43 template <
44  class TScalarType = double, // Data type for scalars (float or
45  // double)
46  unsigned int NDimensions = 3>
47 // Number of dimensions
48 class ITK_EXPORT TranslationTransform :
49  public Transform<TScalarType, NDimensions, NDimensions>
50 {
51 public:
57 
59  itkNewMacro(Self);
60 
62  itkTypeMacro(TranslationTransform, Transform);
63 
65  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
66  itkStaticConstMacro(ParametersDimension, unsigned int, NDimensions);
68 
70  typedef typename Superclass::ScalarType ScalarType;
71 
73  typedef typename Superclass::ParametersType ParametersType;
74 
76  typedef typename Superclass::JacobianType JacobianType;
77 
79  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
80 
84 
88 
90  typedef vnl_vector_fixed<TScalarType, NDimensions> InputVnlVectorType;
91  typedef vnl_vector_fixed<TScalarType, NDimensions> OutputVnlVectorType;
92 
96 
99  typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
100  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
101 
103  typedef typename Superclass::TransformCategoryType TransformCategoryType;
104 
107  const OutputVectorType & GetOffset(void) const
108  {
109  return m_Offset;
110  }
111 
114  void SetParameters(const ParametersType & parameters);
115 
117  virtual const ParametersType & GetParameters(void) const;
118 
122  void SetOffset(const OutputVectorType & offset)
123  {
124  m_Offset = offset; return;
125  }
126 
128  void Compose(const Self *other, bool pre = 0);
129 
134  void Translate(const OutputVectorType & offset, bool pre = 0);
135 
140  OutputPointType TransformPoint(const InputPointType & point) const;
141 
142  using Superclass::TransformVector;
143  OutputVectorType TransformVector(const InputVectorType & vector) const;
144 
145  OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const;
146 
147  using Superclass::TransformCovariantVector;
148  OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType & vector) const;
149 
153  inline InputPointType BackTransform(const OutputPointType & point) const;
154 
155  inline InputVectorType BackTransform(const OutputVectorType & vector) const;
156 
157  inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const;
158 
159  inline InputCovariantVectorType BackTransform(const OutputCovariantVectorType & vector) const;
160 
165  bool GetInverse(Self *inverse) const;
166 
168  virtual InverseTransformBasePointer GetInverseTransform() const;
169 
171  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & point, JacobianType & j) const;
172 
177  virtual void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianType & jac) const;
178 
180  void SetIdentity(void);
181 
183  virtual NumberOfParametersType GetNumberOfParameters(void) const
184  {
185  return NDimensions;
186  }
187 
193  virtual bool IsLinear() const
194  {
195  return true;
196  }
197 
201  virtual TransformCategoryType GetTransformCategory() const
202  {
203  return Self::Linear;
204  }
205 
209  virtual void SetFixedParameters(const ParametersType &)
210  {
211  }
212 
216  virtual const ParametersType & GetFixedParameters(void) const
217  {
218  this->m_FixedParameters.SetSize(0);
219  return this->m_FixedParameters;
220  }
222 
223 protected:
227  void PrintSelf(std::ostream & os, Indent indent) const;
228 
229 private:
230  TranslationTransform(const Self &); // purposely not implemented
231  void operator=(const Self &); // purposely not implemented
232 
234  OutputVectorType m_Offset; // Offset of the transformation
235 }; // class TranslationTransform
236 
237 // Back transform a point
238 template <class TScalarType, unsigned int NDimensions>
239 inline
242 {
243  return point - m_Offset;
244 }
245 
246 // Back transform a vector
247 template <class TScalarType, unsigned int NDimensions>
248 inline
251 {
252  return vect;
253 }
254 
255 // Back transform a vnl_vector
256 template <class TScalarType, unsigned int NDimensions>
257 inline
260 {
261  return vect;
262 }
263 
264 // Back Transform a CovariantVector
265 template <class TScalarType, unsigned int NDimensions>
266 inline
269 {
270  return vect;
271 }
272 
273 } // namespace itk
274 
275 #ifndef ITK_MANUAL_INSTANTIATION
276 #include "itkTranslationTransform.hxx"
277 #endif
278 
279 #endif /* __itkTranslationTransform_h */
280