ITK  4.2.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 Vector<TScalarType,
82  itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
83  typedef Vector<TScalarType,
84  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
86 
88  typedef CovariantVector<TScalarType,
89  itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType;
90  typedef CovariantVector<TScalarType,
91  itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType;
93 
95  typedef vnl_vector_fixed<TScalarType,
96  itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType;
97  typedef vnl_vector_fixed<TScalarType,
98  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType;
100 
102  typedef Point<TScalarType,
103  itkGetStaticConstMacro(InputSpaceDimension)> InputPointType;
104  typedef Point<TScalarType,
105  itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType;
107 
110  typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
111  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
112 
114  virtual OutputPointType TransformPoint(const InputPointType & point) const
115  {
116  return point;
117  }
118 
120  using Superclass::TransformVector;
121  virtual OutputVectorType TransformVector(const InputVectorType & vector) const
122  {
123  return vector;
124  }
125 
127  virtual OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const
128  {
129  return vector;
130  }
131 
133  using Superclass::TransformCovariantVector;
134  virtual OutputCovariantVectorType TransformCovariantVector(
135  const InputCovariantVectorType & vector) const
136  {
137  return vector;
138  }
139 
144  void SetIdentity(void)
145  {
146  }
147 
176  virtual void ComputeJacobianWithRespectToParameters( const InputPointType &,
177  JacobianType & jacobian) const
178  {
179  jacobian = this->m_IdentityJacobian;
180  }
181 
186  virtual void ComputeJacobianWithRespectToPosition(const InputPointType &,
187  JacobianType & jac) const
188  {
189  jac.SetSize( NDimensions, NDimensions );
190  jac.Fill(0.0);
191  for( unsigned int dim = 0; dim < NDimensions; dim++ )
192  {
193  jac[dim][dim] = 1.0;
194  }
195  }
197 
200  virtual InverseTransformBasePointer GetInverseTransform() const
201  {
202  return this->New().GetPointer();
203  }
204 
210  virtual bool IsLinear() const
211  {
212  return true;
213  }
214 
216  virtual const ParametersType & GetFixedParameters(void) const
217  {
218  return this->m_FixedParameters;
219  }
220 
222  virtual void SetFixedParameters(const ParametersType &)
223  {
224  }
225 
227  virtual const ParametersType & GetParameters(void) const
228  {
229  return this->m_Parameters;
230  }
231 
233  virtual void SetParameters(const ParametersType &)
234  {
235  }
236 protected:
237  IdentityTransform() : Transform<TScalarType, NDimensions, NDimensions>(0),
238  m_IdentityJacobian(NDimensions, 0)
239  {
240  // The Jacobian is constant, therefore it can be initialized in the
241  // constructor.
242  this->m_IdentityJacobian.Fill(0.0);
243  }
245 
246  virtual ~IdentityTransform()
247  {
248  }
249 private:
250  IdentityTransform(const Self &); // purposely not implemented
251  void operator=(const Self &); // purposely not implemented
252 
254 };
255 } // end namespace itk
256 
257 #endif
258