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 =========================================================================*/
25 #ifndef vtkPlane_h
26 #define vtkPlane_h
27 
28 #include "vtkCommonDataModelModule.h" // For export macro
29 #include "vtkImplicitFunction.h"
30 
31 class VTKCOMMONDATAMODEL_EXPORT vtkPlane : public vtkImplicitFunction
32 {
33 public:
37  static vtkPlane *New();
38 
40  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
41 
43 
47  void EvaluateFunction(vtkDataArray* input, vtkDataArray* output) VTK_OVERRIDE;
48  double EvaluateFunction(double x[3]) VTK_OVERRIDE;
50 
54  void EvaluateGradient(double x[3], double g[3]) VTK_OVERRIDE;
55 
57 
60  vtkSetVector3Macro(Normal,double);
61  vtkGetVectorMacro(Normal,double,3);
63 
65 
69  vtkSetVector3Macro(Origin,double);
70  vtkGetVectorMacro(Origin,double,3);
72 
78  void Push(double distance);
79 
81 
86  static void ProjectPoint(double x[3], double origin[3], double normal[3],
87  double xproj[3]);
88  void ProjectPoint(double x[3], double xproj[3]);
90 
92 
96  static void ProjectVector(double v[3], double origin[3], double normal[3],
97  double vproj[3]);
98  void ProjectVector(double v[3], double vproj[3]);
100 
102 
107  static void GeneralizedProjectPoint(double x[3], double origin[3],
108  double normal[3], double xproj[3]);
109  void GeneralizedProjectPoint(double x[3], double xproj[3]);
111 
112 
116  static double Evaluate(double normal[3], double origin[3], double x[3]);
117 
119 
123  static double DistanceToPlane(double x[3], double n[3], double p0[3]);
124  double DistanceToPlane(double x[3]);
126 
128 
136  static int IntersectWithLine(double p1[3], double p2[3], double n[3],
137  double p0[3], double& t, double x[3]);
138  int IntersectWithLine(double p1[3], double p2[3], double& t, double x[3]);
140 
141 protected:
142  vtkPlane();
143  ~vtkPlane() VTK_OVERRIDE {}
144 
145  double Normal[3];
146  double Origin[3];
147 
148 private:
149  vtkPlane(const vtkPlane&) VTK_DELETE_FUNCTION;
150  void operator=(const vtkPlane&) VTK_DELETE_FUNCTION;
151 };
152 
153 // Generally the normal should be normalized
154 inline double vtkPlane::Evaluate(double normal[3],
155  double origin[3], double x[3])
156 {
157  return normal[0]*(x[0]-origin[0]) + normal[1]*(x[1]-origin[1]) +
158  normal[2]*(x[2]-origin[2]);
159 }
160 
161 // Assumes normal is normalized
162 inline double vtkPlane::DistanceToPlane(double x[3], double n[3], double p0[3])
163 {
164 #define vtkPlaneAbs(x) ((x)<0?-(x):(x))
165  return (vtkPlaneAbs(n[0]*(x[0]-p0[0]) + n[1]*(x[1]-p0[1]) +
166  n[2]*(x[2]-p0[2])));
167 }
168 
169 #endif
abstract interface for implicit functions
virtual double EvaluateFunction(double x[3])=0
Evaluate function at position x-y-z and return value.
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:162
static double Evaluate(double normal[3], double origin[3], double x[3])
Quick evaluation of plane equation n(x-origin)=0.
Definition: vtkPlane.h:154
#define vtkPlaneAbs(x)
virtual void EvaluateGradient(double x[3], double g[3])=0
Evaluate function gradient at position x-y-z and pass back vector.
a simple class to control print indentation
Definition: vtkIndent.h:33
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
perform various plane computations
Definition: vtkPlane.h:31
~vtkPlane() override
Definition: vtkPlane.h:143
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.