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 =========================================================================*/
53 #ifndef vtkOBBTree_h
54 #define vtkOBBTree_h
55 
56 #include "vtkFiltersGeneralModule.h" // For export macro
57 #include "vtkAbstractCellLocator.h"
58 
59 class vtkMatrix4x4;
60 
61 // Special class defines node for the OBB tree
62 //
63 
64 //
65 class VTKFILTERSGENERAL_EXPORT vtkOBBNode { //;prevent man page generation
66 public:
67  vtkOBBNode();
68  ~vtkOBBNode();
69 
70  double Corner[3]; //center point of this node
71  double Axes[3][3]; //the axes defining the OBB - ordered from long->short
72  vtkOBBNode *Parent; //parent node; nullptr if root
73  vtkOBBNode **Kids; //two children of this node; nullptr if leaf
74  vtkIdList *Cells; //list of cells in node
75  void DebugPrintTree( int level, double *leaf_vol, int *minCells,
76  int *maxCells );
77 
78 private:
79  vtkOBBNode(const vtkOBBNode& other) = delete;
80  vtkOBBNode& operator=(const vtkOBBNode& rhs) = delete;
81 };
82 
83 //
84 
85 class VTKFILTERSGENERAL_EXPORT vtkOBBTree : public vtkAbstractCellLocator
86 {
87 public:
89  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
95  static vtkOBBTree *New();
96 
97  // Re-use any superclass signatures that we don't override.
99 
111  int IntersectWithLine(const double a0[3], const double a1[3],
112  vtkPoints *points, vtkIdList *cellIds) override;
113 
119  int IntersectWithLine(const double a0[3], const double a1[3], double tol,
120  double& t, double x[3], double pcoords[3],
121  int &subId, vtkIdType &cellId, vtkGenericCell *cell) override;
122 
128  static void ComputeOBB(vtkPoints *pts, double corner[3], double max[3],
129  double mid[3], double min[3], double size[3]);
130 
137  void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
138  double mid[3], double min[3], double size[3]);
139 
145  int InsideOrOutside(const double point[3]);
146 
151  int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
152  vtkMatrix4x4 *XformBtoA );
153 
157  int LineIntersectsNode( vtkOBBNode *pA, const double b0[3], const double b1[3] );
158 
162  int TriangleIntersectsNode( vtkOBBNode *pA,
163  double p0[3], double p1[3],
164  double p2[3], vtkMatrix4x4 *XformBtoA );
165 
170  int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
171  int(*function)( vtkOBBNode *nodeA,
172  vtkOBBNode *nodeB,
173  vtkMatrix4x4 *Xform,
174  void *arg ),
175  void *data_arg );
176 
178 
181  void FreeSearchStructure() override;
182  void BuildLocator() override;
184 
194  void GenerateRepresentation(int level, vtkPolyData *pd) override;
195 
196 protected:
197  vtkOBBTree();
198  ~vtkOBBTree() override;
199 
200  // Compute an OBB from the list of cells given. This used to be
201  // public but should not have been. A public call has been added
202  // so that the functionality can be accessed.
203  void ComputeOBB(vtkIdList *cells, double corner[3], double max[3],
204  double mid[3], double min[3], double size[3]);
205 
207  void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
210  int OBBCount;
211 
212  void DeleteTree(vtkOBBNode *OBBptr);
213  void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
214  vtkPoints* pts, vtkCellArray *polys);
215 
216 private:
217  vtkOBBTree(const vtkOBBTree&) = delete;
218  void operator=(const vtkOBBTree&) = delete;
219 };
220 
221 #endif
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkAbstractCellLocator::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkOBBNode::Kids
vtkOBBNode ** Kids
Definition: vtkOBBTree.h:73
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkOBBTree::OBBCount
int OBBCount
Definition: vtkOBBTree.h:210
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkOBBTree
generate oriented bounding box (OBB) tree
Definition: vtkOBBTree.h:85
vtkAbstractCellLocator.h
vtkOBBTree::PointsList
vtkPoints * PointsList
Definition: vtkOBBTree.h:208
vtkOBBNode::Parent
vtkOBBNode * Parent
Definition: vtkOBBTree.h:72
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:31
vtkX3D::level
Definition: vtkX3D.h:395
vtkX3D::points
Definition: vtkX3D.h:446
vtkX3D::point
Definition: vtkX3D.h:236
vtkOBBNode::Cells
vtkIdList * Cells
Definition: vtkOBBTree.h:74
vtkLocator::GenerateRepresentation
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
Method to build a representation at a particular level.
vtkOBBNode
Definition: vtkOBBTree.h:65
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:44
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkX3D::size
Definition: vtkX3D.h:253
vtkLocator::BuildLocator
virtual void BuildLocator()=0
Build the locator from the input dataset.
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:48
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:56
vtkAbstractCellLocator::IntersectWithLine
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.
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:36
vtkLocator::FreeSearchStructure
virtual void FreeSearchStructure()=0
Free the memory required for the spatial data structure.
vtkOBBTree::InsertedPoints
int * InsertedPoints
Definition: vtkOBBTree.h:209
vtkOBBTree::Tree
vtkOBBNode * Tree
Definition: vtkOBBTree.h:206