ITK  4.3.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 protected:
240  Rigid2DTransform(unsigned int outputSpaceDimension, unsigned int parametersDimension);
241  Rigid2DTransform(unsigned int parametersDimension);
243 
244  ~Rigid2DTransform();
245 
249  void PrintSelf(std::ostream & os, Indent indent) const;
250 
254  virtual void ComputeMatrix(void);
255 
260  virtual void ComputeMatrixParameters(void);
261 
263  void SetVarAngle(TScalarType angle)
264  {
265  m_Angle = angle;
266  }
267 
268 private:
269  Rigid2DTransform(const Self &); // purposely not implemented
270  void operator=(const Self &); // purposely not implemented
271 
272  TScalarType m_Angle;
273 
274 }; // class Rigid2DTransform
275 
276 // Back transform a point
277 template <class TScalarType>
278 inline
281 {
282  itkWarningMacro(
283  <<
284  "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."
285  );
286  return this->GetInverseMatrix() * ( point - this->GetOffset() );
287 }
288 
289 // Back transform a vector
290 template <class TScalarType>
291 inline
294 {
295  itkWarningMacro(
296  <<
297  "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."
298  );
299  return this->GetInverseMatrix() * vect;
300 }
301 
302 // Back transform a vnl_vector
303 template <class TScalarType>
304 inline
307 {
308  itkWarningMacro(
309  <<
310  "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."
311  );
312  return this->GetInverseMatrix() * vect;
313 }
314 
315 // Back Transform a CovariantVector
316 template <class TScalarType>
317 inline
320 {
321  itkWarningMacro(
322  <<
323  "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."
324  );
325  return this->GetMatrix() * vect;
326 }
327 
328 } // namespace itk
329 
330 #ifndef ITK_MANUAL_INSTANTIATION
331 #include "itkRigid2DTransform.hxx"
332 #endif
333 
334 #endif /* __itkRigid2DTransform_h */
335