Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkSpatialOrientationAdapter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSpatialOrientationAdapter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-03 15:09:35 $
00007   Version:   $Revision: 1.7 $
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 __itkSpatialOrientationAdapter_h
00021 #define __itkSpatialOrientationAdapter_h
00022 #include "itkOrientationAdapter.h"
00023 #include "itkSpatialOrientation.h"
00024 #include "itkConceptChecking.h"
00025 
00026 namespace itk
00027 {
00028 
00029 //
00030 // Helper functions, better than Macros
00031 //
00032 namespace Function
00033 {
00034 
00035 inline unsigned Max3(double x, double y, double z)
00036 {
00037   const double obliquityThresholdCosineValue = 0.001;
00038   
00039   double absX = vnl_math_abs(x);
00040   double absY = vnl_math_abs(y);
00041   double absZ = vnl_math_abs(z);
00042 
00043   if ( ( absX > obliquityThresholdCosineValue ) && ( absX > absY ) && ( absX > absZ ))
00044     {
00045     return 0;
00046     }
00047   else if (  ( absY > obliquityThresholdCosineValue ) && ( absY > absX ) && ( absY > absZ ) )
00048     {
00049     return 1;
00050     }
00051   else if ( ( absZ > obliquityThresholdCosineValue ) && ( absZ > absX ) && ( absZ > absY ) )
00052     {
00053     return 2;
00054     }
00055   // they must all be equal, so just say x
00056   return 0;
00057 }
00058 
00059 inline int Sign(double x)
00060 {
00061   if(x < 0)
00062     {
00063     return -1;
00064     }
00065   return 1;
00066 }
00067 
00068 } // namespace Function
00069 
00073 class ITKCommon_EXPORT SpatialOrientationAdapter : 
00074   public OrientationAdapterBase<SpatialOrientation::ValidCoordinateOrientationFlags,3>
00075 {
00076 public:
00078   typedef SpatialOrientationAdapter Self;
00079 
00080   typedef OrientationAdapterBase<SpatialOrientation::ValidCoordinateOrientationFlags,3>
00081   SuperClass;
00082 
00083   typedef SpatialOrientation::ValidCoordinateOrientationFlags OrientationType;
00084 
00086   typedef SuperClass::DirectionType DirectionType;
00087 
00089   SpatialOrientationAdapter() {};
00090 
00092   virtual OrientationType FromDirectionCosines(const DirectionType &Dir);
00093 
00095   virtual DirectionType ToDirectionCosines(const OrientationType &Or);
00096 
00097 };
00098 
00099 } // namespace itk
00100 
00101 #endif // __itkSpatialOrientationAdapter_h
00102 

Generated at Thu May 28 11:42:20 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000