ITK  4.9.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>
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 
68 
72 
75 
78 
82 
86 
88  typedef vnl_vector_fixed<TParametersValueType, NDimensions> InputVnlVectorType;
89  typedef vnl_vector_fixed<TParametersValueType, NDimensions> OutputVnlVectorType;
90 
94 
98  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
99 
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 
141  OutputVectorType TransformVector(const InputVectorType & vector) const ITK_OVERRIDE;
142 
143  OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const ITK_OVERRIDE;
144 
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 
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:
225  virtual void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
226 
227 private:
228  TranslationTransform(const Self &) ITK_DELETE_FUNCTION;
229  void operator=(const Self &) ITK_DELETE_FUNCTION;
230 
232  OutputVectorType m_Offset; // Offset of the transformation
233 }; // class TranslationTransform
234 
235 // Back transform a point
236 template<typename TParametersValueType, unsigned int NDimensions>
237 inline
238 typename TranslationTransform<TParametersValueType, NDimensions>::InputPointType
239 TranslationTransform<TParametersValueType, NDimensions>::BackTransform(const OutputPointType & point) const
240 {
241  return point - m_Offset;
242 }
243 
244 // Back transform a vector
245 template<typename TParametersValueType, unsigned int NDimensions>
246 inline
249 {
250  return vect;
251 }
252 
253 // Back transform a vnl_vector
254 template<typename TParametersValueType, unsigned int NDimensions>
255 inline
258 {
259  return vect;
260 }
261 
262 // Back Transform a CovariantVector
263 template<typename TParametersValueType, unsigned int NDimensions>
264 inline
267 {
268  return vect;
269 }
270 
271 } // namespace itk
272 
273 #ifndef ITK_MANUAL_INSTANTIATION
274 #include "itkTranslationTransform.hxx"
275 #endif
276 
277 #endif /* itkTranslationTransform_h */
virtual InverseTransformBasePointer GetInverseTransform() const override
Light weight base class for most itk classes.
InputPointType BackTransform(const OutputPointType &point) const
Vector< TParametersValueType, NDimensions > InputVectorType
Superclass::FixedParametersType FixedParametersType
OutputVectorType TransformVector(const InputVectorType &vector) const override
IdentifierType NumberOfParametersType
Transform< TParametersValueType, NDimensions, NDimensions > Superclass
vnl_vector_fixed< TParametersValueType, NDimensions > OutputVnlVectorType
Superclass::InverseTransformBaseType InverseTransformBaseType
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:193
virtual TransformCategoryType GetTransformCategory() const override
InverseTransformBaseType::Pointer InverseTransformBasePointer
Vector< TParametersValueType, NDimensions > OutputVectorType
vnl_vector_fixed< TParametersValueType, NDimensions > InputVnlVectorType
virtual const ParametersType & GetParameters() const override
virtual bool IsLinear() const override
Superclass::JacobianType JacobianType
virtual void PrintSelf(std::ostream &os, Indent indent) const override
Superclass::ScalarType ScalarType
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
OutputPointType TransformPoint(const InputPointType &point) const override
CovariantVector< TParametersValueType, NDimensions > OutputCovariantVectorType
SmartPointer< const Self > ConstPointer
void SetSize(SizeValueType sz)
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &point, JacobianType &j) const override
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
static const unsigned int SpaceDimension
CovariantVector< TParametersValueType, NDimensions > InputCovariantVectorType
void SetOffset(const OutputVectorType &offset)
void Translate(const OutputVectorType &offset, bool pre=0)
Superclass::ParametersType ParametersType
virtual const FixedParametersType & GetFixedParameters() const override
Superclass::NumberOfParametersType NumberOfParametersType
void Compose(const Self *other, bool pre=0)
virtual NumberOfParametersType GetNumberOfParameters() const override
virtual void SetParameters(const ParametersType &parameters) override
Transform< TParametersValueType, NOutputDimensions, NInputDimensions > InverseTransformBaseType
Definition: itkTransform.h:163
bool GetInverse(Self *inverse) const
static const unsigned int ParametersDimension
Point< TParametersValueType, NDimensions > InputPointType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:239
Translation transformation of a vector space (e.g. space coordinates)
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianType &jac) const override
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.
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const override