VTK  9.6.2
vtkOBBTree.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
115
116#ifndef vtkOBBTree_h
117#define vtkOBBTree_h
118
120#include "vtkFiltersGeneralModule.h" // For export macro
121
122VTK_ABI_NAMESPACE_BEGIN
123class vtkMatrix4x4;
124
125// Special class defines node for the OBB tree
126class VTKFILTERSGENERAL_EXPORT vtkOBBNode
127{ //;prevent man page generation
128public:
129 vtkOBBNode();
130 ~vtkOBBNode();
131
132 double Corner[3]; // center point of this node
133 double Axes[3][3]; // the axes defining the OBB - ordered from long->short
134 vtkOBBNode* Parent; // parent node; nullptr if root
135 vtkOBBNode** Kids; // two children of this node; nullptr if leaf
136 vtkIdList* Cells; // list of cells in node
137 void DebugPrintTree(int level, double* leaf_vol, int* minCells, int* maxCells);
138
139private:
140 vtkOBBNode(const vtkOBBNode& other) = delete;
141 vtkOBBNode& operator=(const vtkOBBNode& rhs) = delete;
142};
143
144class VTKFILTERSGENERAL_EXPORT vtkOBBTree : public vtkAbstractCellLocator
145{
146public:
148
152 void PrintSelf(ostream& os, vtkIndent indent) override;
154
159 static vtkOBBTree* New();
160
161 // Reuse any superclass signatures that we don't override.
163
170 int IntersectWithLine(const double a0[3], const double a1[3], double tol, double& t, double x[3],
171 double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
172
185 const double a0[3], const double a1[3], vtkPoints* points, vtkIdList* cellIds) override;
186
192 static void ComputeOBB(
193 vtkPoints* pts, double corner[3], double max[3], double mid[3], double min[3], double size[3]);
194
201 void ComputeOBB(vtkDataSet* input, double corner[3], double max[3], double mid[3], double min[3],
202 double size[3]);
203
209 int InsideOrOutside(const double point[3]);
210
215 int DisjointOBBNodes(vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* XformBtoA);
216
220 int LineIntersectsNode(vtkOBBNode* pA, const double b0[3], const double b1[3]);
221
226 vtkOBBNode* pA, double p0[3], double p1[3], double p2[3], vtkMatrix4x4* XformBtoA);
227
233 int (*function)(vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* Xform, void* arg),
234 void* data_arg);
235
237
240 void FreeSearchStructure() override;
241 void BuildLocator() override;
242 void ForceBuildLocator() override;
244
254 void GenerateRepresentation(int level, vtkPolyData* pd) override;
255
256protected:
258 ~vtkOBBTree() override;
259
260 void BuildLocatorInternal() override;
261
262 // Compute an OBB from the list of cells given. This used to be
263 // public but should not have been. A public call has been added
264 // so that the functionality can be accessed.
265 void ComputeOBB(vtkIdList* cells, double corner[3], double max[3], double mid[3], double min[3],
266 double size[3]);
267
268 vtkOBBNode* Tree;
269 void BuildTree(vtkIdList* cells, vtkOBBNode* parent, int level);
273
274 void DeleteTree(vtkOBBNode* OBBptr);
276 vtkOBBNode* OBBptr, int level, int repLevel, vtkPoints* pts, vtkCellArray* polys);
277
278private:
279 vtkOBBTree(const vtkOBBTree&) = delete;
280 void operator=(const vtkOBBTree&) = delete;
281};
282
283VTK_ABI_NAMESPACE_END
284#endif
an abstract base class for locators which find cells
virtual int IntersectWithLine(const double p1[3], const 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
abstract class to specify dataset behavior
Definition vtkDataSet.h:166
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
generate oriented bounding box (OBB) tree
represent and manipulate 3D points
Definition vtkPoints.h:139
concrete dataset represents vertices, lines, polygons, and triangle strips
int IntersectWithLine(const double p1[3], const double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId) override
Line-edge intersection.
static vtkBiQuadraticQuadraticHexahedron * New()
void PrintSelf(ostream &os, vtkIndent indent) override
@ Cells
A cell specified by degrees of freedom held in arrays.
int DisjointOBBNodes(vtkOBBNode *nodeA, vtkOBBNode *nodeB, vtkMatrix4x4 *XformBtoA)
Returns true if nodeB and nodeA are disjoint after optional transformation of nodeB with matrix Xform...
vtkOBBNode * Tree
Definition vtkOBBTree.h:268
void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level)
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 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.
void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, vtkPoints *pts, vtkCellArray *polys)
~vtkOBBTree() override
int OBBCount
Definition vtkOBBTree.h:272
vtkPoints * PointsList
Definition vtkOBBTree.h:270
vtkOBBTree()
void ForceBuildLocator() override
Satisfy locator's abstract interface, see vtkLocator.
void BuildLocator() override
Satisfy locator's abstract interface, see vtkLocator.
void DeleteTree(vtkOBBNode *OBBptr)
int * InsertedPoints
Definition vtkOBBTree.h:271
void FreeSearchStructure() override
Satisfy locator's abstract interface, see vtkLocator.
int LineIntersectsNode(vtkOBBNode *pA, const double b0[3], const double b1[3])
Returns true if line intersects node.
void BuildLocatorInternal() override
void GenerateRepresentation(int level, vtkPolyData *pd) override
Create polygonal representation for OBB tree at specified level.
int InsideOrOutside(const double point[3])
Determine whether a point is inside or outside the data used to build this OBB tree.
int vtkIdType
Definition vtkType.h:368
#define max(a, b)