UtilsLite
Utilities for C++ programming
Loading...
Searching...
No Matches
Utils::AABBtree< Real > Class Template Reference

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.
 

Detailed Description

template<typename Real>
class Utils::AABBtree< Real >

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.

Template Parameters
RealType of the real numbers (e.g., float, double).

Member Typedef Documentation

◆ AABB_MAP

template<typename Real>
using Utils::AABBtree< Real >::AABB_MAP = map<integer,AABB_SET>

Map for bounding box indices and their overlaps.

◆ AABB_SET

template<typename Real>
using Utils::AABBtree< Real >::AABB_SET = set<integer>

Set of integers representing bounding box indices.

◆ integer

template<typename Real>
using Utils::AABBtree< Real >::integer = int

Integer type.

Constructor & Destructor Documentation

◆ AABBtree() [1/2]

template<typename Real>
Utils::AABBtree< Real >::AABBtree ( )
default

Default constructor.

◆ AABBtree() [2/2]

template<typename Real>
Utils::AABBtree< Real >::AABBtree ( AABBtree< Real > const & t)

Copy constructor for AABBtree.

Parameters
tAnother AABBtree object to copy from.

Member Function Documentation

◆ add_bboxes()

template<typename Real>
void Utils::AABBtree< Real >::add_bboxes ( Real const bb_min[],
integer ldim0,
Real const bb_max[],
integer ldim1 )

Adds bounding boxes to the tree.

Parameters
bb_minMinimum corners of bounding boxes.
ldim0Leading dimension for the minimum corners.
bb_maxMaximum corners of bounding boxes.
ldim1Leading dimension for the maximum corners.

◆ allocate()

template<typename Real>
void Utils::AABBtree< Real >::allocate ( integer nbox,
integer dim )

Allocates memory for the AABB tree.

Parameters
nboxNumber of bounding boxes.
dimDimension of the bounding boxes.

◆ build() [1/2]

template<typename Real>
void Utils::AABBtree< Real >::build ( )

Builds the AABB tree.

◆ build() [2/2]

template<typename Real>
void Utils::AABBtree< Real >::build ( Real const bb_min[],
integer ldim0,
Real const bb_max[],
integer ldim1,
integer nbox,
integer dim )
inline

Builds the AABB tree with specified bounding boxes.

Parameters
bb_minMinimum corners of bounding boxes.
ldim0Leading dimension for the minimum corners.
bb_maxMaximum corners of bounding boxes.
ldim1Leading dimension for the maximum corners.
nboxNumber of bounding boxes.
dimDimension of the bounding boxes.

◆ dim()

template<typename Real>
integer Utils::AABBtree< Real >::dim ( ) const
inline

Returns the spatial dimension of the bounding boxes.

Returns
Dimension of the bounding boxes.

◆ get_bbox_indexes_of_a_node()

template<typename Real>
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.

Parameters
i_posIndex of the node.
bb_indexSet to store indices of bounding boxes.

◆ get_bboxes_of_the_tree()

template<typename Real>
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.

Parameters
bb_minArray to store the minimum corners.
ldim0Leading dimension for minimum corners.
bb_maxArray to store the maximum corners.
ldim1Leading dimension for maximum corners.
nminMinimum number of objects in a node.

◆ get_root_bbox()

template<typename Real>
void Utils::AABBtree< Real >::get_root_bbox ( Real bb_min[],
Real bb_max[] ) const

Gets the bounding box of the root node.

Parameters
bb_minArray to store the minimum corner.
bb_maxArray to store the maximum corner.

◆ info()

template<typename Real>
string Utils::AABBtree< Real >::info ( ) const

Returns information about the AABB tree.

Returns
A string containing information about the tree.

◆ intersect()

template<typename Real>
void Utils::AABBtree< Real >::intersect ( AABBtree< Real > const & aabb,
AABB_MAP & bb_index ) const

Intersects the tree with another AABB tree.

Parameters
aabbThe other AABB tree to intersect with.
bb_indexMap to store indices of intersecting bounding boxes.

◆ intersect_and_refine()

template<typename Real>
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.

Parameters
aabbThe other AABB tree to intersect with.
bb_indexMap to store indices of intersecting bounding boxes.

◆ intersect_with_one_bbox()

template<typename Real>
void Utils::AABBtree< Real >::intersect_with_one_bbox ( Real const bbox[],
AABB_SET & bb_index ) const

Intersects the tree with a bounding box.

Parameters
bboxThe bounding box to intersect with.
bb_indexSet to store indices of intersecting bounding boxes.

◆ intersect_with_one_bbox_and_refine()

template<typename Real>
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.

Parameters
bboxThe bounding box to intersect with.
bb_indexSet to store indices of intersecting bounding boxes.

◆ intersect_with_one_point()

template<typename Real>
void Utils::AABBtree< Real >::intersect_with_one_point ( Real const pnt[],
AABB_SET & bb_index ) const

Intersects the tree with a point.

Parameters
pntThe point to intersect with.
bb_indexSet to store indices of intersecting bounding boxes.

◆ intersect_with_one_point_and_refine()

template<typename Real>
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.

Parameters
pntThe point to intersect with.
bb_indexSet to store indices of intersecting bounding boxes.

◆ min_distance_candidates()

template<typename Real>
void Utils::AABBtree< Real >::min_distance_candidates ( Real const pnt[],
AABB_SET & bb_index ) const

Finds candidates for minimum distance to a point.

Parameters
pntThe point to check against.
bb_indexSet to store indices of candidate bounding boxes.

◆ num_check()

template<typename Real>
integer Utils::AABBtree< Real >::num_check ( ) const
inline

Returns the number of overlap checks performed.

Returns
Number of checks.

◆ num_objects()

template<typename Real>
integer Utils::AABBtree< Real >::num_objects ( ) const
inline

Returns the number of objects (bounding boxes).

Returns
Number of objects.

◆ num_tree_nodes() [1/2]

template<typename Real>
integer Utils::AABBtree< Real >::num_tree_nodes ( ) const
inline

Returns the number of tree nodes.

Returns
Number of tree nodes.

◆ num_tree_nodes() [2/2]

template<typename Real>
AABBtree< Real >::integer Utils::AABBtree< Real >::num_tree_nodes ( integer nmin) const

Returns the number of tree nodes with at least nmin objects.

Parameters
nminMinimum number of objects in the node.
Returns
Number of nodes.

◆ pnt_bbox_minmax()

template<typename Real>
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.

Parameters
pntThe point.
bboxThe bounding box.
dminMinimum distance.
dmaxMaximum distance.

◆ replace_bbox()

template<typename Real>
void Utils::AABBtree< Real >::replace_bbox ( Real const bbox_min[],
Real const bbox_max[],
integer ipos )

Replaces a bounding box at a specific position.

Parameters
bbox_minNew minimum corner of the bounding box.
bbox_maxNew maximum corner of the bounding box.
iposIndex of the bounding box to replace.

◆ set_bbox_long_edge_ratio()

template<typename Real>
void Utils::AABBtree< Real >::set_bbox_long_edge_ratio ( Real ratio)

Sets the bounding box long edge ratio.

Parameters
ratioLong edge ratio.

◆ set_bbox_min_size_tolerance()

template<typename Real>
void Utils::AABBtree< Real >::set_bbox_min_size_tolerance ( Real tol)

Sets the bounding box minimum size tolerance.

Parameters
tolMinimum size tolerance.

◆ set_bbox_overlap_tolerance()

template<typename Real>
void Utils::AABBtree< Real >::set_bbox_overlap_tolerance ( Real tol)

Sets the bounding box overlap tolerance.

Parameters
tolOverlap tolerance.

◆ set_max_num_objects_per_node()

template<typename Real>
void Utils::AABBtree< Real >::set_max_num_objects_per_node ( integer n)

Sets the maximum number of objects per node.

Parameters
nMaximum number of objects.

The documentation for this class was generated from the following files: