VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 //BTX
98 /*
99  if the borland compiler is ever removed, we can use these declarations
100  instead of reimplementaing the calls in this subclass
101  using vtkAbstractCellLocator::IntersectWithLine;
102  using vtkAbstractCellLocator::FindClosestPoint;
103  using vtkAbstractCellLocator::FindClosestPointWithinRadius;
104 */
105 //ETX
106 
108 
109  virtual int IntersectWithLine(
110  double a0[3], double a1[3], double tol,
111  double& t, double x[3], double pcoords[3],
112  int &subId)
113  {
114  return Superclass::
115  IntersectWithLine(a0, a1, tol,t, x, pcoords, subId);
116  }
118 
120 
121  virtual int IntersectWithLine(
122  double a0[3], double a1[3], double tol,
123  double& t, double x[3], double pcoords[3],
124  int &subId, vtkIdType &cellId)
125  {
126  return Superclass::
127  IntersectWithLine(a0, a1, tol,t, x, pcoords, subId, cellId);
128  }
130 
132 
140  int IntersectWithLine(const double a0[3], const double a1[3],
141  vtkPoints *points, vtkIdList *cellIds);
143 
145 
148  int IntersectWithLine(double a0[3], double a1[3], double tol,
149  double& t, double x[3], double pcoords[3],
150  int &subId, vtkIdType &cellId, vtkGenericCell *cell);
152 
154 
163  virtual void FindClosestPoint(
164  double x[3], double closestPoint[3],
165  vtkIdType &cellId, int &subId, double& dist2)
166  {
167  Superclass::
168  FindClosestPoint(x, closestPoint, cellId, subId, dist2);
169  }
171 
173 
174  virtual void FindClosestPoint(
175  double x[3], double closestPoint[3],
176  vtkGenericCell *cell, vtkIdType &cellId,
177  int &subId, double& dist2)
178  {
179  Superclass::
180  FindClosestPoint(x, closestPoint, cell, cellId, subId, dist2);
181  }
183 
185 
187  double x[3], double radius,
188  double closestPoint[3], vtkIdType &cellId,
189  int &subId, double& dist2)
190  {
191  return Superclass::FindClosestPointWithinRadius
192  (x, radius, closestPoint, cellId, subId, dist2);
193  }
195 
197 
199  double x[3], double radius,
200  double closestPoint[3],
201  vtkGenericCell *cell, vtkIdType &cellId,
202  int &subId, double& dist2)
203  {
204  return Superclass::FindClosestPointWithinRadius
205  (x, radius, closestPoint, cell, cellId, subId, dist2);
206  }
208 
210 
212  double x[3], double radius, double closestPoint[3],
213  vtkGenericCell *cell, vtkIdType &cellId,
214  int &subId, double& dist2, int &inside)
215  {
216  return Superclass::FindClosestPointWithinRadius
217  (x, radius, closestPoint, cell, cellId, subId, dist2, inside);
218  }
220 
222 
225  static void ComputeOBB(vtkPoints *pts, double corner[3], double max[3],
226  double mid[3], double min[3], double size[3]);
228 
230 
234  void ComputeOBB(vtkDataSet *input, double corner[3], double max[3],
235  double mid[3], double min[3], double size[3]);
237 
242  int InsideOrOutside(const double point[3]);
243 
244  //BTX
245 
247 
249  int DisjointOBBNodes( vtkOBBNode *nodeA, vtkOBBNode *nodeB,
250  vtkMatrix4x4 *XformBtoA );
252 
254  int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
255 
257 
258  int TriangleIntersectsNode( vtkOBBNode *pA,
259  double p0[3], double p1[3],
260  double p2[3], vtkMatrix4x4 *XformBtoA );
262 
264 
266  int IntersectWithOBBTree( vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA,
267  int(*function)( vtkOBBNode *nodeA,
268  vtkOBBNode *nodeB,
269  vtkMatrix4x4 *Xform,
270  void *arg ),
271  void *data_arg );
272  //ETX
274 
276 
277  void FreeSearchStructure();
278  void BuildLocator();
280 
290 
291  //BTX
292 protected:
293  vtkOBBTree();
294  ~vtkOBBTree();
295 
296  // Compute an OBB from the list of cells given. This used to be
297  // public but should not have been. A public call has been added
298  // so that the functionality can be accessed.
299  void ComputeOBB(vtkIdList *cells, double corner[3], double max[3],
300  double mid[3], double min[3], double size[3]);
301 
303  void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level);
306  int OBBCount;
307 
308  void DeleteTree(vtkOBBNode *OBBptr);
309  void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel,
310  vtkPoints* pts, vtkCellArray *polys);
311 
312  //ETX
313 private:
314  vtkOBBTree(const vtkOBBTree&); // Not implemented.
315  void operator=(const vtkOBBTree&); // Not implemented.
316 };
317 
318 #endif
vtkOBBNode * Parent
Definition: vtkOBBTree.h:74
GLsizeiptr size
Definition: vtkgl.h:11843
virtual void BuildLocator()=0
virtual void FindClosestPoint(double x[3], double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
Definition: vtkOBBTree.h:163
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
vtkOBBNode ** Kids
Definition: vtkOBBTree.h:75
abstract class to specify dataset behavior
Definition: vtkDataSet.h:60
GLint level
Definition: vtkgl.h:11316
an abstract base class for locators which find cells
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2, int &inside)
Definition: vtkOBBTree.h:211
int * InsertedPoints
Definition: vtkOBBTree.h:305
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkIdType &cellId, int &subId, double &dist2)
Definition: vtkOBBTree.h:186
int vtkIdType
Definition: vtkType.h:268
GLdouble GLdouble t
Definition: vtkgl.h:11602
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:302
void PrintSelf(ostream &os, vtkIndent indent)
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
virtual int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId)
Definition: vtkOBBTree.h:121
a simple class to control print indentation
Definition: vtkIndent.h:38
int OBBCount
Definition: vtkOBBTree.h:306
list of point or cell ids
Definition: vtkIdList.h:35
#define VTKFILTERSGENERAL_EXPORT
vtkPoints * PointsList
Definition: vtkOBBTree.h:304
virtual void FindClosestPoint(double x[3], double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2)
Definition: vtkOBBTree.h:174
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
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
virtual vtkIdType FindClosestPointWithinRadius(double x[3], double radius, double closestPoint[3], vtkGenericCell *cell, vtkIdType &cellId, int &subId, double &dist2)
Definition: vtkOBBTree.h:198
static vtkObject * New()
virtual void GenerateRepresentation(int level, vtkPolyData *pd)=0
#define max(a, b)
represent and manipulate 3D points
Definition: vtkPoints.h:39
virtual int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
Definition: vtkOBBTree.h:109