ITK  4.6.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  typename TScalar = double, // Data type for scalars (float or
45  // double)
46  unsigned int NDimensions = 3>
47 // Number of dimensions
49  public Transform< TScalar, 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 
71 
74 
77 
80 
84 
88 
90  typedef vnl_vector_fixed<TScalar, NDimensions> InputVnlVectorType;
91  typedef vnl_vector_fixed<TScalar, NDimensions> OutputVnlVectorType;
92 
96 
100  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
101 
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 
143  OutputVectorType TransformVector(const InputVectorType & vector) const;
144 
146 
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 
160 
165  bool GetInverse(Self *inverse) const;
166 
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 
184  {
185  return NDimensions;
186  }
187 
193  virtual bool IsLinear() const
194  {
195  return true;
196  }
197 
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 <typename TScalar, unsigned int NDimensions>
239 inline
242 {
243  return point - m_Offset;
244 }
245 
246 // Back transform a vector
247 template <typename TScalar, unsigned int NDimensions>
248 inline
251 {
252  return vect;
253 }
254 
255 // Back transform a vnl_vector
256 template <typename TScalar, unsigned int NDimensions>
257 inline
260 {
261  return vect;
262 }
263 
264 // Back Transform a CovariantVector
265 template <typename TScalar, 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 */
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:238
Superclass::NumberOfParametersType NumberOfParametersType
Definition: itkTransform.h:183
Light weight base class for most itk classes.
Superclass::TransformCategoryType TransformCategoryType
vnl_vector_fixed< TScalar, NDimensions > OutputVnlVectorType
void Translate(const OutputVectorType &offset, bool pre=0)
Superclass::ScalarType ScalarType
void PrintSelf(std::ostream &os, Indent indent) const
Point< TScalar, NDimensions > InputPointType
Transform< TScalar, NOutputDimensions, NInputDimensions > InverseTransformBaseType
Definition: itkTransform.h:161
virtual void SetFixedParameters(const ParametersType &)
static const unsigned int ParametersDimension
const OutputVectorType & GetOffset(void) const
void SetParameters(const ParametersType &parameters)
static const unsigned int SpaceDimension
void Compose(const Self *other, bool pre=0)
SmartPointer< const Self > ConstPointer
vnl_vector_fixed< TScalar, NDimensions > InputVnlVectorType
virtual const ParametersType & GetParameters(void) const
InverseTransformBaseType::Pointer InverseTransformBasePointer
virtual const ParametersType & GetFixedParameters(void) const
Superclass::NumberOfParametersType NumberOfParametersType
virtual InverseTransformBasePointer GetInverseTransform() const
void operator=(const Self &)
IdentifierType NumberOfParametersType
Transform< TScalar, NDimensions, NDimensions > Superclass
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
Vector< TScalar, NDimensions > OutputVectorType
void SetSize(SizeValueType sz)
void SetOffset(const OutputVectorType &offset)
Class to hold and manage different parameter types used during optimization.
Superclass::JacobianType JacobianType
virtual NumberOfParametersType GetNumberOfParameters(void) const
InputPointType BackTransform(const OutputPointType &point) const
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:192
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianType &jac) const
bool GetInverse(Self *inverse) const
Vector< TScalar, NDimensions > InputVectorType
Superclass::InverseTransformBaseType InverseTransformBaseType
CovariantVector< TScalar, NDimensions > OutputCovariantVectorType
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const
Superclass::ParametersType ParametersType
virtual TransformCategoryType GetTransformCategory() const
Point< TScalar, NDimensions > OutputPointType
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &point, JacobianType &j) const
Control indentation during Print() invocation.
Definition: itkIndent.h:49
OutputPointType TransformPoint(const InputPointType &point) const
Superclass::TransformCategoryType TransformCategoryType
Definition: itkTransform.h:431
CovariantVector< TScalar, NDimensions > InputCovariantVectorType
OutputVectorType TransformVector(const InputVectorType &vector) const
Translation transformation of a vector space (e.g. space coordinates)
A templated class holding a n-Dimensional covariant vector.