VTK
vtkOBBTree.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkOBBTree.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=========================================================================*/
56#ifndef vtkOBBTree_h
57#define vtkOBBTree_h
58
59#include "vtkFiltersGeneralModule.h" // For export macro
61
62class vtkMatrix4x4;
63
64// Special class defines node for the OBB tree
65//
66
67//
68class VTKFILTERSGENERAL_EXPORT vtkOBBNode { //;prevent man page generation
69public:
72
73 double Corner[3]; //center point of this node
74 double Axes[3][3]; //the axes defining the OBB - ordered from long->short
75 vtkOBBNode *Parent; //parent node; NULL if root
76 vtkOBBNode **Kids; //two children of this node; NULL if leaf
77 vtkIdList *Cells; //list of cells in node
78 void DebugPrintTree( int level, double *leaf_vol, int *minCells,
79 int *maxCells );
80
81private:
82 vtkOBBNode(const vtkOBBNode& other) VTK_DELETE_FUNCTION;
83 vtkOBBNode& operator=(const vtkOBBNode& rhs) VTK_DELETE_FUNCTION;
84};
85
86//
87
88class VTKFILTERSGENERAL_EXPORT vtkOBBTree : public vtkAbstractCellLocator
89{
90public:
92 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
93
98 static vtkOBBTree *New();
99
100 // Re-use any superclass signatures that we don't override.
102
114 int IntersectWithLine(const double a0[3], const double a1[3],
115 vtkPoints *points, vtkIdList *cellIds) VTK_OVERRIDE;
116
122 int IntersectWithLine(double a0[3], double a1[3], double tol,
123 double& t, double x[3], double pcoords[3],
124 int &subId, vtkIdType &cellId, vtkGenericCell *cell) VTK_OVERRIDE;
125
131 static void ComputeOBB(vtkPoints *pts, double corner[3], double max[3],
132 double mid[3], double min[3], double size[3]);
133
140 void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
141 double mid[3], double min[3], double size[3]);
142
148 int InsideOrOutside(const double point[3]);
149
155 vtkMatrix4x4 *XformBtoA );
156
160 int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
161
166 double p0[3], double p1[3],
167 double p2[3], vtkMatrix4x4 *XformBtoA );
168
173 int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
174 int(*function)( vtkOBBNode *nodeA,
175 vtkOBBNode *nodeB,
176 vtkMatrix4x4 *Xform,
177 void *arg ),
178 void *data_arg );
179
181
184 void FreeSearchStructure() VTK_OVERRIDE;
185 void BuildLocator() VTK_OVERRIDE;
187
197 void GenerateRepresentation(int level, vtkPolyData *pd) VTK_OVERRIDE;
198
199protected:
201 ~vtkOBBTree() VTK_OVERRIDE;
202
203 // Compute an OBB from the list of cells given. This used to be
204 // public but should not have been. A public call has been added
205 // so that the functionality can be accessed.
206 void ComputeOBB(vtkIdList *cells, double corner[3], double max[3],
207 double mid[3], double min[3], double size[3]);
208
210 void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
211 vtkPoints *PointsList;
212 int *InsertedPoints;
213 int OBBCount;
214
215 void DeleteTree(vtkOBBNode *OBBptr);
216 void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
217 vtkPoints* pts, vtkCellArray *polys);
218
219private:
220 vtkOBBTree(const vtkOBBTree&) VTK_DELETE_FUNCTION;
221 void operator=(const vtkOBBTree&) VTK_DELETE_FUNCTION;
222};
223
224#endif
an abstract base class for locators which find cells
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
Return intersection point (if any) of finite line with cells contained in cell locator.
object to represent cell connectivity
Definition: vtkCellArray.h:51
abstract class to specify dataset behavior
Definition: vtkDataSet.h:63
provides thread-safe access to cells
list of point or cell ids
Definition: vtkIdList.h:37
a simple class to control print indentation
Definition: vtkIndent.h:40
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
vtkOBBNode * Parent
Definition: vtkOBBTree.h:75
vtkIdList * Cells
Definition: vtkOBBTree.h:77
void DebugPrintTree(int level, double *leaf_vol, int *minCells, int *maxCells)
vtkOBBNode ** Kids
Definition: vtkOBBTree.h:76
generate oriented bounding box (OBB) tree
Definition: vtkOBBTree.h:89
void ComputeOBB(vtkDataSet *input, double corner[3], double max[3], double mid[3], double min[3], double size[3])
Compute an OBB for the input dataset using the cells in the data.
void FreeSearchStructure() override
Satisfy locator's abstract interface, see vtkLocator.
int DisjointOBBNodes(vtkOBBNode *nodeA, vtkOBBNode *nodeB, vtkMatrix4x4 *XformBtoA)
Returns true if nodeB and nodeA are disjoint after optional transformation of nodeB with matrix Xform...
int InsideOrOutside(const double point[3])
Determine whether a point is inside or outside the data used to build this OBB tree.
int LineIntersectsNode(vtkOBBNode *pA, double b0[3], double b1[3])
Returns true if line intersects node.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkOBBTree * New()
Construct with automatic computation of divisions, averaging 25 cells per octant.
int IntersectWithLine(const double a0[3], const double a1[3], vtkPoints *points, vtkIdList *cellIds) override
Take the passed line segment and intersect it with the data set.
int IntersectWithOBBTree(vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA, int(*function)(vtkOBBNode *nodeA, vtkOBBNode *nodeB, vtkMatrix4x4 *Xform, void *arg), void *data_arg)
For each intersecting leaf node pair, call function.
int TriangleIntersectsNode(vtkOBBNode *pA, double p0[3], double p1[3], double p2[3], vtkMatrix4x4 *XformBtoA)
Returns true if triangle (optionally transformed) intersects node.
static void ComputeOBB(vtkPoints *pts, double corner[3], double max[3], double mid[3], double min[3], double size[3])
Compute an OBB from the list of points given.
int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId, vtkGenericCell *cell) override
Return the first intersection of the specified line segment with the OBB tree, as well as information...
represent and manipulate 3D points
Definition: vtkPoints.h:40
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
@ point
Definition: vtkX3D.h:236
@ points
Definition: vtkX3D.h:446
@ level
Definition: vtkX3D.h:395
@ function
Definition: vtkX3D.h:249
@ size
Definition: vtkX3D.h:253
int vtkIdType
Definition: vtkType.h:287
#define max(a, b)