BVH

class compas_model.datastructures.BVH(nodetype=<class 'compas_model.datastructures.bvh.AABBNode'>, max_depth=None, leafsize=1, **kwargs)

Bases: Tree

Bounding Volume Hierarchy as a special case of a (binary) tree.

Parameters:
nodetypeType[AABBNode] | Type[OBBNode], optional

The type of boundng volume node to use in the tree.

max_depthint, optional

The maximum depth of the tree.

leafsizeint, optional

The number of objects contained by a leaf.

Notes

This class has the following constructors:

References

Examples

>>>

Methods

from_breps

Construct a BVH from a mesh.

from_mesh

Construct a BVH from a mesh.

from_meshes

Construct a BVH from a collection of meshes.

from_polyhedrons

Construct a BVH from a mesh.

from_triangles

Construct a BVH from a collection of triangles.

intersect_box

Intersect the tree with a box to find all intersected nodes in descending order.

intersect_line

Intersect the tree with a line to find all intersected nodes in descending order.

intersect_sphere

Intersect the tree with a sphere to find all intersected nodes in descending order.

nnbrs

object_nnbrs

point_nnbrs

rebuild

Rebuild the tree using the current objects.

refit

Refit the tree to the current objects.

Inherited Methods

ToString

Converts the instance to a string.

add

Add a node to the tree.

compute_aabb

Compute the axis-aligned bounding box of the datastructure.

compute_obb

Compute the oriented bounding box of the datastructure.

copy

Make an independent copy of the data object.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

get_hierarchy_string

Return string representation for the spatial hierarchy of the tree.

get_node_by_name

Get a node by its name.

get_nodes_by_name

Get all nodes by their name.

remove

Remove a node from the tree.

rotate

Rotate the datastructure.

rotated

Returns a rotated copy of this geometry.

scale

Scale the datastructure.

scaled

Returns a scaled copy of this geometry.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_graph

Convert the tree to a graph.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

transform

Transforms the data structure.

transform_numpy

Transforms the data structure.

transformed

Returns a transformed copy of this data structure.

transformed_numpy

Returns a transformed copy of this data structure.

translate

Translate the datastructure.

translated

Returns a translated copy of this geometry.

traverse

Traverse the tree from the root node.

validate_data

Validate the data against the object's data schema.