VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPlane.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00030 #ifndef __vtkPlane_h 00031 #define __vtkPlane_h 00032 00033 #include "vtkImplicitFunction.h" 00034 00035 class VTK_COMMON_EXPORT vtkPlane : public vtkImplicitFunction 00036 { 00037 public: 00039 static vtkPlane *New(); 00040 00041 vtkTypeMacro(vtkPlane,vtkImplicitFunction); 00042 void PrintSelf(ostream& os, vtkIndent indent); 00043 00045 00046 double EvaluateFunction(double x[3]); 00047 double EvaluateFunction(double x, double y, double z) 00048 {return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ; 00050 00052 void EvaluateGradient(double x[3], double g[3]); 00053 00055 00056 vtkSetVector3Macro(Normal,double); 00057 vtkGetVectorMacro(Normal,double,3); 00059 00061 00063 vtkSetVector3Macro(Origin,double); 00064 vtkGetVectorMacro(Origin,double,3); 00066 00069 void Push(double distance); 00070 00072 00075 static void ProjectPoint(double x[3], double origin[3], double normal[3], 00076 double xproj[3]); 00077 void ProjectPoint(double x[3], double xproj[3]); 00079 00081 00083 static void ProjectVector(double v[3], double origin[3], double normal[3], 00084 double vproj[3]); 00085 void ProjectVector(double v[3], double vproj[3]); 00087 00089 00092 static void GeneralizedProjectPoint(double x[3], double origin[3], 00093 double normal[3], double xproj[3]); 00094 void GeneralizedProjectPoint(double x[3], double xproj[3]); 00096 00097 00099 static double Evaluate(double normal[3], double origin[3], double x[3]); 00100 00102 00104 static double DistanceToPlane(double x[3], double n[3], double p0[3]); 00105 double DistanceToPlane(double x[3]); 00107 00109 00115 static int IntersectWithLine(double p1[3], double p2[3], double n[3], 00116 double p0[3], double& t, double x[3]); 00117 int IntersectWithLine(double p1[3], double p2[3], double& t, double x[3]); 00119 00120 protected: 00121 vtkPlane(); 00122 ~vtkPlane() {}; 00123 00124 double Normal[3]; 00125 double Origin[3]; 00126 00127 private: 00128 vtkPlane(const vtkPlane&); // Not implemented. 00129 void operator=(const vtkPlane&); // Not implemented. 00130 }; 00131 00132 inline double vtkPlane::Evaluate(double normal[3], 00133 double origin[3], double x[3]) 00134 { 00135 return normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) + 00136 normal[2]*(x[2]-origin[2]); 00137 } 00138 00139 inline double vtkPlane::DistanceToPlane(double x[3], double n[3], double p0[3]) 00140 { 00141 #define vtkPlaneAbs(x) ((x)<0?-(x):(x)) 00142 return (vtkPlaneAbs(n[0]*(x[0]-p0[0]) + n[1]*(x[1]-p0[1]) + 00143 n[2]*(x[2]-p0[2]))); 00144 } 00145 00146 #endif 00147 00148