Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __cmtkAnatomicalOrientation_h_included_
00034 #define __cmtkAnatomicalOrientation_h_included_
00035
00036 #include <cmtkconfig.h>
00037
00038 #include <Base/cmtkAnatomicalOrientationBase.h>
00039
00040 #include <System/cmtkSmartPtr.h>
00041
00042 #include <Base/cmtkTypes.h>
00043 #include <Base/cmtkFixedVector.h>
00044 #include <Base/cmtkMetaInformationObject.h>
00045 #include <Base/cmtkAffineXform.h>
00046
00047 namespace
00048 cmtk
00049 {
00050
00053
00055 class AnatomicalOrientation
00056 : public AnatomicalOrientationBase
00057 {
00058 public:
00060 typedef AnatomicalOrientation Self;
00061
00063 typedef AnatomicalOrientationBase Superclass;
00064
00074 static void GetOrientationFromDirections( char* orientation, const AffineXform::MatrixType& directions, const char* spaceAxes );
00075
00077 static void GetImageToSpaceAxesPermutation( int (&imageToSpaceAxesPermutation)[3][3], const char* orientation, const char* spaceAxes );
00078
00080 class PermutationMatrix
00081 {
00082 public:
00084 typedef PermutationMatrix Self;
00085
00087 typedef SmartPointer<Self> SmartPtr;
00088
00090 PermutationMatrix( const FixedVector<3,int>& sourceDims, const std::string& curOrientation, const char newOrientation[3] );
00091
00098 template<class T>
00099 const FixedVector<3,T> GetPermutedArray( const FixedVector<3,T>& source ) const
00100 {
00101 FixedVector<3,T> target;
00102 for ( int i = 0; i < 3; i++ )
00103 {
00104 target[i] = source[this->m_Axes[i]];
00105 }
00106 return target;
00107 }
00108
00111 AffineXform::MatrixType GetPermutedMatrix( const AffineXform::MatrixType& inMatrix ) const;
00112
00117 void GetReorientedIndex( const int* origPoint, int* newPoint ) const
00118 {
00119 for ( int i = 0; i < 3; ++i )
00120 newPoint[i] = this->m_Multipliers[i] * origPoint[this->m_Axes[i]] + this->m_Offsets[i];
00121 }
00122
00127 size_t NewOffsetFromPoint( const int* origPoint ) const
00128 {
00129 return ( this->m_Multipliers[0] * origPoint[this->m_Axes[0]] + this->m_Offsets[0] ) +
00130 this->m_NewDims[0] *
00131 ( ( this->m_Multipliers[1] * origPoint[this->m_Axes[1]] + this->m_Offsets[1] ) +
00132 this->m_NewDims[1] *
00133 ( this->m_Multipliers[2] * origPoint[this->m_Axes[2]] + this->m_Offsets[2] ) );
00134 }
00135
00136 private:
00144 FixedVector<3,int> m_Axes;
00145
00151 FixedVector<3,int> m_Multipliers;
00152
00156 FixedVector<3,int> m_NewDims;
00157
00164 FixedVector<3,int> m_Offsets;
00165 };
00166 };
00167
00169
00170 }
00171
00172 #endif // #ifndef __cmtkAnatomicalOrientation_h_included_