00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkQuaternionOrientationAdapter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2005-10-31 17:52:09 $ 00007 Version: $Revision: 1.2 $ 00008 00009 Copyright (c) Insight Software Consortium. All rights reserved. 00010 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. 00011 00012 Portions of this code are covered under the VTK copyright. 00013 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details. 00014 00015 This software is distributed WITHOUT ANY WARRANTY; without even 00016 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 PURPOSE. See the above copyright notices for more information. 00018 00019 =========================================================================*/ 00020 #ifndef __itkQuaternionOrientationAdapter_h 00021 #define __itkQuaternionOrientationAdapter_h 00022 #include "itkOrientationAdapter.h" 00023 #include "itkQuaternionRigidTransform.h" 00024 #include "itkConceptChecking.h" 00025 00026 namespace itk 00027 { 00031 namespace QuaternionOrientationAdapterClasses 00032 { 00033 typedef QuaternionRigidTransform<double> TransformType; 00034 typedef TransformType::Pointer TransformPointerType; 00035 } 00036 template <int Dimension> 00037 class QuaternionOrientationAdapter : 00038 public OrientationAdapterBase<QuaternionOrientationAdapterClasses::TransformPointerType,Dimension> 00039 { 00040 public: 00042 typedef QuaternionOrientationAdapter Self; 00043 00044 typedef OrientationAdapterBase<QuaternionOrientationAdapterClasses::TransformPointerType,Dimension> 00045 SuperClass; 00046 typedef QuaternionRigidTransform<double> OrientationRootType; 00047 typedef QuaternionOrientationAdapterClasses::TransformPointerType OrientationType; 00048 00050 itkConceptMacro(DimensionShouldBe3, 00051 (Concept::SameDimension<Dimension,3>)); 00052 00054 typedef typename SuperClass::DirectionType DirectionType; 00055 00057 virtual OrientationType FromDirectionCosines(const DirectionType &Dir) 00058 { 00059 OrientationType q = OrientationRootType::New(); 00060 q->SetMatrix(Dir); 00061 return q; 00062 } 00064 00066 virtual DirectionType ToDirectionCosines(const OrientationType &Or) 00067 { 00068 return Or->GetMatrix(); 00069 } 00070 00071 }; 00072 00073 } // namespace itk 00074 00075 00076 #endif // __itkQuaternionOrientationAdapter_h 00077