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 =========================================================================*/
55 #ifndef vtkOBBTree_h
56 #define vtkOBBTree_h
57 
58 #include "vtkFiltersGeneralModule.h" // For export macro
59 #include "vtkAbstractCellLocator.h"
60 
61 class vtkMatrix4x4;
62 
63 // Special class defines node for the OBB tree
64 //
65 //BTX
66 //
67 class VTKFILTERSGENERAL_EXPORT vtkOBBNode { //;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; NULL if root
75  vtkOBBNode **Kids; //two children of this node; NULL if leaf
76  vtkIdList *Cells; //list of cells in node
77  void DebugPrintTree( int level, double *leaf_vol, int *minCells,
78  int *maxCells );
79 
80 private:
81  vtkOBBNode(const vtkOBBNode& other); // no copy constructor
82  vtkOBBNode& operator=(const vtkOBBNode& rhs); // no copy assignment
83 };
84 //ETX
85 //
86 
88 {
89 public:
91  void PrintSelf(ostream& os, vtkIndent indent);
92 
95  static vtkOBBTree *New();
96 
97  // Re-use any superclass signatures that we don't override.
99 
101 
109  int IntersectWithLine(const double a0[3], const double a1[3],
110  vtkPoints *points, vtkIdList *cellIds);
112 
114 
117  int IntersectWithLine(double a0[3], double a1[3], double tol,
118  double& t, double x[3], double pcoords[3],
119  int &subId, vtkIdType &cellId, vtkGenericCell *cell);
121 
123 
126  static void ComputeOBB(vtkPoints *pts, double corner[3], double max[3],
127  double mid[3], double min[3], double size[3]);
129 
131 
135  void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
136  double mid[3], double min[3], double size[3]);
138 
143  int InsideOrOutside(const double point[3]);
144 
145  //BTX
146 
148 
150  int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
151  vtkMatrix4x4 *XformBtoA );
153 
155  int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
156 
158 
159  int TriangleIntersectsNode( vtkOBBNode *pA,
160  double p0[3], double p1[3],
161  double p2[3], vtkMatrix4x4 *XformBtoA );
163 
165 
167  int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
168  int(*function)( vtkOBBNode *nodeA,
169  vtkOBBNode *nodeB,
170  vtkMatrix4x4 *Xform,
171  void *arg ),
172  void *data_arg );
173  //ETX
175 
177 
178  void FreeSearchStructure();
179  void BuildLocator();
181 
191 
192  //BTX
193 protected:
194  vtkOBBTree();
195  ~vtkOBBTree();
196 
197  // Compute an OBB from the list of cells given. This used to be
198  // public but should not have been. A public call has been added
199  // so that the functionality can be accessed.
200  void ComputeOBB(vtkIdList *cells, double corner[3], double max[3],
201  double mid[3], double min[3], double size[3]);
202 
204  void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
207  int OBBCount;
208 
209  void DeleteTree(vtkOBBNode *OBBptr);
210  void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
211  vtkPoints* pts, vtkCellArray *polys);
212 
213  //ETX
214 private:
215  vtkOBBTree(const vtkOBBTree&); // Not implemented.
216  void operator=(const vtkOBBTree&); // Not implemented.
217 };
218 
219 #endif
vtkOBBNode * Parent
Definition: vtkOBBTree.h:74
virtual void BuildLocator()=0
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
vtkOBBNode ** Kids
Definition: vtkOBBTree.h:75
abstract class to specify dataset behavior
Definition: vtkDataSet.h:61
an abstract base class for locators which find cells
int * InsertedPoints
Definition: vtkOBBTree.h:206
int vtkIdType
Definition: vtkType.h:275
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
vtkIdList * Cells
Definition: vtkOBBTree.h:76
virtual void FreeSearchStructure()=0
provides thread-safe access to cells
generate oriented bounding box (OBB) tree
Definition: vtkOBBTree.h:87
vtkOBBNode * Tree
Definition: vtkOBBTree.h:203
void PrintSelf(ostream &os, vtkIndent indent)
a simple class to control print indentation
Definition: vtkIndent.h:38
int OBBCount
Definition: vtkOBBTree.h:207
list of point or cell ids
Definition: vtkIdList.h:35
#define VTKFILTERSGENERAL_EXPORT
vtkPoints * PointsList
Definition: vtkOBBTree.h:205
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
object to represent cell connectivity
Definition: vtkCellArray.h:49
static vtkObject * New()
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
#define max(a, b)
represent and manipulate 3D points
Definition: vtkPoints.h:38