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:
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 
151  vtkMatrix4x4 *XformBtoA );
153 
155  int LineIntersectsNode( vtkOBBNode *pA, double b0[3], double b1[3] );
156 
158 
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 
179  void BuildLocator();
181 
191 
192  //BTX
193 protected:
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
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkOBBTree::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkOBBNode::~vtkOBBNode
~vtkOBBNode()
vtkOBBNode::Kids
vtkOBBNode ** Kids
Definition: vtkOBBTree.h:75
vtkOBBTree::DeleteTree
void DeleteTree(vtkOBBNode *OBBptr)
vtkAbstractCellLocator::IntersectWithLine
virtual int IntersectWithLine(double p1[3], double p2[3], double tol, double &t, double x[3], double pcoords[3], int &subId)
vtkIdType
int vtkIdType
Definition: vtkType.h:275
vtkOBBTree::OBBCount
int OBBCount
Definition: vtkOBBTree.h:207
vtkOBBTree::LineIntersectsNode
int LineIntersectsNode(vtkOBBNode *pA, double b0[3], double b1[3])
vtkOBBTree::GenerateRepresentation
void GenerateRepresentation(int level, vtkPolyData *pd)
vtkOBBTree
generate oriented bounding box (OBB) tree
Definition: vtkOBBTree.h:88
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkAbstractCellLocator.h
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkOBBTree::New
static vtkOBBTree * New()
vtkOBBTree::ComputeOBB
void ComputeOBB(vtkDataSet *input, double corner[3], double max[3], double mid[3], double min[3], double size[3])
vtkgl::input
GLenum GLenum GLenum input
Definition: vtkgl.h:15941
vtkOBBTree::BuildLocator
void BuildLocator()
vtkgl::points
GLsizei const GLfloat * points
Definition: vtkgl.h:14786
vtkOBBTree::PointsList
vtkPoints * PointsList
Definition: vtkOBBTree.h:205
vtkOBBNode::Parent
vtkOBBNode * Parent
Definition: vtkOBBTree.h:74
max
#define max(a, b)
Definition: vtkX3DExporterFIWriterHelper.h:30
vtkOBBTree::vtkOBBTree
vtkOBBTree()
vtkOBBTree::BuildTree
void BuildTree(vtkIdList *cells, vtkOBBNode *parent, int level)
vtkX3D::point
@ point
Definition: vtkX3D.h:236
vtkOBBNode::Cells
vtkIdList * Cells
Definition: vtkOBBTree.h:76
vtkFiltersGeneralModule.h
vtkOBBNode
Definition: vtkOBBTree.h:67
vtkOBBTree::GeneratePolygons
void GeneratePolygons(vtkOBBNode *OBBptr, int level, int repLevel, vtkPoints *pts, vtkCellArray *polys)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:39
vtkCellArray
object to represent cell connectivity
Definition: vtkCellArray.h:50
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
VTKFILTERSGENERAL_EXPORT
#define VTKFILTERSGENERAL_EXPORT
Definition: vtkFiltersGeneralModule.h:15
vtkOBBTree::~vtkOBBTree
~vtkOBBTree()
vtkOBBTree::IntersectWithOBBTree
int IntersectWithOBBTree(vtkOBBTree *OBBTreeB, vtkMatrix4x4 *XformBtoA, int(*function)(vtkOBBNode *nodeA, vtkOBBNode *nodeB, vtkMatrix4x4 *Xform, void *arg), void *data_arg)
vtkgl::level
GLint level
Definition: vtkgl.h:11316
vtkAbstractCellLocator
an abstract base class for locators which find cells
Definition: vtkAbstractCellLocator.h:50
vtkOBBTree::IntersectWithLine
int IntersectWithLine(double a0[3], double a1[3], double tol, double &t, double x[3], double pcoords[3], int &subId, vtkIdType &cellId, vtkGenericCell *cell)
vtkDataSet
abstract class to specify dataset behavior
Definition: vtkDataSet.h:62
vtkOBBNode::vtkOBBNode
vtkOBBNode()
vtkOBBTree::DisjointOBBNodes
int DisjointOBBNodes(vtkOBBNode *nodeA, vtkOBBNode *nodeB, vtkMatrix4x4 *XformBtoA)
vtkgl::t
GLdouble GLdouble t
Definition: vtkgl.h:11602
vtkOBBTree::InsideOrOutside
int InsideOrOutside(const double point[3])
vtkOBBTree::ComputeOBB
static void ComputeOBB(vtkPoints *pts, double corner[3], double max[3], double mid[3], double min[3], double size[3])
vtkOBBTree::ComputeOBB
void ComputeOBB(vtkIdList *cells, double corner[3], double max[3], double mid[3], double min[3], double size[3])
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkGenericCell
provides thread-safe access to cells
Definition: vtkGenericCell.h:42
vtkOBBTree::IntersectWithLine
int IntersectWithLine(const double a0[3], const double a1[3], vtkPoints *points, vtkIdList *cellIds)
vtkOBBNode::DebugPrintTree
void DebugPrintTree(int level, double *leaf_vol, int *minCells, int *maxCells)
vtkOBBTree::InsertedPoints
int * InsertedPoints
Definition: vtkOBBTree.h:206
vtkOBBTree::Tree
vtkOBBNode * Tree
Definition: vtkOBBTree.h:203
vtkOBBTree::FreeSearchStructure
void FreeSearchStructure()
vtkOBBTree::TriangleIntersectsNode
int TriangleIntersectsNode(vtkOBBNode *pA, double p0[3], double p1[3], double p2[3], vtkMatrix4x4 *XformBtoA)
vtkgl::size
GLsizeiptr size
Definition: vtkgl.h:11843