VTK  9.6.20260605
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
134
135#ifndef vtkOBBTree_h
136#define vtkOBBTree_h
137
139#include "vtkFiltersGeneralModule.h" // For export macro
140
141VTK_ABI_NAMESPACE_BEGIN
142class vtkMatrix4x4;
143
144// Special class defines node for the OBB tree
145class VTKFILTERSGENERAL_EXPORT vtkOBBNode
146{ //;prevent man page generation
147public:
150
151 double Corner[3]; // center point of this node
152 double Axes[3][3]; // the axes defining the OBB - ordered from long->short
153 vtkOBBNode* Parent; // parent node; nullptr if root
154 vtkOBBNode** Kids; // two children of this node; nullptr if leaf
155 vtkIdList* Cells; // list of cells in node
156 void DebugPrintTree(int level, double* leaf_vol, int* minCells, int* maxCells);
157
158private:
159 vtkOBBNode(const vtkOBBNode& other) = delete;
160 vtkOBBNode& operator=(const vtkOBBNode& rhs) = delete;
161};
162
163class VTKFILTERSGENERAL_EXPORT vtkOBBTree : public vtkAbstractCellLocator
164{
165public:
167
171 void PrintSelf(ostream& os, vtkIndent indent) override;
173
178 static vtkOBBTree* New();
179
180 // Reuse any superclass signatures that we don't override.
183
190 int IntersectWithLine(const double a0[3], const double a1[3], double tol, double& t, double x[3],
191 double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
192
204 int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints* points,
205 vtkIdList* cellIds, vtkGenericCell* cell) override;
206
212 static void ComputeOBB(
213 vtkPoints* pts, double corner[3], double max[3], double mid[3], double min[3], double size[3]);
214
221 void ComputeOBB(vtkDataSet* input, double corner[3], double max[3], double mid[3], double min[3],
222 double size[3]);
223
229 int InsideOrOutside(const double point[3], double tol = 0);
230
236 vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* XformBtoA, double tol = 0);
237
241 int LineIntersectsNode(vtkOBBNode* pA, const double b0[3], const double b1[3], double tol = 0);
242
246 int TriangleIntersectsNode(vtkOBBNode* pA, double p0[3], double p1[3], double p2[3],
247 vtkMatrix4x4* XformBtoA, double tol = 0);
248
254 int (*function)(vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* Xform, void* arg),
255 void* data_arg, double tol = 0);
256
258
261 void FreeSearchStructure() override;
262 void BuildLocator() override;
263 void ForceBuildLocator() override;
265
275 void GenerateRepresentation(int level, vtkPolyData* pd) override;
276
277protected:
279 ~vtkOBBTree() override;
280
281 void BuildLocatorInternal() override;
282
283 // Compute an OBB from the list of cells given. This used to be
284 // public but should not have been. A public call has been added
285 // so that the functionality can be accessed.
286 void ComputeOBB(vtkIdList* cells, double corner[3], double max[3], double mid[3], double min[3],
287 double size[3]);
288
290 void BuildTree(vtkIdList* cells, vtkOBBNode* parent, int level);
294
295 void DeleteTree(vtkOBBNode* OBBptr);
297 vtkOBBNode* OBBptr, int level, int repLevel, vtkPoints* pts, vtkCellArray* polys);
298
299private:
300 vtkOBBTree(const vtkOBBTree&) = delete;
301 void operator=(const vtkOBBTree&) = delete;
302};
303
304VTK_ABI_NAMESPACE_END
305#endif
void FindCellsAlongLine(const double p1[3], const double p2[3], double tol, vtkIdList *cells)
Take the passed line segment and intersect it with the data set.
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.
vtkAbstractCellLocator()
Find the cell containing a given point.
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:135
a simple class to control print indentation
Definition vtkIndent.h:108
represent and manipulate 4x4 transformation matrices
double Axes[3][3]
Definition vtkOBBTree.h:152
vtkOBBNode * Parent
Definition vtkOBBTree.h:153
double Corner[3]
Definition vtkOBBTree.h:151
vtkIdList * Cells
Definition vtkOBBTree.h:155
void DebugPrintTree(int level, double *leaf_vol, int *minCells, int *maxCells)
vtkOBBNode ** Kids
Definition vtkOBBTree.h:154
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.
int LineIntersectsNode(vtkOBBNode *pA, const double b0[3], const double b1[3], double tol=0)
Returns true if line intersects node.
void BuildLocator() override
Satisfy locator's abstract interface, see vtkLocator.
int TriangleIntersectsNode(vtkOBBNode *pA, double p0[3], double p1[3], double p2[3], vtkMatrix4x4 *XformBtoA, double tol=0)
Returns true if triangle (optionally transformed) intersects node.
void FreeSearchStructure() override
Satisfy locator's abstract interface, see vtkLocator.
int IntersectWithLine(const double a0[3], const 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...
void GenerateRepresentation(int level, vtkPolyData *pd) override
Create polygonal representation for OBB tree at specified level.
void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, vtkPoints *pts, vtkCellArray *polys)
int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints *points, vtkIdList *cellIds, vtkGenericCell *cell) 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, double tol=0)
For each intersecting leaf node pair, call function.
~vtkOBBTree() override
vtkOBBNode * Tree
Definition vtkOBBTree.h:289
void PrintSelf(ostream &os, vtkIndent indent) override
Standard methods to print and obtain type-related information.
void BuildLocatorInternal() override
This function is not pure virtual to maintain backwards compatibility.
int InsideOrOutside(const double point[3], double tol=0)
Determine whether a point is inside or outside the data used to build this OBB tree.
static vtkOBBTree * New()
Construct with automatic computation of divisions, averaging 25 cells per octant.
void ComputeOBB(vtkIdList *cells, double corner[3], double max[3], double mid[3], double min[3], double size[3])
vtkPoints * PointsList
Definition vtkOBBTree.h:291
int * InsertedPoints
Definition vtkOBBTree.h:292
void ForceBuildLocator() override
Satisfy locator's abstract interface, see vtkLocator.
int DisjointOBBNodes(vtkOBBNode *nodeA, vtkOBBNode *nodeB, vtkMatrix4x4 *XformBtoA, double tol=0)
Returns true if nodeB and nodeA are disjoint after optional transformation of nodeB with matrix Xform...
void DeleteTree(vtkOBBNode *OBBptr)
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.
void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level)
represent and manipulate 3D points
Definition vtkPoints.h:140
concrete dataset represents vertices, lines, polygons, and triangle strips
int vtkIdType
Definition vtkType.h:363
#define max(a, b)