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 "cmtkTransformedVolumeAxes.h"
00034
00035 #include <cassert>
00036
00037 namespace
00038 cmtk
00039 {
00040
00043
00044 TransformedVolumeAxes::TransformedVolumeAxes
00045 ( const UniformVolume& volume, const AffineXform* xform, const Types::Coordinate* deltas, const Types::Coordinate* otherOrigin )
00046 {
00047
00048 UniformVolume::CoordinateVectorType dX = FixedVectorStaticInitializer<3,Types::Coordinate>::Init(1,0,0);
00049 UniformVolume::CoordinateVectorType dY = FixedVectorStaticInitializer<3,Types::Coordinate>::Init(0,1,0);
00050 UniformVolume::CoordinateVectorType dZ = FixedVectorStaticInitializer<3,Types::Coordinate>::Init(0,0,1);
00051 UniformVolume::CoordinateVectorType V( volume.m_Offset );
00052
00053 dX += volume.m_Offset;
00054 dY += volume.m_Offset;
00055 dZ += volume.m_Offset;
00056
00057 if ( xform )
00058 {
00059 xform->ApplyInPlace(V);
00060 xform->ApplyInPlace(dX);
00061 xform->ApplyInPlace(dY);
00062 xform->ApplyInPlace(dZ);
00063 }
00064
00065 dX -= V;
00066 dY -= V;
00067 dZ -= V;
00068
00069 if ( otherOrigin )
00070 {
00071 V -= FixedVector<3,Types::Coordinate>( otherOrigin );
00072 }
00073
00074
00075 if ( deltas )
00076 {
00077 const UniformVolume::CoordinateVectorType deltasV( deltas );
00078 dX /= deltasV;
00079 dY /= deltasV;
00080 dZ /= deltasV;
00081 V /= deltasV;
00082 }
00083
00084 this->MakeHash( volume, V, dX, dY, dZ );
00085 }
00086
00087 TransformedVolumeAxes::TransformedVolumeAxes
00088 ( const UniformVolume& volume, const ParametricPlane& mirrorPlane, const Types::Coordinate* deltas )
00089 {
00090
00091 UniformVolume::CoordinateVectorType dX = FixedVectorStaticInitializer<3,Types::Coordinate>::Init(1,0,0);
00092 UniformVolume::CoordinateVectorType dY = FixedVectorStaticInitializer<3,Types::Coordinate>::Init(0,1,0);
00093 UniformVolume::CoordinateVectorType dZ = FixedVectorStaticInitializer<3,Types::Coordinate>::Init(0,0,1);
00094 UniformVolume::CoordinateVectorType V( volume.m_Offset );
00095
00096
00097 mirrorPlane.MirrorInPlace(V);
00098 mirrorPlane.MirrorInPlace(dX);
00099 dX -= V;
00100 mirrorPlane.MirrorInPlace(dY);
00101 dY -= V;
00102 mirrorPlane.MirrorInPlace(dZ);
00103 dZ -= V;
00104
00105
00106 if ( deltas )
00107 {
00108 const UniformVolume::CoordinateVectorType deltasV( deltas );
00109 dX /= deltasV;
00110 dY /= deltasV;
00111 dZ /= deltasV;
00112 V /= deltasV;
00113 }
00114
00115 this->MakeHash( volume, V, dX, dY, dZ );
00116 }
00117
00118 void
00119 TransformedVolumeAxes::MakeHash
00120 ( const UniformVolume& volume, const UniformVolume::SpaceVectorType& offset, const UniformVolume::SpaceVectorType& dX, const UniformVolume::SpaceVectorType& dY, const UniformVolume::SpaceVectorType& dZ )
00121 {
00122 this->m_Dims = volume.m_Dims;
00123 for ( int dim = 0; dim<3; ++dim )
00124 {
00125 this->m_Hash[dim] = Memory::AllocateArray<UniformVolume::SpaceVectorType>( this->m_Dims[dim] );
00126 assert( this->m_Hash[dim] != NULL );
00127 }
00128
00129 const Types::Coordinate deltaX = volume.m_Delta[0];
00130 const Types::Coordinate deltaY = volume.m_Delta[1];
00131 const Types::Coordinate deltaZ = volume.m_Delta[2];
00132
00133 int idx;
00134 for ( idx=0; idx < this->m_Dims[0]; ++idx )
00135 this->m_Hash[0][idx] = deltaX*idx*dX;
00136
00137 for ( idx=0; idx < this->m_Dims[1]; ++idx )
00138 this->m_Hash[1][idx] = deltaY*idx*dY;
00139
00140 for ( idx=0; idx < this->m_Dims[2]; ++idx )
00141 (this->m_Hash[2][idx] = deltaZ*idx*dZ) += offset;
00142 }
00143
00144 TransformedVolumeAxes::~TransformedVolumeAxes()
00145 {
00146 for ( int dim = 0; dim<3; ++dim )
00147 {
00148 assert( this->m_Hash[dim] != NULL );
00149 Memory::DeleteArray( this->m_Hash[dim] );
00150 }
00151 }
00152
00153 }