forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkPlanesIntersection.h
128 lines (97 loc) · 4.37 KB
/
vtkPlanesIntersection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPlanesIntersection.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*----------------------------------------------------------------------------
Copyright (c) Sandia Corporation
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
----------------------------------------------------------------------------*/
// .NAME vtkPlanesIntersection - A vtkPlanesIntersection object is a
// vtkPlanes object that can compute whether the arbitrary convex region
// bounded by it's planes intersects an axis-aligned box.
//
// .SECTION Description
// A subclass of vtkPlanes, this class determines whether it
// intersects an axis aligned box. This is motivated by the
// need to intersect the axis aligned region of a spacial
// decomposition of volume data with various other regions.
// It uses the algorithm from Graphics Gems IV, page 81.
//
// .SECTION Caveat
// An instance of vtkPlanes can be redefined by changing the planes,
// but this subclass then will not know if the region vertices are
// up to date. (Region vertices can be specified in SetRegionVertices
// or computed by the subclass.) So Delete and recreate if you want
// to change the set of planes.
//
#ifndef __vtkPlanesIntersection_h
#define __vtkPlanesIntersection_h
#include "vtkPlanes.h"
class vtkPoints;
class vtkPointsProjectedHull;
class vtkCell;
class VTK_FILTERING_EXPORT vtkPlanesIntersection : public vtkPlanes
{
vtkTypeMacro(vtkPlanesIntersection, vtkPlanes);
public:
void PrintSelf(ostream& os, vtkIndent indent);
static vtkPlanesIntersection *New();
// Description:
// It helps if you know the vertices of the convex region.
// If you don't, we will calculate them. Region vertices
// are 3-tuples.
void SetRegionVertices(vtkPoints *pts);
void SetRegionVertices(double *v, int nvertices);
int GetNumRegionVertices();
int GetRegionVertices(double *v, int nvertices);
// Description:
// Return 1 if the axis aligned box defined by R intersects
// the region defined by the planes, or 0 otherwise.
int IntersectsRegion(vtkPoints *R);
// Description:
// A convenience function provided by this class, returns
// 1 if the polygon defined in pts intersects the bounding
// box defined in bounds, 0 otherwise.
//
// The points must define a planar polygon.
static int PolygonIntersectsBBox(double bounds[6], vtkPoints *pts);
// Description:
// Another convenience function provided by this class, returns
// the vtkPlanesIntersection object representing a 3D
// cell. The point IDs for each face must be given in
// counter-clockwise order from the outside of the cell.
static vtkPlanesIntersection *Convert3DCell(vtkCell *cell);
protected:
static void ComputeNormal(double *p1, double *p2, double *p3, double normal[3]);
static double EvaluatePlaneEquation(double *x, double *p);
static void PlaneEquation(double *n, double *x, double *p);
static int GoodNormal(double *n);
static int Invert3x3(double M[3][3]);
vtkPlanesIntersection();
~vtkPlanesIntersection();
private:
int IntersectsBoundingBox(vtkPoints *R);
int EnclosesBoundingBox(vtkPoints *R);
int EvaluateFacePlane(int plane, vtkPoints *R);
int IntersectsProjection(vtkPoints *R, int direction);
void SetPlaneEquations();
void ComputeRegionVertices();
void planesMatrix(int p1, int p2, int p3, double M[3][3]) const;
int duplicate(double testv[3]) const;
void planesRHS(int p1, int p2, int p3, double r[3]) const;
int outsideRegion(double v[3]) ;
// plane equations
double *Plane;
// vertices of convex regions enclosed by the planes, also
// the ccw hull of that region projected in 3 orthog. directions
vtkPointsProjectedHull *regionPts;
vtkPlanesIntersection(const vtkPlanesIntersection&); // Not implemented
void operator=(const vtkPlanesIntersection&); // Not implemented
};
#endif