OBBTree
Introduction
vtkOBBTree - generate an oriented bounding box hierarchy for a dataset
vtkOBBTree builds a tree of oriented bounding boxes over the cells of a vtkPolyData. Each node holds the box of a subset of the cells, split in two along its longest axis until the leaves hold no more than numberOfCellsPerNode cells or the maximum level is reached. The tree can then be tested against another OBB tree to find intersecting cells.
Methods
buildLocator
Build the OBB tree of the current dataset. The tree is discarded and rebuilt on every call.
computeOBBFromDataset
Compute the oriented bounding box of a dataset without building a tree. The results are written into the arrays passed in.
| Argument | Type | Required | Description |
|---|---|---|---|
input | vtkPolyData | Yes | |
corner | Vector3 | Yes | corner the axes originate from |
max | Vector3 | Yes | longest axis |
mid | Vector3 | Yes | middle axis |
min | Vector3 | Yes | shortest axis |
size | Vector3 | Yes | extent of the box along each axis |
deepCopy
Copy the settings and the tree of another OBB tree into this one.
| Argument | Type | Required | Description |
|---|---|---|---|
tree | vtkOBBTree | Yes |
disjointOBBNodes
Test whether two nodes are disjoint, nodeB being optionally transformed into the space of nodeA by XformBtoA. Returns 0 when the boxes overlap and the number of the separating axis test that succeeded otherwise.
| Argument | Type | Required | Description |
|---|---|---|---|
nodeA | vtkOBBNode | Yes | |
nodeB | vtkOBBNode | Yes | |
XformBtoA | mat4 | No | assumed to be orthogonal |
extend
Method used to decorate a given object (publicAPI+model) with vtkOBBTree characteristics.
| Argument | Type | Required | Description |
|---|---|---|---|
publicAPI | Yes | object on which methods will be bounds (public) | |
model | Yes | object on which data structure will be bounds (protected) | |
initialValues | IOBBTreeInitialValues | No | (default: {}) |
findTriangleIntersections
Intersect the triangles of two leaf nodes and append the resulting segments to info.intersectionLines. Returns the number of intersection lines found.
| Argument | Type | Required | Description |
|---|---|---|---|
info | ITriangleIntersectionInfo | Yes | |
node0 | vtkOBBNode | Yes | leaf of this tree |
node1 | vtkOBBNode | Yes | leaf of info.obbTree1 |
transform | mat4 | No |
generateRepresentation
Create a polygonal representation of the boxes at the given level. When level is negative the leaf nodes are gathered instead. Returns null when the tree has not been built.
| Argument | Type | Required | Description |
|---|---|---|---|
level | Number | Yes |
getAutomatic
Get whether the number of cells per node is computed from the dataset.
getDataset
Get the dataset the tree is built from.
getLevel
Get the depth reached by the last call to buildLocator.
getMaxLevel
Get the maximum depth of the tree.
getNumberOfCellsPerNode
Get the number of cells below which a node is not split any further.
getRetainCellLists
Get whether the cell lists of the non-leaf nodes are kept.
getTolerance
Get the tolerance used by the separating axis tests.
getTree
Get the root node of the tree.
intersectWithOBBTree
Traverse this tree against obbTreeB and call onIntersect for every pair of intersecting leaf nodes. obbTreeB is optionally transformed into the space of this tree by XformBtoA. Returns the accumulated absolute value of the callback results.
| Argument | Type | Required | Description |
|---|---|---|---|
obbTreeB | vtkOBBTree | Yes | |
XformBtoA | mat4 | No | |
onIntersect | OnIntersectCallback | No | (default: () => -1) |
intersectionLines
Polydata the intersection points and lines are appended to.
newInstance
Method used to create a new instance of vtkOBBTree
| Argument | Type | Required | Description |
|---|---|---|---|
initialValues | IOBBTreeInitialValues | No | for pre-setting some of its content |
obbTree1
The tree the triangles of the second node belong to.
setAutomatic
Set whether the number of cells per node is computed from the dataset.
| Argument | Type | Required | Description |
|---|---|---|---|
automatic | Boolean | Yes |
setDataset
Set the dataset the tree is built from.
| Argument | Type | Required | Description |
|---|---|---|---|
dataset | vtkPolyData | Yes |
setLevel
Set the depth of the tree.
| Argument | Type | Required | Description |
|---|---|---|---|
level | Number | Yes |
setMaxLevel
Set the maximum depth of the tree.
| Argument | Type | Required | Description |
|---|---|---|---|
maxLevel | Number | Yes |
setNumberOfCellsPerNode
Set the number of cells below which a node is not split any further.
| Argument | Type | Required | Description |
|---|---|---|---|
numberOfCellsPerNode | Number | Yes |
setRetainCellLists
Set whether the cell lists of the non-leaf nodes are kept.
| Argument | Type | Required | Description |
|---|---|---|---|
retainCellLists | Number | Yes |
setTolerance
Set the tolerance used by the separating axis tests.
| Argument | Type | Required | Description |
|---|---|---|---|
tolerance | Number | Yes |
setTree
Set the root node of the tree.
| Argument | Type | Required | Description |
|---|---|---|---|
tree | vtkOBBNode | Yes |
transform
Apply a transform to every node of the tree in place.
| Argument | Type | Required | Description |
|---|---|---|---|
transform | Transform | Yes | a vtkMatrixBuilder transform |
triangleIntersectsNode
Test whether a triangle intersects a node, the triangle being optionally transformed into the space of the node by XformBtoA. Returns 1 when they overlap and 0 otherwise.
| Argument | Type | Required | Description |
|---|---|---|---|
nodeA | vtkOBBNode | Yes | |
p0 | Vector3 | Yes | |
p1 | Vector3 | Yes | |
p2 | Vector3 | Yes | |
XformBtoA | mat4 | No | assumed to be orthogonal |