27#ifndef UTILS_AABB_TREE_dot_HH
28#define UTILS_AABB_TREE_dot_HH
62 template <
typename Real>
86 Real * m_bbox_tree{
nullptr};
87 Real * m_bbox_objs{
nullptr};
89 mutable vector<integer> m_stack;
94 integer m_max_num_objects_per_node{16};
95 Real m_bbox_long_edge_ratio{Real(0.8)};
96 Real m_bbox_overlap_tolerance{Real(0.1)};
97 Real m_bbox_min_size_tolerance{Real(0)};
100 mutable integer m_num_check = 0;
102 using OVERLAP_FUN = bool (*) ( Real
const bbox1[], Real
const bbox2[],
integer dim );
104 OVERLAP_FUN m_check_overlap{
nullptr};
105 OVERLAP_FUN m_check_overlap_with_point{
nullptr};
107 static bool overlap1( Real
const bbox1[], Real
const bbox2[],
integer dim );
108 static bool overlap2( Real
const bbox1[], Real
const bbox2[],
integer dim );
109 static bool overlap3( Real
const bbox1[], Real
const bbox2[],
integer dim );
110 static bool overlap4( Real
const bbox1[], Real
const bbox2[],
integer dim );
111 static bool overlap5( Real
const bbox1[], Real
const bbox2[],
integer dim );
112 static bool overlap6( Real
const bbox1[], Real
const bbox2[],
integer dim );
113 static bool overlap7( Real
const bbox1[], Real
const bbox2[],
integer dim );
114 static bool overlap8( Real
const bbox1[], Real
const bbox2[],
integer dim );
116 static bool pnt_overlap1( Real
const pnt[], Real
const bbox2[],
integer dim );
117 static bool pnt_overlap2( Real
const pnt[], Real
const bbox2[],
integer dim );
118 static bool pnt_overlap3( Real
const pnt[], Real
const bbox2[],
integer dim );
119 static bool pnt_overlap4( Real
const pnt[], Real
const bbox2[],
integer dim );
120 static bool pnt_overlap5( Real
const pnt[], Real
const bbox2[],
integer dim );
121 static bool pnt_overlap6( Real
const pnt[], Real
const bbox2[],
integer dim );
122 static bool pnt_overlap7( Real
const pnt[], Real
const bbox2[],
integer dim );
123 static bool pnt_overlap8( Real
const pnt[], Real
const bbox2[],
integer dim );
125 static bool check_overlap( Real
const bb1[], Real
const bb2[],
integer dim );
126 static bool check_overlap_with_point( Real
const bb1[], Real
const pnt[],
integer dim );
128 Real max_bbox_distance( Real
const bbox[], Real
const pnt[] )
const;
188 Real
const bb_min[],
integer ldim0,
189 Real
const bb_max[],
integer ldim1
201 Real
const bbox_min[],
202 Real
const bbox_max[],
223 Real
const bb_min[],
integer ldim0,
224 Real
const bb_max[],
integer ldim1,
299 void pnt_bbox_minmax( Real
const pnt[], Real
const bbox[], Real & dmin, Real & dmax )
const;
381 #ifndef UTILS_OS_WINDOWS
382 extern template class AABBtree<float>;
383 extern template class AABBtree<double>;
A class representing an axis-aligned bounding box tree.
Definition Utils_AABB_tree.hh:63
void get_root_bbox(Real bb_min[], Real bb_max[]) const
Gets the bounding box of the root node.
Definition Utils_AABB_tree.cc:1160
integer num_check() const
Returns the number of overlap checks performed.
Definition Utils_AABB_tree.hh:327
void build()
Builds the AABB tree.
Definition Utils_AABB_tree.cc:509
void set_bbox_min_size_tolerance(Real tol)
Sets the bounding box minimum size tolerance.
Definition Utils_AABB_tree.cc:358
void replace_bbox(Real const bbox_min[], Real const bbox_max[], integer ipos)
Replaces a bounding box at a specific position.
Definition Utils_AABB_tree.cc:483
void min_distance_candidates(Real const pnt[], AABB_SET &bb_index) const
Finds candidates for minimum distance to a point.
Definition Utils_AABB_tree.cc:1069
int integer
Integer type.
Definition Utils_AABB_tree.hh:66
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.
Definition Utils_AABB_tree.hh:222
void set_max_num_objects_per_node(integer n)
Sets the maximum number of objects per node.
Definition Utils_AABB_tree.cc:316
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.
Definition Utils_AABB_tree.cc:1169
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.
Definition Utils_AABB_tree.cc:1041
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.
Definition Utils_AABB_tree.cc:772
void set_bbox_long_edge_ratio(Real ratio)
Sets the bounding box long edge ratio.
Definition Utils_AABB_tree.cc:330
void set_bbox_overlap_tolerance(Real tol)
Sets the bounding box overlap tolerance.
Definition Utils_AABB_tree.cc:344
integer num_tree_nodes() const
Returns the number of tree nodes.
Definition Utils_AABB_tree.hh:320
void intersect(AABBtree< Real > const &aabb, AABB_MAP &bb_index) const
Intersects the tree with another AABB tree.
Definition Utils_AABB_tree.cc:908
integer num_objects() const
Returns the number of objects (bounding boxes).
Definition Utils_AABB_tree.hh:313
integer dim() const
Returns the spatial dimension of the bounding boxes.
Definition Utils_AABB_tree.hh:306
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.
Definition Utils_AABB_tree.cc:860
void add_bboxes(Real const bb_min[], integer ldim0, Real const bb_max[], integer ldim1)
Adds bounding boxes to the tree.
Definition Utils_AABB_tree.cc:454
void intersect_with_one_bbox(Real const bbox[], AABB_SET &bb_index) const
Intersects the tree with a bounding box.
Definition Utils_AABB_tree.cc:820
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.
Definition Utils_AABB_tree.cc:1131
void intersect_and_refine(AABBtree< Real > const &aabb, AABB_MAP &bb_index) const
Intersects the tree with another AABB tree and refines the search.
Definition Utils_AABB_tree.cc:970
map< integer, AABB_SET > AABB_MAP
Map for bounding box indices and their overlaps.
Definition Utils_AABB_tree.hh:68
AABBtree()=default
Default constructor.
void intersect_with_one_point(Real const pnt[], AABB_SET &bb_index) const
Intersects the tree with a point.
Definition Utils_AABB_tree.cc:731
set< integer > AABB_SET
Set of integers representing bounding box indices.
Definition Utils_AABB_tree.hh:67
void allocate(integer nbox, integer dim)
Allocates memory for the AABB tree.
Definition Utils_AABB_tree.cc:372
string info() const
Returns information about the AABB tree.
Definition Utils_AABB_tree.cc:292
Class for dynamic memory allocation of objects.
Definition Malloc.hxx:79
Definition SystemUtils.cc:39