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 "vtkCommonDataModelModule.h" // For export macro 00034 #include "vtkImplicitFunction.h" 00035 00036 class VTKCOMMONDATAMODEL_EXPORT vtkPlane : public vtkImplicitFunction 00037 { 00038 public: 00040 static vtkPlane *New(); 00041 00042 vtkTypeMacro(vtkPlane,vtkImplicitFunction); 00043 void PrintSelf(ostream& os, vtkIndent indent); 00044 00046 00047 double EvaluateFunction(double x[3]); 00048 double EvaluateFunction(double x, double y, double z) 00049 {return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ; 00051 00053 void EvaluateGradient(double x[3], double g[3]); 00054 00056 00057 vtkSetVector3Macro(Normal,double); 00058 vtkGetVectorMacro(Normal,double,3); 00060 00062 00064 vtkSetVector3Macro(Origin,double); 00065 vtkGetVectorMacro(Origin,double,3); 00067 00070 void Push(double distance); 00071 00073 00076 static void ProjectPoint(double x[3], double origin[3], double normal[3], 00077 double xproj[3]); 00078 void ProjectPoint(double x[3], double xproj[3]); 00080 00082 00084 static void ProjectVector(double v[3], double origin[3], double normal[3], 00085 double vproj[3]); 00086 void ProjectVector(double v[3], double vproj[3]); 00088 00090 00093 static void GeneralizedProjectPoint(double x[3], double origin[3], 00094 double normal[3], double xproj[3]); 00095 void GeneralizedProjectPoint(double x[3], double xproj[3]); 00097 00098 00100 static double Evaluate(double normal[3], double origin[3], double x[3]); 00101 00103 00105 static double DistanceToPlane(double x[3], double n[3], double p0[3]); 00106 double DistanceToPlane(double x[3]); 00108 00110 00116 static int IntersectWithLine(double p1[3], double p2[3], double n[3], 00117 double p0[3], double& t, double x[3]); 00118 int IntersectWithLine(double p1[3], double p2[3], double& t, double x[3]); 00120 00121 protected: 00122 vtkPlane(); 00123 ~vtkPlane() {} 00124 00125 double Normal[3]; 00126 double Origin[3]; 00127 00128 private: 00129 vtkPlane(const vtkPlane&); // Not implemented. 00130 void operator=(const vtkPlane&); // Not implemented. 00131 }; 00132 00133 inline double vtkPlane::Evaluate(double normal[3], 00134 double origin[3], double x[3]) 00135 { 00136 return normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) + 00137 normal[2]*(x[2]-origin[2]); 00138 } 00139 00140 inline double vtkPlane::DistanceToPlane(double x[3], double n[3], double p0[3]) 00141 { 00142 #define vtkPlaneAbs(x) ((x)<0?-(x):(x)) 00143 return (vtkPlaneAbs(n[0]*(x[0]-p0[0]) + n[1]*(x[1]-p0[1]) + 00144 n[2]*(x[2]-p0[2]))); 00145 } 00146 00147 #endif 00148 00149