00001 /*========================================================================= 00002 00003 Program: Insight Segmentation & Registration Toolkit 00004 Module: $RCSfile: itkQuaternionOrientationAdapter.h,v $ 00005 Language: C++ 00006 Date: $Date: 2009-03-03 15:08:22 $ 00007 Version: $Revision: 1.3 $ 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 typedef QuaternionRigidTransform<double> TransformType; 00033 typedef TransformType::Pointer TransformPointerType; 00034 } 00035 template <int VDimension> 00036 class QuaternionOrientationAdapter : 00037 public OrientationAdapterBase<QuaternionOrientationAdapterClasses::TransformPointerType,VDimension> 00038 { 00039 public: 00041 typedef QuaternionOrientationAdapter Self; 00042 00043 typedef OrientationAdapterBase<QuaternionOrientationAdapterClasses::TransformPointerType,VDimension> 00044 SuperClass; 00045 typedef QuaternionRigidTransform<double> OrientationRootType; 00046 typedef QuaternionOrientationAdapterClasses::TransformPointerType 00047 OrientationType; 00048 00050 itkConceptMacro(DimensionShouldBe3, 00051 (Concept::SameDimension<VDimension,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 }; 00072 00073 } // namespace itk 00074 00075 00076 #endif // __itkQuaternionOrientationAdapter_h 00077