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 <cmtkconfig.h>
00034
00035 #include <Pipeline/cmtkPlane.h>
00036
00037 namespace
00038 cmtk
00039 {
00040
00043
00044 Plane::Plane()
00045 {
00046 Dims[0] = Dims[1] = 0;
00047 Spacing[0] = Spacing[1] = 1;
00048 Origin[0] = Origin[1] = Origin[2] = 0;
00049 DirectionX[0] = 1;
00050 DirectionY[1] = 1;
00051 DirectionX[1] = DirectionX[2] = DirectionY[0] = DirectionY[2] = 0;
00052 }
00053
00054 void Plane::CopyStructure( const Plane *plane )
00055 {
00056 this->SetDims( plane->GetDims() );
00057 this->SetSpacing( plane->GetSpacing() );
00058 this->SetOrigin( plane->GetOrigin() );
00059 this->SetDirectionX( plane->GetDirectionX() );
00060 this->SetDirectionY( plane->GetDirectionY() );
00061 }
00062
00063 void Plane::Project( Vector3D& p, const Vector3D& q ) const
00064 {
00065 Vector3D v( q );
00066 v[0] -= Origin[0];
00067 v[1] -= Origin[1];
00068 v[2] -= Origin[2];
00069
00070 p[0] =
00071 ( v[0] * DirectionX[0] + v[1] * DirectionX[1] + v[2] * DirectionX[2] ) /
00072 ( MathUtil::Square( DirectionX[0] ) + MathUtil::Square( DirectionX[1] ) + MathUtil::Square( DirectionX[2] ) );
00073 p[1] =
00074 ( v[0] * DirectionY[0] + v[1] * DirectionY[1] + v[2] * DirectionY[2] ) /
00075 ( MathUtil::Square( DirectionY[0] ) + MathUtil::Square( DirectionY[1] ) + MathUtil::Square( DirectionY[2] ) );
00076 p[2] = 0;
00077 }
00078
00079 void
00080 Plane::ProjectPixel( const Vector3D& v, unsigned int& i, unsigned int& j ) const
00081 {
00082 Vector3D q(v), p;
00083 this->Project( p, q );
00084
00085 i = MathUtil::Round( p[0] / Spacing[0] );
00086 j = MathUtil::Round( p[1] / Spacing[1] );
00087 }
00088
00089 }