VTK  9.7.1
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
56 #ifndef vtkOBBTree_h
57 #define vtkOBBTree_h
58 
59 #include "vtkAbstractCellLocator.h"
60 #include "vtkFiltersGeneralModule.h" // For export macro
61 
62 VTK_ABI_NAMESPACE_BEGIN
63 class vtkMatrix4x4;
64 
65 // Special class defines node for the OBB tree
66 class VTKFILTERSGENERAL_EXPORT vtkOBBNode
67 { //;prevent man page generation
68 public:
69  vtkOBBNode();
70  ~vtkOBBNode();
71 
72  double Corner[3]; // center point of this node
73  double Axes[3][3]; // the axes defining the OBB - ordered from long->short
74  vtkOBBNode* Parent; // parent node; nullptr if root
75  vtkOBBNode** Kids; // two children of this node; nullptr if leaf
76  vtkIdList* Cells; // list of cells in node
77  void DebugPrintTree(int level, double* leaf_vol, int* minCells, int* maxCells);
78 
79 private:
80  vtkOBBNode(const vtkOBBNode& other) = delete;
81  vtkOBBNode& operator=(const vtkOBBNode& rhs) = delete;
82 };
83 
84 class VTKFILTERSGENERAL_EXPORT vtkOBBTree : public vtkAbstractCellLocator
85 {
86 public:
88 
92  void PrintSelf(ostream& os, vtkIndent indent) override;
94 
99  static vtkOBBTree* New();
100 
101  // Reuse any superclass signatures that we don't override.
104 
111  int IntersectWithLine(const double a0[3], const double a1[3], double tol, double& t, double x[3],
112  double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
113 
125  int IntersectWithLine(const double p1[3], const double p2[3], double tol, vtkPoints* points,
126  vtkIdList* cellIds, vtkGenericCell* cell) override;
127 
133  static void ComputeOBB(
134  vtkPoints* pts, double corner[3], double max[3], double mid[3], double min[3], double size[3]);
135 
142  void ComputeOBB(vtkDataSet* input, double corner[3], double max[3], double mid[3], double min[3],
143  double size[3]);
144 
150  int InsideOrOutside(const double point[3], double tol = 0);
151 
156  int DisjointOBBNodes(
157  vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* XformBtoA, double tol = 0);
158 
162  int LineIntersectsNode(vtkOBBNode* pA, const double b0[3], const double b1[3], double tol = 0);
163 
167  int TriangleIntersectsNode(vtkOBBNode* pA, double p0[3], double p1[3], double p2[3],
168  vtkMatrix4x4* XformBtoA, double tol = 0);
169 
174  int IntersectWithOBBTree(vtkOBBTree* OBBTreeB, vtkMatrix4x4* XformBtoA,
175  int (*function)(vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* Xform, void* arg),
176  void* data_arg, double tol = 0);
177 
179 
182  void FreeSearchStructure() override;
183  void BuildLocator() override;
184  void ForceBuildLocator() override;
186 
196  void GenerateRepresentation(int level, vtkPolyData* pd) override;
197 
198 protected:
199  vtkOBBTree();
200  ~vtkOBBTree() override;
201 
202  void BuildLocatorInternal() override;
203 
204  // Compute an OBB from the list of cells given. This used to be
205  // public but should not have been. A public call has been added
206  // so that the functionality can be accessed.
207  void ComputeOBB(vtkIdList* cells, double corner[3], double max[3], double mid[3], double min[3],
208  double size[3]);
209 
211  void BuildTree(vtkIdList* cells, vtkOBBNode* parent, int level);
214  int OBBCount;
215 
216  void DeleteTree(vtkOBBNode* OBBptr);
217  void GeneratePolygons(
218  vtkOBBNode* OBBptr, int level, int repLevel, vtkPoints* pts, vtkCellArray* polys);
219 
220 private:
221  vtkOBBTree(const vtkOBBTree&) = delete;
222  void operator=(const vtkOBBTree&) = delete;
223 };
224 
225 VTK_ABI_NAMESPACE_END
226 #endif
vtkOBBNode * Parent
Definition: vtkOBBTree.h:74
virtual void BuildLocator()=0
Build the locator from the input dataset.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
vtkOBBNode ** Kids
Definition: vtkOBBTree.h:75
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
an abstract base class for locators which find cells
int * InsertedPoints
Definition: vtkOBBTree.h:213
int vtkIdType
Definition: vtkType.h:363
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:71
vtkIdList * Cells
Definition: vtkOBBTree.h:76
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
provides thread-safe access to cells
generate oriented bounding box (OBB) tree
Definition: vtkOBBTree.h:84
vtkOBBNode * Tree
Definition: vtkOBBTree.h:210
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.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void BuildLocatorInternal()
This function is not pure virtual to maintain backwards compatibility.
Definition: vtkLocator.h:199
int OBBCount
Definition: vtkOBBTree.h:214
list of point or cell ids
Definition: vtkIdList.h:25
vtkPoints * PointsList
Definition: vtkOBBTree.h:212
object to represent cell connectivity
Definition: vtkCellArray.h:177
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
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 void GenerateRepresentation(int level, vtkPolyData *pd)=0
Method to build a representation at a particular level.
#define max(a, b)
represent and manipulate 3D points
Definition: vtkPoints.h:30
virtual void ForceBuildLocator()
Build the locator from the input dataset (even if UseExistingSearchStructure is on).
Definition: vtkLocator.h:163