VTK
vtkPlane.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPlane.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
30 #ifndef __vtkPlane_h
31 #define __vtkPlane_h
32 
33 #include "vtkImplicitFunction.h"
34 
36 {
37 public:
39  static vtkPlane *New();
40 
42  void PrintSelf(ostream& os, vtkIndent indent);
43 
45 
46  double EvaluateFunction(double x[3]);
47  double EvaluateFunction(double x, double y, double z)
48  {return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ;
50 
52  void EvaluateGradient(double x[3], double g[3]);
53 
55 
56  vtkSetVector3Macro(Normal,double);
57  vtkGetVectorMacro(Normal,double,3);
59 
61 
63  vtkSetVector3Macro(Origin,double);
64  vtkGetVectorMacro(Origin,double,3);
66 
69  void Push(double distance);
70 
72 
75  static void ProjectPoint(double x[3], double origin[3], double normal[3],
76  double xproj[3]);
77  void ProjectPoint(double x[3], double xproj[3]);
79 
81 
83  static void ProjectVector(double v[3], double origin[3], double normal[3],
84  double vproj[3]);
85  void ProjectVector(double v[3], double vproj[3]);
87 
89 
92  static void GeneralizedProjectPoint(double x[3], double origin[3],
93  double normal[3], double xproj[3]);
94  void GeneralizedProjectPoint(double x[3], double xproj[3]);
96 
97 
99  static double Evaluate(double normal[3], double origin[3], double x[3]);
100 
102 
104  static double DistanceToPlane(double x[3], double n[3], double p0[3]);
105  double DistanceToPlane(double x[3]);
107 
109 
115  static int IntersectWithLine(double p1[3], double p2[3], double n[3],
116  double p0[3], double& t, double x[3]);
117  int IntersectWithLine(double p1[3], double p2[3], double& t, double x[3]);
119 
120 protected:
121  vtkPlane();
122  ~vtkPlane() {};
123 
124  double Normal[3];
125  double Origin[3];
126 
127 private:
128  vtkPlane(const vtkPlane&); // Not implemented.
129  void operator=(const vtkPlane&); // Not implemented.
130 };
131 
132 inline double vtkPlane::Evaluate(double normal[3],
133  double origin[3], double x[3])
134 {
135  return normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) +
136  normal[2]*(x[2]-origin[2]);
137 }
138 
139 inline double vtkPlane::DistanceToPlane(double x[3], double n[3], double p0[3])
140 {
141 #define vtkPlaneAbs(x) ((x)<0?-(x):(x))
142  return (vtkPlaneAbs(n[0]*(x[0]-p0[0]) + n[1]*(x[1]-p0[1]) +
143  n[2]*(x[2]-p0[2])));
144 }
145 
146 #endif
147 
148