ITK  4.2.0
Insight Segmentation and Registration Toolkit
itkRigid2DTransform.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 __itkRigid2DTransform_h
19 #define __itkRigid2DTransform_h
20 
21 #include <iostream>
23 
24 namespace itk
25 {
56 template <class TScalarType = double>
57 // Data type for scalars (float or double)
58 class ITK_EXPORT Rigid2DTransform :
59  public MatrixOffsetTransformBase<TScalarType, 2, 2> // Dimensions of
60  // input and output
61  // spaces
62 {
63 public:
69 
72 
74  itkNewMacro(Self);
75 
77  itkStaticConstMacro(InputSpaceDimension, unsigned int, 2);
78  itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
79  itkStaticConstMacro(ParametersDimension, unsigned int, 3);
81 
83  typedef typename Superclass::ScalarType ScalarType;
84 
86  typedef typename Superclass::ParametersType ParametersType;
87  typedef typename Superclass::ParametersValueType ParametersValueType;
88 
90  typedef typename Superclass::JacobianType JacobianType;
91 
92  // / Standard matrix type for this class
93  typedef typename Superclass::MatrixType MatrixType;
94  typedef typename Superclass::MatrixValueType MatrixValueType;
95 
96  // / Standard vector type for this class
97  typedef typename Superclass::OffsetType OffsetType;
99 
100  // / Standard vector type for this class
101  typedef typename Superclass::InputVectorType InputVectorType;
102  typedef typename Superclass::OutputVectorType OutputVectorType;
103  typedef typename Superclass::OutputVectorValueType OutputVectorValueType;
104 
105  // / Standard covariant vector type for this class
106  typedef typename Superclass::InputCovariantVectorType InputCovariantVectorType;
107  typedef typename Superclass::OutputCovariantVectorType OutputCovariantVectorType;
108 
109  // / Standard vnl_vector type for this class
110  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
111  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
112 
113  // / Standard coordinate point type for this class
114  typedef typename Superclass::InputPointType InputPointType;
115  typedef typename Superclass::OutputPointType OutputPointType;
116 
119  typedef typename Superclass::InverseTransformBaseType InverseTransformBaseType;
120  typedef typename InverseTransformBaseType::Pointer InverseTransformBasePointer;
121 
134  virtual void SetMatrix(const MatrixType & matrix);
135 
143  void Translate(const OffsetType & offset, bool pre = false);
144 
153  inline InputPointType BackTransform(const OutputPointType & point) const;
154 
155  inline InputVectorType BackTransform(const OutputVectorType & vector) const;
156 
157  inline InputVnlVectorType BackTransform(const OutputVnlVectorType & vector) const;
158 
159  inline InputCovariantVectorType BackTransform(const OutputCovariantVectorType & vector) const;
160 
162  void SetAngle(TScalarType angle);
163 
164  itkGetConstReferenceMacro(Angle, TScalarType);
165 
167  void SetAngleInDegrees(TScalarType angle);
168 
172  void SetRotation(TScalarType angle)
173  {
174  this->SetAngle(angle);
175  }
176  virtual const TScalarType & GetRotation() const
177  {
178  return m_Angle;
179  }
181 
190  void SetParameters(const ParametersType & parameters);
191 
200  const ParametersType & GetParameters(void) const;
201 
204  virtual void ComputeJacobianWithRespectToParameters( const InputPointType & p, JacobianType & jacobian) const;
205 
210  void CloneInverseTo(Pointer & newinverse) const;
211 
213  bool GetInverse(Self *inverse) const;
214 
216  virtual InverseTransformBasePointer GetInverseTransform() const;
217 
222  void CloneTo(Pointer & clone) const;
223 
225  virtual void SetIdentity(void);
226 
227 #ifdef ITKV3_COMPATIBILITY
228 
234  itkLegacyMacro(virtual void SetRotationMatrix(const MatrixType & matrix));
235  itkLegacyMacro(const MatrixType & GetRotationMatrix() const);
236 #endif
237 
238 
239 
240 protected:
241  Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
242  Rigid2DTransform(unsigned int parametersDimension);
244 
245  ~Rigid2DTransform();
246 
250  void PrintSelf(std::ostream & os, Indent indent) const;
251 
255  virtual void ComputeMatrix(void);
256 
261  virtual void ComputeMatrixParameters(void);
262 
264  void SetVarAngle(TScalarType angle)
265  {
266  m_Angle = angle;
267  }
268 private:
269  Rigid2DTransform(const Self &); // purposely not implemented
270  void operator=(const Self &); // purposely not implemented
272 
273  TScalarType m_Angle;
274 
275 }; // class Rigid2DTransform
276 
277 // Back transform a point
278 template <class TScalarType>
279 inline
282 {
283  itkWarningMacro(
284  <<
285  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
286  );
287  return this->GetInverseMatrix() * ( point - this->GetOffset() );
288 }
289 
290 // Back transform a vector
291 template <class TScalarType>
292 inline
295 {
296  itkWarningMacro(
297  <<
298  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
299  );
300  return this->GetInverseMatrix() * vect;
301 }
302 
303 // Back transform a vnl_vector
304 template <class TScalarType>
305 inline
308 {
309  itkWarningMacro(
310  <<
311  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
312  );
313  return this->GetInverseMatrix() * vect;
314 }
315 
316 // Back Transform a CovariantVector
317 template <class TScalarType>
318 inline
321 {
322  itkWarningMacro(
323  <<
324  "BackTransform(): This method is slated to be removed from ITK. Instead, please use GetInverse() to generate an inverse transform and then perform the transform using that inverted transform."
325  );
326  return this->GetMatrix() * vect;
327 }
328 
329 } // namespace itk
330 
331 // Define instantiation macro for this template.
332 #define ITK_TEMPLATE_Rigid2DTransform(_, EXPORT, TypeX, TypeY) \
333  namespace itk \
334  { \
335  _( 1 ( class EXPORT Rigid2DTransform<ITK_TEMPLATE_1 TypeX> ) ) \
336  namespace Templates \
337  { \
338  typedef Rigid2DTransform<ITK_TEMPLATE_1 TypeX> Rigid2DTransform##TypeY; \
339  } \
340  }
341 
342 #if ITK_TEMPLATE_EXPLICIT
343 #include "Templates/itkRigid2DTransform+-.h"
344 #endif
345 
346 #if ITK_TEMPLATE_TXX
347 #include "itkRigid2DTransform.hxx"
348 #endif
349 
350 #endif /* __itkRigid2DTransform_h */
351