ITK  4.13.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 "itkTransform.h"
22 #include "itkMacro.h"
23 #include "itkMatrix.h"
24 
25 namespace itk
26 {
27 
43 template<typename TParametersValueType=double,
44  unsigned int NDimensions = 3>
45 class ITK_TEMPLATE_EXPORT TranslationTransform :
46  public Transform<TParametersValueType, NDimensions, NDimensions>
47 {
48 public:
54 
56  itkNewMacro(Self);
57 
59  itkTypeMacro(TranslationTransform, Transform);
60 
62  itkStaticConstMacro(SpaceDimension, unsigned int, NDimensions);
63  itkStaticConstMacro(ParametersDimension, unsigned int, NDimensions);
65 
67  typedef typename Superclass::ScalarType ScalarType;
68 
70  typedef typename Superclass::FixedParametersType FixedParametersType;
71  typedef typename Superclass::ParametersType ParametersType;
72 
74  typedef typename Superclass::JacobianType JacobianType;
75 
77  typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
78 
82 
86 
88  typedef vnl_vector_fixed<TParametersValueType, NDimensions> InputVnlVectorType;
89  typedef vnl_vector_fixed<TParametersValueType, NDimensions> OutputVnlVectorType;
90 
94 
97  typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
98  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
99 
101  typedef typename Superclass::TransformCategoryType TransformCategoryType;
102 
105  const OutputVectorType & GetOffset(void) const
106  {
107  return m_Offset;
108  }
109 
112  virtual void SetParameters(const ParametersType & parameters) ITK_OVERRIDE;
113 
115  virtual const ParametersType & GetParameters() const ITK_OVERRIDE;
116 
120  void SetOffset(const OutputVectorType & offset)
121  {
122  m_Offset = offset; return;
123  }
124 
126  void Compose(const Self *other, bool pre = 0);
127 
132  void Translate(const OutputVectorType & offset, bool pre = 0);
133 
138  OutputPointType TransformPoint(const InputPointType & point) const ITK_OVERRIDE;
139 
140  using Superclass::TransformVector;
141  OutputVectorType TransformVector(const InputVectorType & vector) const ITK_OVERRIDE;
142 
143  OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const ITK_OVERRIDE;
144 
145  using Superclass::TransformCovariantVector;
146  OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType & vector) const ITK_OVERRIDE;
147 
151  inline InputPointType BackTransform(const OutputPointType & point) const;
152 
153  inline InputVectorType BackTransform(const OutputVectorType & vector) const;
154 
155  inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const;
156 
157  inline InputCovariantVectorType BackTransform(const OutputCovariantVectorType & vector) const;
158 
163  bool GetInverse(Self *inverse) const;
164 
166  virtual InverseTransformBasePointer GetInverseTransform() const ITK_OVERRIDE;
167 
169  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & point, JacobianType & j) const ITK_OVERRIDE;
170 
175  virtual void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianType & jac) const ITK_OVERRIDE;
176 
178  void SetIdentity();
179 
181  virtual NumberOfParametersType GetNumberOfParameters() const ITK_OVERRIDE
182  {
183  return NDimensions;
184  }
185 
191  virtual bool IsLinear() const ITK_OVERRIDE
192  {
193  return true;
194  }
195 
199  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE
200  {
201  return Self::Linear;
202  }
203 
207  virtual void SetFixedParameters(const FixedParametersType &) ITK_OVERRIDE
208  {
209  }
210 
214  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE
215  {
216  this->m_FixedParameters.SetSize(0);
217  return this->m_FixedParameters;
218  }
220 
221 protected:
223  ~TranslationTransform() ITK_OVERRIDE;
225  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
226 
227 private:
228  ITK_DISALLOW_COPY_AND_ASSIGN(TranslationTransform);
229 
230  JacobianType m_IdentityJacobian;
231  OutputVectorType m_Offset; // Offset of the transformation
232 }; // class TranslationTransform
233 
234 // Back transform a point
235 template<typename TParametersValueType, unsigned int NDimensions>
236 inline
237 typename TranslationTransform<TParametersValueType, NDimensions>::InputPointType
238 TranslationTransform<TParametersValueType, NDimensions>::BackTransform(const OutputPointType & point) const
239 {
240  return point - m_Offset;
241 }
242 
243 // Back transform a vector
244 template<typename TParametersValueType, unsigned int NDimensions>
245 inline
248 {
249  return vect;
250 }
251 
252 // Back transform a vnl_vector
253 template<typename TParametersValueType, unsigned int NDimensions>
254 inline
257 {
258  return vect;
259 }
260 
261 // Back Transform a CovariantVector
262 template<typename TParametersValueType, unsigned int NDimensions>
263 inline
266 {
267  return vect;
268 }
269 
270 } // namespace itk
271 
272 #ifndef ITK_MANUAL_INSTANTIATION
273 #include "itkTranslationTransform.hxx"
274 #endif
275 
276 #endif /* itkTranslationTransform_h */
Light weight base class for most itk classes.
InputPointType BackTransform(const OutputPointType &point) const
Vector< TParametersValueType, NDimensions > InputVectorType
Superclass::FixedParametersType FixedParametersType
IdentifierType NumberOfParametersType
Transform< TParametersValueType, NDimensions, NDimensions > Superclass
vnl_vector_fixed< TParametersValueType, NDimensions > OutputVnlVectorType
Superclass::InverseTransformBaseType InverseTransformBaseType
virtual TransformCategoryType GetTransformCategory() const override
InverseTransformBaseType::Pointer InverseTransformBasePointer
Vector< TParametersValueType, NDimensions > OutputVectorType
vnl_vector_fixed< TParametersValueType, NDimensions > InputVnlVectorType
virtual bool IsLinear() const override
Superclass::JacobianType JacobianType
Superclass::ScalarType ScalarType
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
CovariantVector< TParametersValueType, NDimensions > OutputCovariantVectorType
SmartPointer< const Self > ConstPointer
void SetSize(SizeValueType sz)
virtual void SetFixedParameters(const FixedParametersType &) override
Class to hold and manage different parameter types used during optimization.
Superclass::TransformCategoryType TransformCategoryType
const OutputVectorType & GetOffset(void) const
CovariantVector< TParametersValueType, NDimensions > InputCovariantVectorType
Superclass::ParametersType ParametersType
virtual const FixedParametersType & GetFixedParameters() const override
Superclass::NumberOfParametersType NumberOfParametersType
Point< TParametersValueType, NDimensions > InputPointType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Translation transformation of a vector space (e.g. space coordinates)
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:52
Point< TParametersValueType, NDimensions > OutputPointType
A templated class holding a n-Dimensional covariant vector.