ITK  5.0.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:
49  ITK_DISALLOW_COPY_AND_ASSIGN(TranslationTransform);
50 
56 
58  itkNewMacro(Self);
59 
61  itkTypeMacro(TranslationTransform, Transform);
62 
64  static constexpr unsigned int SpaceDimension = NDimensions;
65  static constexpr unsigned int ParametersDimension = NDimensions;
66 
68  using ScalarType = typename Superclass::ScalarType;
69 
71  using FixedParametersType = typename Superclass::FixedParametersType;
72  using ParametersType = typename Superclass::ParametersType;
73 
75  using JacobianType = typename Superclass::JacobianType;
76  using JacobianPositionType = typename Superclass::JacobianPositionType;
77  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
78 
80  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
81 
85 
89 
91  using InputVnlVectorType = vnl_vector_fixed<TParametersValueType, NDimensions>;
92  using OutputVnlVectorType = vnl_vector_fixed<TParametersValueType, NDimensions>;
93 
97 
100  using InverseTransformBaseType = typename Superclass::InverseTransformBaseType;
101  using InverseTransformBasePointer = typename InverseTransformBaseType::Pointer;
102 
104  using TransformCategoryType = typename Superclass::TransformCategoryType;
105 
108  const OutputVectorType & GetOffset() const
109  {
110  return m_Offset;
111  }
112 
115  void SetParameters(const ParametersType & parameters) override;
116 
118  const ParametersType & GetParameters() const override;
119 
123  void SetOffset(const OutputVectorType & offset)
124  {
125  m_Offset = offset; return;
126  }
127 
129  void Compose(const Self *other, bool pre = false);
130 
135  void Translate(const OutputVectorType & offset, bool pre = false);
136 
141  OutputPointType TransformPoint(const InputPointType & point) const override;
142 
143  using Superclass::TransformVector;
144  OutputVectorType TransformVector(const InputVectorType & vector) const override;
145 
146  OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const override;
147 
148  using Superclass::TransformCovariantVector;
149  OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType & vector) const override;
150 
154  inline InputPointType BackTransform(const OutputPointType & point) const;
155 
156  inline InputVectorType BackTransform(const OutputVectorType & vector) const;
157 
158  inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const;
159 
160  inline InputCovariantVectorType BackTransform(const OutputCovariantVectorType & vector) const;
161 
166  bool GetInverse(Self *inverse) const;
167 
169  InverseTransformBasePointer GetInverseTransform() const override;
170 
172  void ComputeJacobianWithRespectToParameters(const InputPointType & point, JacobianType & j) const override;
173 
174 
179  void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianPositionType & jac) const override;
180  using Superclass::ComputeJacobianWithRespectToPosition;
181 
183  void SetIdentity();
184 
187  {
188  return NDimensions;
189  }
190 
196  bool IsLinear() const override
197  {
198  return true;
199  }
200 
205  {
206  return Self::Linear;
207  }
208 
213  {
214  }
215 
219  const FixedParametersType & GetFixedParameters() const override
220  {
221  this->m_FixedParameters.SetSize(0);
222  return this->m_FixedParameters;
223  }
225 
226 protected:
228  ~TranslationTransform() override = default;
230  void PrintSelf(std::ostream & os, Indent indent) const override;
231 
232 private:
234  OutputVectorType m_Offset; // Offset of the transformation
235 }; // class TranslationTransform
236 
237 // Back transform a point
238 template<typename TParametersValueType, unsigned int NDimensions>
239 inline
242 {
243  return point - m_Offset;
244 }
245 
246 // Back transform a vector
247 template<typename TParametersValueType, unsigned int NDimensions>
248 inline
251 {
252  return vect;
253 }
254 
255 // Back transform a vnl_vector
256 template<typename TParametersValueType, unsigned int NDimensions>
257 inline
260 {
261  return vect;
262 }
263 
264 // Back Transform a CovariantVector
265 template<typename TParametersValueType, 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 */
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
Light weight base class for most itk classes.
InputPointType BackTransform(const OutputPointType &point) const
TransformCategoryType GetTransformCategory() const override
vnl_vector_fixed< TParametersValueType, NDimensions > InputVnlVectorType
const FixedParametersType & GetFixedParameters() const override
typename Superclass::InverseTransformBaseType InverseTransformBaseType
void SetFixedParameters(const FixedParametersType &) override
typename Superclass::JacobianPositionType JacobianPositionType
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
typename Superclass::JacobianType JacobianType
void SetSize(SizeValueType sz)
vnl_vector_fixed< TParametersValueType, NDimensions > OutputVnlVectorType
NumberOfParametersType GetNumberOfParameters() const override
Class to hold and manage different parameter types used during optimization.
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
typename Superclass::ScalarType ScalarType
void SetOffset(const OutputVectorType &offset)
IdentifierType NumberOfParametersType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
Translation transformation of a vector space (e.g. space coordinates)
const OutputVectorType & GetOffset() const
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:52
A templated class holding a n-Dimensional covariant vector.