compas_model.datastructures
¤
Classes¤
AABBNode
¤
BVH tree node with an axis-aligned bounding box as bounding volume.
-
Reference
datastructures ClassesBVH Functions
BVH
¤
BVH(
nodetype: type[AABBNode] | type[OBBNode] = AABBNode,
max_depth: int | None = None,
leafsize: int = 1,
**kwargs,
)
Bounding Volume Hierarchy as a special case of a (binary) tree.
Parameters:
-
nodetype(type[AABBNode] | type[OBBNode], default:AABBNode) –The type of bounding volume node to use in the tree.
-
max_depth(int | None, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The number of objects contained by a leaf.
Functions¤
from_breps
classmethod
¤
from_breps(
triangles: list[Brep],
nodetype: type[AABBNode] | type[OBBNode] = AABBNode,
max_depth: int | None = None,
leafsize: int = 1,
) -> BVH
Construct a BVH from a collection of breps.
Parameters:
-
triangles(list[Brep]) –A list of brep objects.
-
nodetype(type[AABBNode] | type[OBBNode], default:AABBNode) –The type of node to use during construction.
-
max_depth(int | None, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of breps contained in a leaf node.
Returns:
-
BVH–The constructed tree.
from_mesh
classmethod
¤
from_mesh(
mesh: Mesh,
nodetype: type[AABBNode] | type[OBBNode] = AABBNode,
max_depth: int | None = None,
leafsize: int = 1,
) -> BVH
Construct a BVH from a mesh.
Parameters:
-
mesh(Mesh) –A mesh data structure.
-
nodetype(type[AABBNode] | type[OBBNode], default:AABBNode) –The type of node to use during construction.
-
max_depth(int | None, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of mesh faces contained in a leaf node.
Returns:
-
BVH–The constructed tree.
from_meshes
classmethod
¤
from_meshes(
meshes: list[Mesh],
nodetype: type[AABBNode] | type[OBBNode] = AABBNode,
max_depth: int | None = None,
leafsize: int = 1,
) -> BVH
Construct a BVH from a collection of meshes.
Parameters:
-
meshes(list[Mesh]) –A list of mesh objects.
-
nodetype(type[AABBNode] | type[OBBNode], default:AABBNode) –The type of node to use during construction.
-
max_depth(int | None, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of meshes contained in a leaf node.
Returns:
-
BVH–The constructed tree.
from_polyhedrons
classmethod
¤
from_polyhedrons(
polyhedrons: list[Polyhedron],
nodetype: type[AABBNode] | type[OBBNode] = AABBNode,
max_depth: int | None = None,
leafsize: int = 1,
) -> BVH
Construct a BVH from a collection of polyhedrons.
Parameters:
-
polyhedrons(list[Polyhedron]) –A list of polyhedron objects.
-
nodetype(type[AABBNode] | type[OBBNode], default:AABBNode) –The type of node to use during construction.
-
max_depth(int | None, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of polyhedrons contained in a leaf node.
Returns:
-
BVH–The constructed tree.
from_triangles
classmethod
¤
from_triangles(
triangles: list[list[Point]],
nodetype: type[AABBNode] | type[OBBNode] = AABBNode,
max_depth: int | None = None,
leafsize: int = 1,
) -> BVH
Construct a BVH from a collection of triangles.
Parameters:
-
triangles(list[list[Point]]) –A list of triangles, with each triangle represented by three points.
-
nodetype(type[AABBNode] | type[OBBNode], default:AABBNode) –The type of node to use during construction.
-
max_depth(int | None, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of triangles contained in a leaf node.
Returns:
-
BVH–The constructed tree.
intersect_box
¤
Intersect the tree with a box to find all intersected nodes in descending order.
Parameters:
-
box(Box) –
Yields:
-
BVHNode–Intersected nodes.
intersect_line
¤
Intersect the tree with a line to find all intersected nodes in descending order.
Parameters:
-
line(Line) –
Yields:
-
BVHNode–Intersected nodes.
KDTree
¤
KDTree(elements: list[Element])
A tree for nearest neighbor search in a k-dimensional space.
Parameters:
-
elements(list[Element]) –A list of objects to populate the tree with. The tree is built automatically.
References
Wikipedia, k-d tree: https://en.wikipedia.org/wiki/K-d_tree Dell'Amico, M. KD-Tree for nearest neighbor search in a K-dimensional space (Python recipe): http://code.activestate.com/recipes/577497-kd-tree-for-nearest-neighbor-search-in-a-k-dimensional-space/.
Functions¤
nearest_neighbor
¤
nearest_neighbors
¤
nearest_neighbors(
point: Point, number: int, distance_sort: bool = False
) -> list[tuple[Element, float]]
OBBNode
¤
BVH tree node with an oriented bounding box as bounding volume.
-
Reference
datastructures ClassesBVH Functions