compas_model.datastructures
¤
Classes¤
AABBNode
¤
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 boundng volume node to use in the tree.
-
max_depth(int, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The number of objects contained by a leaf.
Examples:
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 mesh.
Parameters:
-
breps(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, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of breps contained in a leaf node.
Returns:
-
BVH–
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, 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–
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, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of meshes contained in a leaf node.
Returns:
-
BVH–
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 mesh.
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, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of polyhedrons contained in a leaf node.
Returns:
-
BVH–
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, default:None) –The maximum depth of the tree.
-
leafsize(int, default:1) –The maximum number of triangles contained in a leaf node.
Returns:
-
BVH–
intersect_box
¤
Intersect the tree with a box to find all intersected nodes in descending order.
Parameters:
-
box(Box) –
Yields:
-
BVHNode–
intersect_line
¤
Intersect the tree with a line to find all intersected nodes in descending order.
Parameters:
-
line(Line) –
Yields:
-
BVHNode–
KDTree
¤
KDTree(elements: list[Element])
A tree for nearest neighbor search in a k-dimensional space.
Parameters:
-
objects(sequence[[float, float, float] | Point]) –A list of objects to populate the tree with. If objects are provided, the tree is built automatically. Otherwise, use :meth:
build.
Attributes:
-
root(Node) –The root node of the built tree. This is the median with respect to the different dimensions of the tree.
Notes
For more info, see [1] and [2].
References
.. [1] Wikipedia. k-d tree. Available at: https://en.wikipedia.org/wiki/K-d_tree. .. [2] Dell'Amico, M. KD-Tree for nearest neighbor search in a K-dimensional space (Python recipe). Available at: 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]]