ITK  4.4.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 <class TScalarType,
50  unsigned int NDimensions = 3>
51 class ITK_EXPORT IdentityTransform : public Transform<TScalarType, 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 TScalarType ScalarType;
73 
75  typedef typename Superclass::ParametersType ParametersType;
76 
78  typedef typename Superclass::JacobianType JacobianType;
79 
81  typedef typename Superclass::TransformCategoryType TransformCategoryType;
82 
84  typedef Vector<TScalarType,
85  itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
86  typedef Vector<TScalarType,
87  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
89 
91  typedef CovariantVector<TScalarType,
92  itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType;
93  typedef CovariantVector<TScalarType,
94  itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType;
96 
98  typedef vnl_vector_fixed<TScalarType,
99  itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType;
100  typedef vnl_vector_fixed<TScalarType,
101  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType;
103 
105  typedef Point<TScalarType,
106  itkGetStaticConstMacro(InputSpaceDimension)> InputPointType;
107  typedef Point<TScalarType,
108  itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType;
110 
113  typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
114  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
115 
117  virtual OutputPointType TransformPoint(const InputPointType & point) const
118  {
119  return point;
120  }
121 
123  using Superclass::TransformVector;
124  virtual OutputVectorType TransformVector(const InputVectorType & vector) const
125  {
126  return vector;
127  }
128 
130  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const
131  {
132  return vector;
133  }
134 
136  using Superclass::TransformCovariantVector;
137  virtual OutputCovariantVectorType TransformCovariantVector(
138  const InputCovariantVectorType & vector) const
139  {
140  return vector;
141  }
142 
147  void SetIdentity(void)
148  {
149  }
150 
179  virtual void ComputeJacobianWithRespectToParameters( const InputPointType &,
180  JacobianType & jacobian) const
181  {
182  jacobian = this->m_IdentityJacobian;
183  }
184 
189  virtual void ComputeJacobianWithRespectToPosition(const InputPointType &,
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 
203  virtual InverseTransformBasePointer GetInverseTransform() const
204  {
205  return this->New().GetPointer();
206  }
207 
213  virtual TransformCategoryType GetTransformCategory() const
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<TScalarType, 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 
249  virtual ~IdentityTransform()
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
262