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 =========================================================================*/
31 #ifndef vtkPlane_h
32 #define vtkPlane_h
33 
34 #include "vtkCommonDataModelModule.h" // For export macro
35 #include "vtkImplicitFunction.h"
36 
37 class VTKCOMMONDATAMODEL_EXPORT vtkPlane : public vtkImplicitFunction
38 {
39 public:
43  static vtkPlane *New();
44 
46  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
47 
49 
52  double EvaluateFunction(double x[3]) VTK_OVERRIDE;
53  double EvaluateFunction(double x, double y, double z)
54  {return this->vtkImplicitFunction::EvaluateFunction(x, y, z); } ;
56 
60  void EvaluateGradient(double x[3], double g[3]) VTK_OVERRIDE;
61 
63 
66  vtkSetVector3Macro(Normal,double);
67  vtkGetVectorMacro(Normal,double,3);
69 
71 
75  vtkSetVector3Macro(Origin,double);
76  vtkGetVectorMacro(Origin,double,3);
78 
84  void Push(double distance);
85 
87 
92  static void ProjectPoint(double x[3], double origin[3], double normal[3],
93  double xproj[3]);
94  void ProjectPoint(double x[3], double xproj[3]);
96 
98 
102  static void ProjectVector(double v[3], double origin[3], double normal[3],
103  double vproj[3]);
104  void ProjectVector(double v[3], double vproj[3]);
106 
108 
113  static void GeneralizedProjectPoint(double x[3], double origin[3],
114  double normal[3], double xproj[3]);
115  void GeneralizedProjectPoint(double x[3], double xproj[3]);
117 
118 
122  static double Evaluate(double normal[3], double origin[3], double x[3]);
123 
125 
129  static double DistanceToPlane(double x[3], double n[3], double p0[3]);
130  double DistanceToPlane(double x[3]);
132 
134 
142  static int IntersectWithLine(double p1[3], double p2[3], double n[3],
143  double p0[3], double& t, double x[3]);
144  int IntersectWithLine(double p1[3], double p2[3], double& t, double x[3]);
146 
147 protected:
149  ~vtkPlane() VTK_OVERRIDE {}
150 
151  double Normal[3];
152  double Origin[3];
153 
154 private:
155  vtkPlane(const vtkPlane&) VTK_DELETE_FUNCTION;
156  void operator=(const vtkPlane&) VTK_DELETE_FUNCTION;
157 };
158 
159 inline double vtkPlane::Evaluate(double normal[3],
160  double origin[3], double x[3])
161 {
162  return normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) +
163  normal[2]*(x[2]-origin[2]);
164 }
165 
166 inline double vtkPlane::DistanceToPlane(double x[3], double n[3], double p0[3])
167 {
168 #define vtkPlaneAbs(x) ((x)<0?-(x):(x))
169  return (vtkPlaneAbs(n[0]*(x[0]-p0[0]) + n[1]*(x[1]-p0[1]) +
170  n[2]*(x[2]-p0[2])));
171 }
172 
173 #endif
174 
175 
vtkPlane
perform various plane computations
Definition: vtkPlane.h:38
vtkPlane::Evaluate
static double Evaluate(double normal[3], double origin[3], double x[3])
Quick evaluation of plane equation n(x-origin)=0.
Definition: vtkPlane.h:159
vtkPlane::ProjectPoint
void ProjectPoint(double x[3], double xproj[3])
vtkPlane::EvaluateFunction
double EvaluateFunction(double x[3]) override
Evaluate plane equation for point x[3].
vtkPlane::ProjectPoint
static void ProjectPoint(double x[3], double origin[3], double normal[3], double xproj[3])
Project a point x onto plane defined by origin and normal.
vtkX3D::Normal
@ Normal
Definition: vtkX3D.h:45
vtkImplicitFunction::EvaluateFunction
virtual double EvaluateFunction(double x[3])=0
Evaluate function at position x-y-z and return value.
vtkPlane::EvaluateFunction
double EvaluateFunction(double x, double y, double z)
Definition: vtkPlane.h:53
vtkPlane::GeneralizedProjectPoint
static void GeneralizedProjectPoint(double x[3], double origin[3], double normal[3], double xproj[3])
Project a point x onto plane defined by origin and normal.
vtkPlane::ProjectVector
void ProjectVector(double v[3], double vproj[3])
vtkPlane::EvaluateGradient
void EvaluateGradient(double x[3], double g[3]) override
Evaluate function gradient at point x[3].
vtkPlaneAbs
#define vtkPlaneAbs(x)
vtkPlane::~vtkPlane
~vtkPlane() override
Definition: vtkPlane.h:149
vtkImplicitFunction
abstract interface for implicit functions
Definition: vtkImplicitFunction.h:59
vtkPlane::IntersectWithLine
static int IntersectWithLine(double p1[3], double p2[3], double n[3], double p0[3], double &t, double x[3])
Given a line defined by the two points p1,p2; and a plane defined by the normal n and point p0,...
vtkPlane::DistanceToPlane
static double DistanceToPlane(double x[3], double n[3], double p0[3])
Return the distance of a point x to a plane defined by n(x-p0) = 0.
Definition: vtkPlane.h:166
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkPlane::IntersectWithLine
int IntersectWithLine(double p1[3], double p2[3], double &t, double x[3])
vtkPlane::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPlane::ProjectVector
static void ProjectVector(double v[3], double origin[3], double normal[3], double vproj[3])
Project a vector v onto plane defined by origin and normal.
vtkPlane::DistanceToPlane
double DistanceToPlane(double x[3])
vtkPlane::Push
void Push(double distance)
Translate the plane in the direction of the normal by the distance specified.
vtkPlane::vtkPlane
vtkPlane()
vtkPlane::GeneralizedProjectPoint
void GeneralizedProjectPoint(double x[3], double xproj[3])
vtkImplicitFunction.h
vtkPlane::New
static vtkPlane * New()
Construct plane passing through origin and normal to z-axis.