29 #ifndef StaticAABBTree_hpp
30 #define StaticAABBTree_hpp
110 static AABB new_lonely_aabb(
double minPoint[3],
double maxPoint[3],
unsigned int primtiveIndex = -1);
120 void build(
const std::vector<AABB> &leavesAABBs);
190 void closest_point(
const double *aPoint,
double &distance,
unsigned int aNode = 0)
const;
241 unsigned int build(std::vector<unsigned int> aabbsIndices,
unsigned int depth = 0);
279 unsigned int new_aabb(
double minPoint[3],
double maxPoint[3],
unsigned int primitiveIndex = -1);
369 static const unsigned int NotInList = (
unsigned int)(-1);
399 mutable std::function<void(
unsigned int primitiveIndex,
const double *aPoint,
double &distance)>
closestPointCallback_;
416 mutable std::function<void(
unsigned int primitiveIndex,
const double *aPoint,
const double *anAxis,
double &distance)>
furthestVertexCallback_;
Definition: StaticAABBTree.hpp:79
const AABB aabb_at_index(unsigned int aabbIndex) const
Definition: StaticAABBTree.hpp:146
const unsigned int node_number() const
Definition: StaticAABBTree.hpp:125
void build(const std::vector< AABB > &leavesAABBs)
Builds the AABB tree from a list of AABBs.
Definition: StaticAABBTree.cpp:75
std::vector< AABB > _aabbs
The AABBs container.
Definition: StaticAABBTree.hpp:385
void xraycast_aabb_tree(Ray aRay, unsigned int aNode=0) const
Raycasts the AABB tree using an x-oriented axis.
Definition: StaticAABBTree.cpp:166
std::function< bool(unsigned int primitiveIndex, Ray aRay)> raycastAABBTreeCallback_
The callback used to check if a primitive with index primitiveIndex is hit by the ray aRay.
Definition: StaticAABBTree.hpp:407
const AABBNode node_at_index(unsigned int nodeIndex) const
Definition: StaticAABBTree.hpp:132
double squared_distance_to_aabb(const double *aPoint, unsigned int anAABB) const
Computes the quared distance between a point and the AABB.
Definition: StaticAABBTree.cpp:466
void set_raycast_aabb_tree_callback(std::function< bool(unsigned int, Ray)> callback) const
Allows to define the callback method that will be used to check if a primitive is intersected by a ra...
Definition: StaticAABBTree.hpp:218
std::vector< AABBNode > _nodes
The AABB nodes container.
Definition: StaticAABBTree.hpp:390
void furthest_vertex_on_aabb_along_axis(const double *anAxis, unsigned int anAABB, double(&furthestPoint)[3]) const
Finds the furthest point on an AABB along a given axis.
Definition: StaticAABBTree.cpp:500
double inner_squared_distance_to_aabb(const double *aPoint, unsigned int anAABB) const
Computes the inner squared distance between a point and the AABB.
Definition: StaticAABBTree.cpp:483
std::function< void(unsigned int primitiveIndex, const double *aPoint, double &distance)> closestPointCallback_
The callback used to check if a primitive with index primitiveIndex contains a vertex closer to aPoin...
Definition: StaticAABBTree.hpp:399
unsigned int new_aabb_from_aabb(const std::vector< unsigned int > &aabbs)
Creates a new AABB that encloses all the AABBs contained in aabbs.
Definition: StaticAABBTree.cpp:387
bool is_aabb_hit_by_xray(unsigned int anAABB, Ray aRay) const
Checks wether an AABB is hit by an x-oriented ray.
Definition: StaticAABBTree.cpp:519
double squared_distance_to_aabb_centre(const double *aPoint, unsigned int anAABB) const
Computes the squared distance between a point and the AABB centre.
Definition: StaticAABBTree.cpp:454
const unsigned int aabb_number() const
Definition: StaticAABBTree.hpp:139
bool AABBFacetIsHitByRay(unsigned int anAABB, double facetNormal[3], Ray aRay) const
Checks wether a facet of an AABB is hit by an arbitrarily oriented ray.
Definition: StaticAABBTree.cpp:548
void set_closest_point_callback(std::function< void(unsigned int, const double *, double &)> callback) const
Allows to define the callback method that will be used to check if a primitive contains a vertex clos...
Definition: StaticAABBTree.hpp:208
void raycast_aabb_tree(Ray aRay, unsigned int aNode=0) const
Raycasts the AABB tree using an arbitrarily oriented axis.
Definition: StaticAABBTree.cpp:196
StaticAABBTree()
instanciates a new empty StaticAABBTree object.
Definition: StaticAABBTree.cpp:40
unsigned int new_aabb_node()
Creates a new AABBNode.
Definition: StaticAABBTree.cpp:338
const bool is_node_leaf(unsigned int nodeIndex) const
Definition: StaticAABBTree.hpp:153
bool is_aabb_hit_by_ray(unsigned int anAABB, Ray aRay) const
Checks wether an AABB is hit by an arbitrarily oriented ray.
Definition: StaticAABBTree.cpp:528
unsigned int new_aabb(double minPoint[3], double maxPoint[3], unsigned int primitiveIndex=-1)
Creates a new AABB with given extreme points and, optionally, the primitive index.
Definition: StaticAABBTree.cpp:377
unsigned int _node_count
The current number of AABB nodes in the tree.
Definition: StaticAABBTree.hpp:380
std::function< void(unsigned int primitiveIndex, const double *aPoint, const double *anAxis, double &distance)> furthestVertexCallback_
The callback used to check if a vertex of a primitive with index primitiveIndex is further than the o...
Definition: StaticAABBTree.hpp:416
unsigned int _aabbsCount
The current number of AABBs in the tree.
Definition: StaticAABBTree.hpp:375
bool is_point_inside_aabb(const double *aPoint, unsigned int anAABB) const
Checks whether a point is inside an AABB.
Definition: StaticAABBTree.cpp:437
void clear()
Clears the AABB tree data structure.
Definition: StaticAABBTree.cpp:64
static const unsigned int NotInList
A flag to determine if an index is in a list.
Definition: StaticAABBTree.hpp:369
~StaticAABBTree()
Default destructor.
Definition: StaticAABBTree.cpp:57
static AABB new_lonely_aabb(double minPoint[3], double maxPoint[3], unsigned int primtiveIndex=-1)
Creates a new 'lonely' AABB with given extreme points.
Definition: StaticAABBTree.cpp:415
void set_furthest_vertex_callback(std::function< void(unsigned int, const double *, const double *, double &)> callback) const
Allows to define the callback that will be used to check if a primitive contains a vertex further to ...
Definition: StaticAABBTree.hpp:229
void closest_point(const double *aPoint, double &distance, unsigned int aNode=0) const
Finds the closest point to the query.
Definition: StaticAABBTree.cpp:226
void furthest_vertex_along_axis(const double *aPoint, const double *anAxis, double &distance, unsigned int aNode=0) const
Finds the furthest vertex in a given direction.
Definition: StaticAABBTree.cpp:283
Definition: StaticAABBTree.hpp:38
double surface
Definition: StaticAABBTree.hpp:47
unsigned int nextFree
Definition: StaticAABBTree.hpp:45
unsigned int primitive
Definition: StaticAABBTree.hpp:43
double volume
Definition: StaticAABBTree.hpp:46
double minPoint[3]
Definition: StaticAABBTree.hpp:40
unsigned int aabbNode
Definition: StaticAABBTree.hpp:44
double midPoint[3]
Definition: StaticAABBTree.hpp:41
double maxPoint[3]
Definition: StaticAABBTree.hpp:42
bool isActive
Definition: StaticAABBTree.hpp:48
Definition: StaticAABBTree.hpp:54
unsigned int parentNode
Definition: StaticAABBTree.hpp:60
int height
Definition: StaticAABBTree.hpp:58
bool isActive
Definition: StaticAABBTree.hpp:64
double location[3]
Definition: StaticAABBTree.hpp:56
unsigned int nextFree
Definition: StaticAABBTree.hpp:63
unsigned int leftNode
Definition: StaticAABBTree.hpp:61
unsigned int aabb
Definition: StaticAABBTree.hpp:57
bool isCrossed
Definition: StaticAABBTree.hpp:65
unsigned int rightNode
Definition: StaticAABBTree.hpp:62
unsigned int depth
Definition: StaticAABBTree.hpp:59
Definition: StaticAABBTree.hpp:71
double direction[3]
Definition: StaticAABBTree.hpp:74
double origin[3]
Definition: StaticAABBTree.hpp:73