Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "vtkThickPlane.h"
00015 #include "vtkMath.h"
00016 #include "vtkObjectFactory.h"
00017
00018 vtkCxxRevisionMacro(vtkThickPlane, "$Revision: 1.41 $");
00019 vtkStandardNewMacro(vtkThickPlane);
00020
00021
00022 vtkThickPlane::vtkThickPlane()
00023 {
00024 this->Normal[0] = 0.0;
00025 this->Normal[1] = 0.0;
00026 this->Normal[2] = 1.0;
00027
00028 this->Origin[0] = 0.0;
00029 this->Origin[1] = 0.0;
00030 this->Origin[2] = 0.0;
00031 }
00032
00033
00034 double vtkThickPlane::EvaluateFunction(double x[3])
00035 {
00036 return this->EvaluateFunction(x[0],x[1],x[2]);
00037 }
00038
00039
00040 double vtkThickPlane::EvaluateFunction(double x,double y,double z)
00041 {
00042
00043 double ppd = Distance - ( this->Normal[0]*x +
00044 this->Normal[1]*y +
00045 this->Normal[2]*z );
00046
00047 if( abs(ppd) <= Thickness )
00048 {
00049 count++;
00050 return 0;
00051 }
00052
00053 if( ppd >= 0 )
00054 return ppd - Thickness;
00055
00056 return abs(ppd + Thickness);
00057 }
00058
00059
00060 void vtkThickPlane::EvaluateGradient(double vtkNotUsed(x)[3], double n[3])
00061 {
00062 for (int i=0; i<3; i++)
00063 {
00064 n[i] = this->Normal[i];
00065 }
00066 }
00067
00068 void vtkThickPlane::SetPose (double _n1, double _n2, double _n3, double _o1, double _o2, double _o3)
00069 {
00070 SetNormal(_n1,_n2,_n3);
00071 SetOrigin(_o1,_o2,_o3);
00072 Distance = Normal[0]*Origin[0]+Normal[1]*Origin[1]+Normal[2]*Origin[2];
00073 if(Distance < 0.0)
00074 {
00075 Distance = -Distance;
00076 Normal[0] = -Normal[0];
00077 Normal[1] = -Normal[1];
00078 Normal[2] = -Normal[2];
00079 }
00080 }
00081
00082 void vtkThickPlane::SetPose (double _n[3], double _o[3])
00083 {
00084 SetPose(_n[0],_n[1],_n[2],_o[0],_o[1],_o[2]);
00085 }
00086
00087 void vtkThickPlane::SetNormal (double _arg1, double _arg2, double _arg3)
00088 {
00089 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << Normal << " to (" << _arg1 << "," << _arg2 << "," << _arg3 << ")");
00090 if ((this->Normal[0] != _arg1)||(this->Normal[1] != _arg2)||(this->Normal[2] != _arg3))
00091 {
00092 double length = sqrt(_arg1*_arg1+_arg2*_arg2+_arg3*_arg3);
00093 this->Normal[0] = _arg1/length;
00094 this->Normal[1] = _arg2/length;
00095 this->Normal[2] = _arg3/length;
00096 this->Modified();
00097 }
00098 };
00099
00100 void vtkThickPlane::SetNormal (double _arg[3])
00101 {
00102 this->SetNormal (_arg[0], _arg[1], _arg[2]);
00103 }
00104
00105 void vtkThickPlane::SetOrigin (double _arg1, double _arg2, double _arg3)
00106 {
00107 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << Origin << " to (" << _arg1 << "," << _arg2 << "," << _arg3 << ")");
00108 if ((this->Normal[0] != _arg1)||(this->Normal[1] != _arg2)||(this->Normal[2] != _arg3))
00109 {
00110 this->Origin[0] = _arg1;
00111 this->Origin[1] = _arg2;
00112 this->Origin[2] = _arg3;
00113 this->Modified();
00114 }
00115 };
00116
00117 void vtkThickPlane::SetOrigin (double _arg[3])
00118 {
00119 this->SetOrigin (_arg[0], _arg[1], _arg[2]);
00120 }
00121
00122 void vtkThickPlane::SetThickness (double _arg)
00123 {
00124 Thickness = abs(_arg);
00125 }
00126
00127 #define VTK_PLANE_TOL 1.0e-06
00128
00129 void vtkThickPlane::PrintSelf(ostream& os, vtkIndent indent)
00130 {
00131 this->Superclass::PrintSelf(os,indent);
00132
00133 os << indent << "Normal: (" << this->Normal[0] << ", "
00134 << this->Normal[1] << ", " << this->Normal[2] << ")\n";
00135
00136 os << indent << "Origin: (" << this->Origin[0] << ", "
00137 << this->Origin[1] << ", " << this->Origin[2] << ")\n";
00138
00139 os << indent << "Thickness: " << this->Thickness << "\n";
00140 }