# BoundingBoxTree¶

class dolfin.cpp.mesh.BoundingBoxTree(*args)

Bases: object

This class implements a (distributed) axis aligned bounding box tree (AABB tree). Bounding box trees can be created from meshes and [other data structures, to be filled in].

Create empty bounding box tree

build()

• build(mesh)

Build bounding box tree for cells of mesh.

Arguments
mesh (Mesh)

The mesh for which to compute the bounding box tree.

• build(mesh, tdim)

Build bounding box tree for mesh entities of given dimension.

Arguments
mesh (Mesh)

The mesh for which to compute the bounding box tree.

dimension (int)

The entity dimension (topological dimension) for which to compute the bounding box tree.

• build(points, gdim)

Build bounding box tree for point cloud.

Arguments
points (list of Point)

The list of points.

gdim (int)

The geometric dimension.

compute_closest_entity()

Compute closest entity to Point.

Returns
int
The local index for the entity that is closest to the point. If more than one entity is at the same distance (or point contained in entity), then the first entity is returned.
double
The distance to the closest entity.
Arguments
point (Point)
The point.
compute_closest_point()

Compute closest point to Point. This function assumes that the tree has been built for a point cloud.

Developer note: This function should not be confused with computing the closest point in all entities of a mesh. That function could be added with relative ease since we actually compute the closest points to get the distance in the above function (compute_closest_entity) inside the specialized implementations in TetrahedronCell.cpp etc.

Returns
int
The local index for the point that is closest to the point. If more than one point is at the same distance (or point contained in entity), then the first point is returned.
double
The distance to the closest point.
Arguments
point (Point)
The point.
compute_collisions()

• compute_collisions(point)

Compute all collisions between bounding boxes and Point.

Returns
numpy.array(int)

A list of local indices for entities contained in (leaf) bounding boxes that collide with (intersect) the given point.

Arguments
point (Point)

The point.

• compute_collisions(tree)

Compute all collisions between bounding boxes and BoundingBoxTree.

Returns std::pair<std::vector<unsigned int>, std::vector<unsigned int> >

Two lists of local indices for entities contained in (leaf) bounding boxes that collide with (intersect) the given bounding box tree. The first list contains entity indices for the first tree (this tree) and the second contains entity indices for the second tree (the input argument).

Arguments
tree (BoundingBoxTree)

The bounding box tree.

compute_entity_collisions()

• compute_entity_collisions(point)

Compute all collisions between entities and Point.

Returns
numpy.array(int)

A list of local indices for entities that collide with (intersect) the given point.

Arguments
point (Point)

The point.

• compute_entity_collisions(tree)

Compute all collisions between entities and BoundingBoxTree.

Returns
std::pair<std::vector<unsigned int>, std::vector<unsigned int> >

A list of local indices for entities that collide with (intersect) the given bounding box tree. The first list contains entity indices for the first tree (this tree) and the second contains entity indices for the second tree (the input argument).

Arguments
tree (BoundingBoxTree)

The bounding box tree.

compute_first_collision()

Compute first collision between bounding boxes and Point.

Returns
int
The local index for the first found entity contained in a (leaf) bounding box that collides with (intersects) the given point. If not found, std::numeric_limits<unsigned int>::max() is returned.
Arguments
point (Point)
The point.
compute_first_entity_collision()

Compute first collision between entities and Point.

Returns
int
The local index for the first found entity that collides with (intersects) the given point. If not found, std::numeric_limits<unsigned int>::max() is returned.
Arguments
point (Point)
The point.
thisown

The membership flag