NAME
vtkOBBTree - generate oriented bounding box (OBB) tree
SYNOPSIS
#include "/opt/vtk-c++/graphics/vtkOBBTree.h"
class VTK_EXPORT vtkOBBTree : public vtkCellLocator
vtkOBBTree();
static vtkOBBTree *New() {return new vtkOBBTree;};
const char *GetClassName() {return "vtkOBBTree";};
void ComputeOBB(vtkFloatPoints *pts, float corner[3], float max[3],
float mid[3], float min[3], float size[3]);
int IntersectWithLine(float a0[3], float a1[3], float& t,
float x[3], float pcoords[3],int &subId);
void FreeSearchStructure();
void BuildLocator();
void GenerateRepresentation(int level, vtkPolyData *pd);
DESCRIPTION
vtkOBBTree is an object to generate oriented bounding box (OBB) trees. An oriented bounding box is a bounding box that does not necessarily line up along coordinate axes. The OBB tree is a hierarchical tree structure of such boxes, where deeper levels of OBB confine smaller regions of space.
To build the OBB, a recursive, top-down process is used. First, the root OBB is constructed by finding the mean and covariance matrix of the cells (and their points) that define the dataset. The eigenvectors of the covariance matrix are extracted, giving a set of three orthogonal vectors that define the tightest-fitting OBB. To create the two children OBB's, a split plane is found that (approximately) divides the number cells in half. These are then assigned to the children OBB's. This process then continues until the MaxLevel ivar limits the recursion, or no split plane can be found.
A good reference for OBB-trees is Gottschalk & Manocha in Proceedings of Siggraph `96.
CAVEATS
Since this algorithms works from a list of cells, the OBB tree will only bound the "geometry" attached to the cells if the convex hull of the cells bounds the geometry.
Long, skinny cells (i.e., cells with poor aspect ratio) may cause unsatisfactory results. This is due to the fact that this is a top-down implementation of the OBB tree, requiring that one or more complete cells are contained in each OBB. This requirement makes it hard to find good split planes during the recurion process. A bottom-up implementation would go a long way to correcting this problem.
SEE ALSO
vtkLocator vtkCellLocator vtkLocatorFilter
vtkOBBTree()
Construct with automatic computation of divisions, averaging 25 cells per octant.
void ComputeOBB(vtkFloatPoints *pts, float corner[3], float max[3],
float mid[3], float min[3], float size[3])
Compute an OBB from the list of points given. Return the corner point and the three axes defining the orientation of the OBB. Also return a sorted list of relative "sizes" of axes for comparison purposes.
int IntersectWithLine(float a0[3], float a1[3], float& t, float x[3], float pcoords[3],
int &subId)
Return intersection point of line defined by two points (a0,a1) in dataset coordinate system; returning cellId (or -1 if no intersection). The argument list returns the intersection parametric coordinate, t, along the line; the coordinate of intersection, x[3]; the cell parametric coordinates, pcoords[3]; and subId of the cell. (Not yet implemented.)
void GenerateRepresentation(int level, vtkPolyData *pd) Create polygonal representation for OBB tree at specified level. If level < 0, then the leaf OBB nodes will be gathered. The aspect ratio (ar) and line diameter (d) are used to control the building of the representation. If a OBB node edge ratio's are greater than ar, then the dimension of the OBB is collapsed (OBB>plane->line). A "line" OBB will be represented either
as two crossed polygons, or as a line, depending on the relative diameter of the OBB compared to the diameter (d).