ITK
4.1.0
Insight Segmentation and Registration Toolkit
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 /*========================================================================= 00019 * 00020 * Portions of this file are subject to the VTK Toolkit Version 3 copyright. 00021 * 00022 * Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00023 * 00024 * For complete copyright, license and disclaimer of warranty information 00025 * please refer to the NOTICE file at the top of the ITK source tree. 00026 * 00027 *=========================================================================*/ 00028 #ifndef __itkSpatialOrientationAdapter_h 00029 #define __itkSpatialOrientationAdapter_h 00030 #include "itkOrientationAdapterBase.h" 00031 #include "itkSpatialOrientation.h" 00032 #include "itkConceptChecking.h" 00033 00034 namespace itk 00035 { 00036 // 00037 // Helper functions, better than Macros 00038 // 00039 namespace Function 00040 { 00041 inline unsigned Max3(double x, double y, double z) 00042 { 00043 const double obliquityThresholdCosineValue = 0.001; 00044 00045 double absX = vnl_math_abs(x); 00046 double absY = vnl_math_abs(y); 00047 double absZ = vnl_math_abs(z); 00048 00049 if ( ( absX > obliquityThresholdCosineValue ) && ( absX > absY ) && ( absX > absZ ) ) 00050 { 00051 return 0; 00052 } 00053 else if ( ( absY > obliquityThresholdCosineValue ) && ( absY > absX ) && ( absY > absZ ) ) 00054 { 00055 return 1; 00056 } 00057 else if ( ( absZ > obliquityThresholdCosineValue ) && ( absZ > absX ) && ( absZ > absY ) ) 00058 { 00059 return 2; 00060 } 00061 // they must all be equal, so just say x 00062 return 0; 00063 } 00064 00065 inline int Sign(double x) 00066 { 00067 if ( x < 0 ) 00068 { 00069 return -1; 00070 } 00071 return 1; 00072 } 00073 } // namespace Function 00074 00079 class ITKCommon_EXPORT SpatialOrientationAdapter: 00080 public OrientationAdapterBase< SpatialOrientation::ValidCoordinateOrientationFlags, 3 > 00081 { 00082 public: 00084 typedef SpatialOrientationAdapter Self; 00085 00086 typedef OrientationAdapterBase< SpatialOrientation::ValidCoordinateOrientationFlags, 3 > 00087 SuperClass; 00088 00089 typedef SpatialOrientation::ValidCoordinateOrientationFlags OrientationType; 00090 00092 typedef SuperClass::DirectionType DirectionType; 00093 00095 SpatialOrientationAdapter() {} 00096 00098 virtual OrientationType FromDirectionCosines(const DirectionType & Dir); 00099 00101 virtual DirectionType ToDirectionCosines(const OrientationType & Or); 00102 }; 00103 } // namespace itk 00104 00105 #endif // __itkSpatialOrientationAdapter_h 00106