![]() |
AABBtree
0.0.0
A C++ non-recursive ND AABB tree
|
A class representing a non-recursive axis-aligned bounding box tree (AABB tree). More...
#include <Tree.hxx>
Classes | |
struct | Node |
struct | Statistics |
Public Member Functions | |
~Tree ()=default | |
Tree ()=default | |
BoxUniquePtrList const & | boxes () const |
BoxUniquePtr const & | box (Integer const i) const |
void | max_nodal_objects (Integer const n) |
Integer | max_nodal_objects () const |
void | separation_ratio_tolerance (Real const ratio) |
Real | separation_ratio_tolerance () const |
std::vector< Node > const & | structure () const |
Node const & | node (Integer const i) const |
Integer | size () const |
void | enable_dumping_mode () |
void | disable_dumping_mode () |
void | dumping_mode (bool const mode) |
bool | is_empty () const |
void | clear () |
void | build (std::unique_ptr< BoxUniquePtrList > boxes_ptr) |
template<typename Object> | |
bool | intersect (Object const &obj, IndexSet &candidates) const |
bool | intersect (Tree const &tree, IndexMap &candidates) const |
bool | self_intersect (IndexSet &candidates) const |
template<typename Object> | |
Real | distance (Object const &obj, IndexSet &candidates) const |
Real | distance (Tree const &tree, IndexMap &candidates) const |
template<typename Object, typename Function = std::function<Real(Object const &, Box const &)>> | |
Real | closest (Object const &obj, Integer const n, IndexSet &candidates, Function distance_function=[](Object const &o, Box const &b) {return b.interior_distance(o);}) const |
template<typename Object, typename Function = std::function<Real(Object const &, Box const &)>> | |
bool | within_distance (Object const &obj, Real const max_distance, IndexSet &candidates, Function distance_function=[](Object const &o, Box const &b) {return b.interior_distance(o);}) const |
void | depth (Integer const i, Integer &d) const |
void | nodes (Integer const i, Integer &l, Integer &n, Integer &b) const |
void | stats (Statistics &stats) const |
void | print (OutStream &os) const |
Static Public Attributes | |
static constexpr Real | EPS {std::numeric_limits<Real>::epsilon()} |
static constexpr Real | INF {std::numeric_limits<Real>::infinity()} |
static constexpr Real | DUMMY_TOL {EPS*static_cast<Real>(100.0)} |
Private Types | |
using | Box = AABBtree::Box<Real, N> |
using | BoxUniquePtr = AABBtree::BoxUniquePtr<Real, N> |
using | BoxUniquePtrList = AABBtree::BoxUniquePtrList<Real, N> |
using | Vector = AABBtree::Vector<Real, N> |
using | Point = AABBtree::Point<Real, N> |
using | QueueItem = std::tuple<Integer, Integer, Real> |
using | PriorityQueue = std::priority_queue<QueueItem, std::vector<QueueItem>, std::function<bool(QueueItem, QueueItem)>> |
Private Attributes | |
std::unique_ptr< BoxUniquePtrList > | m_boxes_ptr {nullptr} |
std::vector< Node > | m_tree_structure |
IndexList | m_tree_boxes_map |
bool | m_dumping_mode {true} |
Integer | m_max_nodal_objects {10} |
Real | m_separation_ratio_tolerance {0.25} |
Real | m_balance_ratio_tolerance {0.3} |
Integer | m_check_counter {0} |
Integer | m_dump_counter {0} |
IndexList | m_stack |
PriorityQueue | m_queue |
The Tree class provides an efficient way to store and query a set of axis-aligned bounding boxes non-recursively. It supports various operations such as building the tree, adding axis-aligned boxes, and performing intersection queries. The Tree class is templated on the type of the real numbers and the dimensions of the bounding boxes and is based, as the name suggests, on a novel non-recursive algorithm.
Real | Type of the scalar coefficients |
N | Dimension of the ambient space. |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
default |
Class destructor for the non-recursive axis-aligned bounding box tree.
|
default |
Class constructor for the non-recursive axis-aligned bounding box tree.
|
inline |
Get a look at the i-th unique pointer to the bounding box.
[in] | i | Index of the unique pointer to the bounding box. |
|
inline |
Get a look at the vector of unique pointers to the bounding boxes.
|
inline |
Build the tree given the bounding boxes.
[in] | boxes_ptr | Bounding boxes to build the tree from. |
|
inline |
Clear the tree.
|
inline |
Find the first \( n \) candidates from an object, using a custom distance function.
[in] | obj | Object to compute the distance to. |
[in] | n | Number of candidates to find. |
[out] | candidates | First \( n \) candidates. |
[in] | distance_function | Custom distance function (default is the interior distance). |
Object | Type of the object to compute the distance to. |
Function | Type of the custom distance function. |
|
inline |
Compute the depth of the tree from a given node.
[in] | i | Index of the node to compute the depth from. |
[out] | d | Depth of the tree from the given node. |
|
inline |
Disable dumping mode while building the tree.
|
inline |
Compute the minimum distance between an object and the tree.
[in] | obj | Object to compute the distance to. |
[out] | candidates | Minimum distance candidates. |
Object | Type of the object to compute the distance to. |
interior_distance
that computes the distance to a box.
|
inline |
Compute the minimum distance between the current tree and another tree.
[in] | tree | Tree to compute the distance to. |
[out] | candidates | Minimum distance candidates. |
|
inline |
Set dumping mode while building the tree.
[in] | mode | Dumping mode. |
|
inline |
Enable dumping mode while building the tree.
|
inline |
Intersect the tree with an object.
[in] | obj | Object to intersect with. |
[out] | candidates | Intersection result (boxes indexes). |
Object | Type of the object to intersect with. |
intersects
that computes the intersection with a box.
|
inline |
Intersect the tree with another tree.
[in] | tree | Tree to intersect with. |
[out] | candidates | Intersection result (boxes indexes). |
|
inline |
Check if tree is empty.
|
inline |
Get the maximum number of objects per node.
|
inline |
Set the maximum number of objects per node.
[in] | n | Maximum number of objects per node. |
|
inline |
Get the i-th tree node.
[in] | i | Index of the node. |
|
inline |
Compute the number of leafs, nodes, and long boxes of the tree from a given node.
[in] | i | Index of the node to start the computation from. |
[out] | l | Number of leafs of the tree from the given node. |
[out] | n | Number of nodes of the tree from the given node. |
[out] | b | Number of long boxes of the tree from the given node. |
|
inline |
Print the tree info to an output stream.
[in] | os | Output stream to print the tree info to. |
|
inline |
Self-intersect the tree (i.e., intersect the tree with itself to find all the intersecting boxes).
[out] | candidates | Intersection result (boxes indexes). |
|
inline |
Get the balance ratio tolerance for bounding boxes.
|
inline |
Set the balance ratio tolerance for bounding boxes.
[in] | ratio | Balance ratio tolerance for bounding boxes. |
|
inline |
Get the number of nodes in the tree.
|
inline |
Compute some statistics about the current tree.
[out] | stats | Statistics about the tree. |
|
inline |
Get the tree structure.
|
inline |
Find the candidates that are within a given distance from a object, using a custom distance function.
[in] | obj | Object to compute the distance to. |
[in] | max_distance | Maximum distance to consider. |
[out] | candidates | Minimum distance candidates. |
[in] | distance_function | Custom distance function (default is the interior distance). |
Object | Type of the object to compute the distance to. |
Function | Type of the custom distance function. |
|
staticconstexpr |
Default tolerance for the scalar type
|
staticconstexpr |
Machine epsilon for the scalar type.
|
staticconstexpr |
Infinity value for the scalar type.
|
private |
Tolerance for bounding boxes balance.
|
private |
Vector of unique pointers to the bounding boxes.
|
mutableprivate |
Number of collision check.
|
mutableprivate |
Number of dumpings.
|
private |
Enable dumping while building the tree.
|
private |
Maximum number of objects per node.
|
mutableprivate |
Queue for tree traversal.
|
private |
Tolerance for bounding boxes separation.
|
mutableprivate |
Tree stack.
|
private |
Reordering between the vector of boxes and the tree internal structure.
|
private |
Tree structure.