![]() |
UtilsLite
Utilities for C++ programming
|
A class representing an axis-aligned bounding box tree. More...
#include <Utils_AABB_tree.hh>
Public Types | |
using | integer = int |
Integer type. | |
using | AABB_SET = set<integer> |
Set of integers representing bounding box indices. | |
using | AABB_MAP = map<integer,AABB_SET> |
Map for bounding box indices and their overlaps. | |
Public Member Functions | |
AABBtree ()=default | |
Default constructor. | |
AABBtree (AABBtree< Real > const &t) | |
Copy constructor for AABBtree. | |
void | set_max_num_objects_per_node (integer n) |
Sets the maximum number of objects per node. | |
void | set_bbox_long_edge_ratio (Real ratio) |
Sets the bounding box long edge ratio. | |
void | set_bbox_overlap_tolerance (Real tol) |
Sets the bounding box overlap tolerance. | |
void | set_bbox_min_size_tolerance (Real tol) |
Sets the bounding box minimum size tolerance. | |
void | allocate (integer nbox, integer dim) |
Allocates memory for the AABB tree. | |
void | add_bboxes (Real const bb_min[], integer ldim0, Real const bb_max[], integer ldim1) |
Adds bounding boxes to the tree. | |
void | replace_bbox (Real const bbox_min[], Real const bbox_max[], integer ipos) |
Replaces a bounding box at a specific position. | |
void | build () |
Builds the AABB tree. | |
void | build (Real const bb_min[], integer ldim0, Real const bb_max[], integer ldim1, integer nbox, integer dim) |
Builds the AABB tree with specified bounding boxes. | |
void | intersect_with_one_point (Real const pnt[], AABB_SET &bb_index) const |
Intersects the tree with a point. | |
void | intersect_with_one_bbox (Real const bbox[], AABB_SET &bb_index) const |
Intersects the tree with a bounding box. | |
void | intersect (AABBtree< Real > const &aabb, AABB_MAP &bb_index) const |
Intersects the tree with another AABB tree. | |
void | intersect_with_one_point_and_refine (Real const pnt[], AABB_SET &bb_index) const |
Intersects the tree with a point and refines the search. | |
void | intersect_with_one_bbox_and_refine (Real const bbox[], AABB_SET &bb_index) const |
Intersects the tree with a bounding box and refines the search. | |
void | intersect_and_refine (AABBtree< Real > const &aabb, AABB_MAP &bb_index) const |
Intersects the tree with another AABB tree and refines the search. | |
void | min_distance_candidates (Real const pnt[], AABB_SET &bb_index) const |
Finds candidates for minimum distance to a point. | |
void | pnt_bbox_minmax (Real const pnt[], Real const bbox[], Real &dmin, Real &dmax) const |
Calculates minimum and maximum distance from a point to a bounding box. | |
integer | dim () const |
Returns the spatial dimension of the bounding boxes. | |
integer | num_objects () const |
Returns the number of objects (bounding boxes). | |
integer | num_tree_nodes () const |
Returns the number of tree nodes. | |
integer | num_check () const |
Returns the number of overlap checks performed. | |
integer | num_tree_nodes (integer nmin) const |
Returns the number of tree nodes with at least nmin objects. | |
void | get_root_bbox (Real bb_min[], Real bb_max[]) const |
Gets the bounding box of the root node. | |
void | get_bboxes_of_the_tree (Real bb_min[], integer ldim0, Real bb_max[], integer ldim1, integer nmin) const |
Gets bounding boxes of the tree. | |
void | get_bbox_indexes_of_a_node (integer i_pos, AABB_SET &bb_index) const |
Gets the indices of bounding boxes in a specific tree node. | |
string | info () const |
Returns information about the AABB tree. | |
A class representing an axis-aligned bounding box tree.
The AABBtree class provides an efficient way to store and query a set of axis-aligned bounding boxes. It supports various operations such as building the tree, adding bounding boxes, and performing intersection tests.
Real | Type of the real numbers (e.g., float, double). |
using Utils::AABBtree< Real >::AABB_MAP = map<integer,AABB_SET> |
Map for bounding box indices and their overlaps.
using Utils::AABBtree< Real >::AABB_SET = set<integer> |
Set of integers representing bounding box indices.
using Utils::AABBtree< Real >::integer = int |
Integer type.
|
default |
Default constructor.
Utils::AABBtree< Real >::AABBtree | ( | AABBtree< Real > const & | t | ) |
void Utils::AABBtree< Real >::add_bboxes | ( | Real const | bb_min[], |
integer | ldim0, | ||
Real const | bb_max[], | ||
integer | ldim1 ) |
Adds bounding boxes to the tree.
bb_min | Minimum corners of bounding boxes. |
ldim0 | Leading dimension for the minimum corners. |
bb_max | Maximum corners of bounding boxes. |
ldim1 | Leading dimension for the maximum corners. |
void Utils::AABBtree< Real >::allocate | ( | integer | nbox, |
integer | dim ) |
Allocates memory for the AABB tree.
nbox | Number of bounding boxes. |
dim | Dimension of the bounding boxes. |
void Utils::AABBtree< Real >::build | ( | ) |
Builds the AABB tree.
|
inline |
Builds the AABB tree with specified bounding boxes.
bb_min | Minimum corners of bounding boxes. |
ldim0 | Leading dimension for the minimum corners. |
bb_max | Maximum corners of bounding boxes. |
ldim1 | Leading dimension for the maximum corners. |
nbox | Number of bounding boxes. |
dim | Dimension of the bounding boxes. |
|
inline |
Returns the spatial dimension of the bounding boxes.
void Utils::AABBtree< Real >::get_bbox_indexes_of_a_node | ( | integer | i_pos, |
AABB_SET & | bb_index ) const |
Gets the indices of bounding boxes in a specific tree node.
i_pos | Index of the node. |
bb_index | Set to store indices of bounding boxes. |
void Utils::AABBtree< Real >::get_bboxes_of_the_tree | ( | Real | bb_min[], |
integer | ldim0, | ||
Real | bb_max[], | ||
integer | ldim1, | ||
integer | nmin ) const |
Gets bounding boxes of the tree.
bb_min | Array to store the minimum corners. |
ldim0 | Leading dimension for minimum corners. |
bb_max | Array to store the maximum corners. |
ldim1 | Leading dimension for maximum corners. |
nmin | Minimum number of objects in a node. |
void Utils::AABBtree< Real >::get_root_bbox | ( | Real | bb_min[], |
Real | bb_max[] ) const |
Gets the bounding box of the root node.
bb_min | Array to store the minimum corner. |
bb_max | Array to store the maximum corner. |
string Utils::AABBtree< Real >::info | ( | ) | const |
Returns information about the AABB tree.
void Utils::AABBtree< Real >::intersect | ( | AABBtree< Real > const & | aabb, |
AABB_MAP & | bb_index ) const |
Intersects the tree with another AABB tree.
aabb | The other AABB tree to intersect with. |
bb_index | Map to store indices of intersecting bounding boxes. |
void Utils::AABBtree< Real >::intersect_and_refine | ( | AABBtree< Real > const & | aabb, |
AABB_MAP & | bb_index ) const |
Intersects the tree with another AABB tree and refines the search.
aabb | The other AABB tree to intersect with. |
bb_index | Map to store indices of intersecting bounding boxes. |
void Utils::AABBtree< Real >::intersect_with_one_bbox | ( | Real const | bbox[], |
AABB_SET & | bb_index ) const |
Intersects the tree with a bounding box.
bbox | The bounding box to intersect with. |
bb_index | Set to store indices of intersecting bounding boxes. |
void Utils::AABBtree< Real >::intersect_with_one_bbox_and_refine | ( | Real const | bbox[], |
AABB_SET & | bb_index ) const |
Intersects the tree with a bounding box and refines the search.
bbox | The bounding box to intersect with. |
bb_index | Set to store indices of intersecting bounding boxes. |
void Utils::AABBtree< Real >::intersect_with_one_point | ( | Real const | pnt[], |
AABB_SET & | bb_index ) const |
Intersects the tree with a point.
pnt | The point to intersect with. |
bb_index | Set to store indices of intersecting bounding boxes. |
void Utils::AABBtree< Real >::intersect_with_one_point_and_refine | ( | Real const | pnt[], |
AABB_SET & | bb_index ) const |
Intersects the tree with a point and refines the search.
pnt | The point to intersect with. |
bb_index | Set to store indices of intersecting bounding boxes. |
void Utils::AABBtree< Real >::min_distance_candidates | ( | Real const | pnt[], |
AABB_SET & | bb_index ) const |
Finds candidates for minimum distance to a point.
pnt | The point to check against. |
bb_index | Set to store indices of candidate bounding boxes. |
|
inline |
Returns the number of overlap checks performed.
|
inline |
Returns the number of objects (bounding boxes).
|
inline |
Returns the number of tree nodes.
AABBtree< Real >::integer Utils::AABBtree< Real >::num_tree_nodes | ( | integer | nmin | ) | const |
Returns the number of tree nodes with at least nmin objects.
nmin | Minimum number of objects in the node. |
void Utils::AABBtree< Real >::pnt_bbox_minmax | ( | Real const | pnt[], |
Real const | bbox[], | ||
Real & | dmin, | ||
Real & | dmax ) const |
Calculates minimum and maximum distance from a point to a bounding box.
pnt | The point. |
bbox | The bounding box. |
dmin | Minimum distance. |
dmax | Maximum distance. |
void Utils::AABBtree< Real >::replace_bbox | ( | Real const | bbox_min[], |
Real const | bbox_max[], | ||
integer | ipos ) |
Replaces a bounding box at a specific position.
bbox_min | New minimum corner of the bounding box. |
bbox_max | New maximum corner of the bounding box. |
ipos | Index of the bounding box to replace. |
void Utils::AABBtree< Real >::set_bbox_long_edge_ratio | ( | Real | ratio | ) |
Sets the bounding box long edge ratio.
ratio | Long edge ratio. |
void Utils::AABBtree< Real >::set_bbox_min_size_tolerance | ( | Real | tol | ) |
Sets the bounding box minimum size tolerance.
tol | Minimum size tolerance. |
void Utils::AABBtree< Real >::set_bbox_overlap_tolerance | ( | Real | tol | ) |
Sets the bounding box overlap tolerance.
tol | Overlap tolerance. |
void Utils::AABBtree< Real >::set_max_num_objects_per_node | ( | integer | n | ) |
Sets the maximum number of objects per node.
n | Maximum number of objects. |