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 #include "cmtkAnatomicalOrientation.h"
00034
00035 #include <string>
00036 #include <iostream>
00037
00038 namespace
00039 cmtk
00040 {
00041
00044
00045 AnatomicalOrientation::PermutationMatrix::PermutationMatrix
00046 ( const FixedVector<3,int>& sourceDims, const std::string& curOrientation, const char newOrientation[3] )
00047 {
00048
00049 for ( int i = 0; i < 3; i++ )
00050 {
00051 for ( int j = 0; j < 3; j++ )
00052 {
00053 if ( newOrientation[i] == curOrientation[j] )
00054 {
00055 this->m_Axes[i] = j;
00056 this->m_Multipliers[i] = 1;
00057 this->m_Offsets[i] = 0;
00058 break;
00059 }
00060 else if ( AnatomicalOrientation::OnSameAxis( newOrientation[i], curOrientation[j] ) )
00061 {
00062 this->m_Axes[i] = j;
00063 this->m_Multipliers[i] = -1;
00064 this->m_Offsets[i] = sourceDims[j] - 1;
00065 break;
00066 }
00067 }
00068 }
00069
00070 this->m_NewDims = this->GetPermutedArray( sourceDims );
00071 }
00072
00073 AffineXform::MatrixType
00074 AnatomicalOrientation::PermutationMatrix::GetPermutedMatrix( const AffineXform::MatrixType& inMatrix ) const
00075 {
00076 AffineXform::MatrixType permutation;
00077
00078 for ( int j = 0; j < 3; ++j )
00079 {
00080 for ( int i = 0; i < 3; ++i )
00081 {
00082 if ( i == this->m_Axes[j] )
00083 permutation[i][j] = this->m_Multipliers[j];
00084 else
00085 permutation[i][j] = 0;
00086 }
00087
00088 permutation[3][j] = this->m_Offsets[j];
00089 }
00090
00091 return permutation.GetInverse() * inMatrix;
00092 }
00093
00094 }