| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkQuaternionOrientationAdapter.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:46 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
Portions of this code are covered under the VTK copyright. |
| 13 |
|
See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. |
| 14 |
|
|
| 15 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 16 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 17 |
IND |
*****PURPOSE. See the above copyright notices for more information. |
| 18 |
|
|
| 19 |
|
=========================================================================*/ |
| 20 |
|
#ifndef __itkQuaternionOrientationAdapter_h |
| 21 |
|
#define __itkQuaternionOrientationAdapter_h |
| 22 |
|
#include "itkOrientationAdapter.h" |
| 23 |
|
#include "itkQuaternionRigidTransform.h" |
| 24 |
|
#include "itkConceptChecking.h" |
| 25 |
|
|
| 26 |
|
namespace itk |
| 27 |
|
{ |
| 28 |
|
/** \class QuaternionOrientationAdapter |
| 29 |
|
* \brief converts QuaternionOrientation flags to/from direction cosines |
| 30 |
|
*/ |
| 31 |
|
namespace QuaternionOrientationAdapterClasses |
| 32 |
IND |
**{ |
| 33 |
IND |
****typedef QuaternionRigidTransform<double> TransformType; |
| 34 |
TDA,IND |
****typedef TransformType::Pointer TransformPointerType; |
| 35 |
IND |
**} |
| 36 |
|
template <int Dimension> |
| 37 |
|
class QuaternionOrientationAdapter : |
| 38 |
LEN,IND |
****public OrientationAdapterBase<QuaternionOrientationAdapterClasses::TransformPointerType,Dimension> |
| 39 |
|
{ |
| 40 |
|
public: |
| 41 |
|
/** typedef for superclass */ |
| 42 |
|
typedef QuaternionOrientationAdapter Self; |
| 43 |
|
|
| 44 |
LEN |
typedef OrientationAdapterBase<QuaternionOrientationAdapterClasses::TransformPointerType,Dimension> |
| 45 |
|
SuperClass; |
| 46 |
TDA |
typedef QuaternionRigidTransform<double> OrientationRootType; |
| 47 |
LEN,TDA |
typedef QuaternionOrientationAdapterClasses::TransformPointerType OrientationType; |
| 48 |
|
|
| 49 |
|
/** The dimension of the input image must be 3. */ |
| 50 |
|
itkConceptMacro(DimensionShouldBe3, |
| 51 |
|
(Concept::SameDimension<Dimension,3>)); |
| 52 |
|
|
| 53 |
|
/** typedef for direction cosines */ |
| 54 |
|
typedef typename SuperClass::DirectionType DirectionType; |
| 55 |
|
|
| 56 |
|
/** convert from direction cosines. */ |
| 57 |
|
virtual OrientationType FromDirectionCosines(const DirectionType &Dir) |
| 58 |
IND |
**{ |
| 59 |
|
OrientationType q = OrientationRootType::New(); |
| 60 |
|
q->SetMatrix(Dir); |
| 61 |
|
return q; |
| 62 |
IND |
**} |
| 63 |
|
|
| 64 |
|
/** convert to direction cosines. */ |
| 65 |
|
virtual DirectionType ToDirectionCosines(const OrientationType &Or) |
| 66 |
IND |
**{ |
| 67 |
|
return Or->GetMatrix(); |
| 68 |
IND |
**} |
| 69 |
|
|
| 70 |
|
}; |
| 71 |
|
|
| 72 |
|
} // namespace itk |
| 73 |
|
|
| 74 |
|
|
| 75 |
|
#endif // __itkQuaternionOrientationAdapter_h |
| 76 |
|
|