VTK  9.2.6
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 =========================================================================*/
69 #ifndef vtkOBBTree_h
70 #define vtkOBBTree_h
71 
72 #include "vtkAbstractCellLocator.h"
73 #include "vtkFiltersGeneralModule.h" // For export macro
74 
75 class vtkMatrix4x4;
76 
77 // Special class defines node for the OBB tree
78 class VTKFILTERSGENERAL_EXPORT vtkOBBNode
79 { //;prevent man page generation
80 public:
81  vtkOBBNode();
82  ~vtkOBBNode();
83 
84  double Corner[3]; // center point of this node
85  double Axes[3][3]; // the axes defining the OBB - ordered from long->short
86  vtkOBBNode* Parent; // parent node; nullptr if root
87  vtkOBBNode** Kids; // two children of this node; nullptr if leaf
88  vtkIdList* Cells; // list of cells in node
89  void DebugPrintTree(int level, double* leaf_vol, int* minCells, int* maxCells);
90 
91 private:
92  vtkOBBNode(const vtkOBBNode& other) = delete;
93  vtkOBBNode& operator=(const vtkOBBNode& rhs) = delete;
94 };
95 
96 class VTKFILTERSGENERAL_EXPORT vtkOBBTree : public vtkAbstractCellLocator
97 {
98 public:
100 
104  void PrintSelf(ostream& os, vtkIndent indent) override;
106 
111  static vtkOBBTree* New();
112 
113  // Re-use any superclass signatures that we don't override.
115 
122  int IntersectWithLine(const double a0[3], const double a1[3], double tol, double& t, double x[3],
123  double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) override;
124 
136  int IntersectWithLine(
137  const double a0[3], const double a1[3], vtkPoints* points, vtkIdList* cellIds) override;
138 
144  static void ComputeOBB(
145  vtkPoints* pts, double corner[3], double max[3], double mid[3], double min[3], double size[3]);
146 
153  void ComputeOBB(vtkDataSet* input, double corner[3], double max[3], double mid[3], double min[3],
154  double size[3]);
155 
161  int InsideOrOutside(const double point[3]);
162 
167  int DisjointOBBNodes(vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* XformBtoA);
168 
172  int LineIntersectsNode(vtkOBBNode* pA, const double b0[3], const double b1[3]);
173 
177  int TriangleIntersectsNode(
178  vtkOBBNode* pA, double p0[3], double p1[3], double p2[3], vtkMatrix4x4* XformBtoA);
179 
184  int IntersectWithOBBTree(vtkOBBTree* OBBTreeB, vtkMatrix4x4* XformBtoA,
185  int (*function)(vtkOBBNode* nodeA, vtkOBBNode* nodeB, vtkMatrix4x4* Xform, void* arg),
186  void* data_arg);
187 
189 
192  void FreeSearchStructure() override;
193  void BuildLocator() override;
194  void ForceBuildLocator() override;
196 
206  void GenerateRepresentation(int level, vtkPolyData* pd) override;
207 
208 protected:
209  vtkOBBTree();
210  ~vtkOBBTree() override;
211 
212  void BuildLocatorInternal() override;
213 
214  // Compute an OBB from the list of cells given. This used to be
215  // public but should not have been. A public call has been added
216  // so that the functionality can be accessed.
217  void ComputeOBB(vtkIdList* cells, double corner[3], double max[3], double mid[3], double min[3],
218  double size[3]);
219 
221  void BuildTree(vtkIdList* cells, vtkOBBNode* parent, int level);
224  int OBBCount;
225 
226  void DeleteTree(vtkOBBNode* OBBptr);
227  void GeneratePolygons(
228  vtkOBBNode* OBBptr, int level, int repLevel, vtkPoints* pts, vtkCellArray* polys);
229 
230 private:
231  vtkOBBTree(const vtkOBBTree&) = delete;
232  void operator=(const vtkOBBTree&) = delete;
233 };
234 
235 #endif
vtkOBBNode * Parent
Definition: vtkOBBTree.h:86
virtual void BuildLocator()=0
Build the locator from the input dataset.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
vtkOBBNode ** Kids
Definition: vtkOBBTree.h:87
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
an abstract base class for locators which find cells
int * InsertedPoints
Definition: vtkOBBTree.h:223
int vtkIdType
Definition: vtkType.h:332
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
vtkIdList * Cells
Definition: vtkOBBTree.h:88
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:96
vtkOBBNode * Tree
Definition: vtkOBBTree.h:220
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:39
virtual void BuildLocatorInternal()
This function is not pure virtual to maintain backwards compatibility.
Definition: vtkLocator.h:203
int OBBCount
Definition: vtkOBBTree.h:224
list of point or cell ids
Definition: vtkIdList.h:33
vtkPoints * PointsList
Definition: vtkOBBTree.h:222
object to represent cell connectivity
Definition: vtkCellArray.h:186
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...
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:39
virtual void ForceBuildLocator()
Build the locator from the input dataset (even if UseExistingSearchStructure is on).
Definition: vtkLocator.h:167