FreeMat: vtkOBBTree

FreeMat

- Main Page
- Related Pages

vtkOBBTree

Section: Visualization Toolkit Graphics Classes

# Usage

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.

To create an instance of class vtkOBBTree, simply invoke its constructor as follows

      obj = vtkOBBTree

# Methods

The class vtkOBBTree has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkOBBTree class.

- `string = obj.GetClassName ()`
- `int = obj.IsA (string name)`
- `vtkOBBTree = obj.NewInstance ()`
- `vtkOBBTree = obj.SafeDownCast (vtkObject o)`
- `int = obj.IntersectWithLine (double a0[3], double a1[3], vtkPoints points, vtkIdList cellIds)` - Take the passed line segment and intersect it with the data set. This method assumes that the data set is a vtkPolyData that describes a closed surface, and the intersection points that are returned in 'points' alternate between entrance points and exit points. The return value of the function is 0 if no intersections were found, -1 if point 'a0' lies inside the closed surface, or +1 if point 'a0' lies outside the closed surface. Either 'points' or 'cellIds' can be set to NULL if you don't want to receive that information.
- `obj.ComputeOBB (vtkDataSet input, double corner[3], double max[3], double mid[3], double min[3], double size[3])` - Compute an OBB for the input dataset using the cells in the data. 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 = obj.InsideOrOutside (double point[3])` - Determine whether a point is inside or outside the data used to build this OBB tree. The data must be a closed surface vtkPolyData data set. The return value is +1 if outside, -1 if inside, and 0 if undecided.
- `obj.FreeSearchStructure ()` - Satisfy locator's abstract interface, see vtkLocator.
- `obj.BuildLocator ()` - Satisfy locator's abstract interface, see vtkLocator.
- `obj.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).