ITK  4.6.0
Insight Segmentation and Registration Toolkit
itkIdentityTransform.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 __itkIdentityTransform_h
19 #define __itkIdentityTransform_h
20 
21 #include "itkObject.h"
22 #include "itkPoint.h"
23 #include "itkCovariantVector.h"
24 #include "vnl/vnl_vector_fixed.h"
25 #include "itkArray2D.h"
26 #include "itkTransform.h"
27 
28 namespace itk
29 {
49 template< typename TScalar,
50  unsigned int NDimensions = 3 >
51 class IdentityTransform : public Transform< TScalar, NDimensions, NDimensions >
52 {
53 public:
59 
61  itkNewMacro(Self);
62 
64  itkTypeMacro(IdentityTransform, Transform);
65 
67  itkStaticConstMacro(InputSpaceDimension, unsigned int, NDimensions);
68  itkStaticConstMacro(OutputSpaceDimension, unsigned int, NDimensions);
70 
72  typedef TScalar ScalarType;
73 
76 
79 
82 
84  typedef Vector<TScalar,
85  itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
86  typedef Vector<TScalar,
87  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
89 
91  typedef CovariantVector<TScalar,
93  typedef CovariantVector<TScalar,
96 
98  typedef vnl_vector_fixed<TScalar,
99  itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType;
100  typedef vnl_vector_fixed<TScalar,
101  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType;
103 
105  typedef Point<TScalar,
106  itkGetStaticConstMacro(InputSpaceDimension)> InputPointType;
107  typedef Point<TScalar,
108  itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType;
110 
114  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
115 
117  virtual OutputPointType TransformPoint(const InputPointType & point) const
118  {
119  return point;
120  }
121 
124  virtual OutputVectorType TransformVector(const InputVectorType & vector) const
125  {
126  return vector;
127  }
128 
131  {
132  return vector;
133  }
134 
138  const InputCovariantVectorType & vector) const
139  {
140  return vector;
141  }
142 
147  void SetIdentity(void)
148  {
149  }
150 
180  JacobianType & jacobian) const
181  {
182  jacobian = this->m_IdentityJacobian;
183  }
184 
190  JacobianType & jac) const
191  {
192  jac.SetSize( NDimensions, NDimensions );
193  jac.Fill(0.0);
194  for( unsigned int dim = 0; dim < NDimensions; dim++ )
195  {
196  jac[dim][dim] = 1.0;
197  }
198  }
200 
204  {
205  return this->New().GetPointer();
206  }
207 
214  {
215  return Self::Linear;
216  }
217 
219  virtual const ParametersType & GetFixedParameters(void) const
220  {
221  return this->m_FixedParameters;
222  }
223 
225  virtual void SetFixedParameters(const ParametersType &)
226  {
227  }
228 
230  virtual const ParametersType & GetParameters(void) const
231  {
232  return this->m_Parameters;
233  }
234 
236  virtual void SetParameters(const ParametersType &)
237  {
238  }
239 
240 protected:
241  IdentityTransform() : Transform<TScalar, NDimensions, NDimensions>(0),
242  m_IdentityJacobian(NDimensions, 0)
243  {
244  // The Jacobian is constant, therefore it can be initialized in the
245  // constructor.
246  this->m_IdentityJacobian.Fill(0.0);
247  }
248 
250  {
251  }
252 
253 private:
254  IdentityTransform(const Self &); // purposely not implemented
255  void operator=(const Self &); // purposely not implemented
256 
258 };
259 } // end namespace itk
260 
261 #endif
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
Definition: itkTransform.h:238
virtual OutputVnlVectorType TransformVector(const InputVnlVectorType &vector) const
Light weight base class for most itk classes.
Transform< TScalar, NOutputDimensions, NInputDimensions > InverseTransformBaseType
Definition: itkTransform.h:161
Point< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType
Implementation of an Identity Transform.
ObjectType * GetPointer() const
Superclass::TransformCategoryType TransformCategoryType
CovariantVector< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &, JacobianType &jac) const
Point< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType
void operator=(const Self &)
vnl_vector_fixed< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType
virtual void SetFixedParameters(const ParametersType &)
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &jacobian) const
Superclass::InverseTransformBaseType InverseTransformBaseType
static Pointer New()
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
virtual OutputPointType TransformPoint(const InputPointType &point) const
static const unsigned int OutputSpaceDimension
Vector< TScalar, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
virtual void SetParameters(const ParametersType &)
virtual OutputVectorType TransformVector(const InputVectorType &vector) const
Vector< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType
vnl_vector_fixed< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType
virtual OutputVectorType TransformVector(const InputVectorType &) const
Definition: itkTransform.h:192
virtual const ParametersType & GetParameters(void) const
Superclass::JacobianType JacobianType
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const
virtual InverseTransformBasePointer GetInverseTransform() const
Transform< TScalar, NDimensions, NDimensions > Superclass
Superclass::ParametersType ParametersType
InverseTransformBaseType::Pointer InverseTransformBasePointer
SmartPointer< Self > Pointer
Superclass::TransformCategoryType TransformCategoryType
Definition: itkTransform.h:431
virtual TransformCategoryType GetTransformCategory() const
CovariantVector< TScalar, itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType
virtual const ParametersType & GetFixedParameters(void) const
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:51
static const unsigned int InputSpaceDimension
A templated class holding a n-Dimensional covariant vector.
SmartPointer< const Self > ConstPointer