AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
Defines a Bounding Volume Hierarchy (BVH) spatial acceleration data structure over a set of geometric entities. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.5.0/src/axom/spin/BVH.hpp>
Public Member Functions | |
BVH ()=delete | |
Default constructor. Disabled. More... | |
BVH (const FloatType *boxes, IndexType numItems, int allocatorID=axom::execution_space< ExecSpace >::allocatorID()) | |
Creates a BVH instance, of specified dimension, over a given set of geometric entities, each represented by its corresponding axis-aligned bounding box. More... | |
~BVH () | |
Destructor. More... | |
int | getAllocatorID () const |
Get the ID of the allocator used by the BVH. More... | |
void | setScaleFactor (FloatType scale_factor) |
Sets the scale factor for scaling the supplied bounding boxes. More... | |
FloatType | getScaleFacor () const |
Returns the scale factor used when constructing the BVH. More... | |
void | setTolerance (FloatType TOL) |
Sets the tolerance used for querying the BVH. More... | |
FloatType | getTolerance () const |
Returns the tolerance value used for BVH queries. More... | |
int | build () |
Generates the BVH. More... | |
void | getBounds (FloatType *min, FloatType *max) const |
Returns the bounds of the BVH, given by the the root bounding box. More... | |
void | findPoints (IndexType *offsets, IndexType *counts, IndexType *&candidates, IndexType numPts, const FloatType *x, const FloatType *y, const FloatType *z=nullptr) const |
Finds the candidate bins that contain each of the query points. More... | |
void | findRays (IndexType *offsets, IndexType *counts, IndexType *&candidates, IndexType numRays, const FloatType *x0, const FloatType *nx, const FloatType *y0, const FloatType *ny, const FloatType *z0=nullptr, const FloatType *nz=nullptr) const |
Finds the candidate bins that intersect the given rays. More... | |
void | findBoundingBoxes (IndexType *offsets, IndexType *counts, IndexType *&candidates, IndexType numBoxes, const FloatType *xmin, const FloatType *xmax, const FloatType *ymin, const FloatType *ymax, const FloatType *zmin=nullptr, const FloatType *zmax=nullptr) const |
Finds the candidate bins that intersect the given bounding boxes. More... | |
void | writeVtkFile (const std::string &fileName) const |
Writes the BVH to the specified VTK file for visualization. More... | |
Defines a Bounding Volume Hierarchy (BVH) spatial acceleration data structure over a set of geometric entities.
The BVH class provides functionality for generating a hierarchical spatial partitioning over a set of geometric entities. Each entity in the BVH is represented by a bounding volume, in this case an axis-aligned bounding box. Once the BVH structure is generated, it is used to accelerate various spatial queries, such as, collision detection, ray tracing, etc., by reducing the search space for a given operation to an abbreviated list of candidate geometric entities to check for a particular query.
NDIMS | the number of dimensions, e.g., 2 or 3. |
ExecSpace | the execution space to use, e.g. SEQ_EXEC, CUDA_EXEC, etc. |
FloatType | floating precision, e.g., double or float . Optional. |
A simple example illustrating how to use the BVH class is given below:
|
delete |
Default constructor. Disabled.
axom::spin::BVH< NDIMS, ExecSpace, FloatType >::BVH | ( | const FloatType * | boxes, |
IndexType | numItems, | ||
int | allocatorID = axom::execution_space< ExecSpace >::allocatorID() |
||
) |
Creates a BVH instance, of specified dimension, over a given set of geometric entities, each represented by its corresponding axis-aligned bounding box.
[in] | boxes | buffer consisting of bounding boxes for each entity. |
[in] | numItems | the total number of items to store in the BVH. |
[in] | allocatorID | Umpire allocator ID to use (optional) |
axom::spin::BVH< NDIMS, ExecSpace, FloatType >::~BVH | ( | ) |
Destructor.
|
inline |
|
inline |
Sets the scale factor for scaling the supplied bounding boxes.
[in] | scale_factor | the scale factor |
|
inline |
Returns the scale factor used when constructing the BVH.
|
inline |
Sets the tolerance used for querying the BVH.
[in] | TOL | the tolerance to use. |
|
inline |
Returns the tolerance value used for BVH queries.
References DISABLE_COPY_AND_ASSIGNMENT, DISABLE_MOVE_AND_ASSIGNMENT, axom::utilities::max(), and axom::utilities::min().
int axom::spin::BVH< NDIMS, ExecSpace, FloatType >::build | ( | ) |
Generates the BVH.
Referenced by axom::quest::getMeshTriangle().
void axom::spin::BVH< NDIMS, ExecSpace, FloatType >::getBounds | ( | FloatType * | min, |
FloatType * | max | ||
) | const |
Returns the bounds of the BVH, given by the the root bounding box.
[out] | min | buffer to store the lower corner of the root bounding box. |
[out] | max | buffer to store the upper corner of the root bounding box. |
void axom::spin::BVH< NDIMS, ExecSpace, FloatType >::findPoints | ( | IndexType * | offsets, |
IndexType * | counts, | ||
IndexType *& | candidates, | ||
IndexType | numPts, | ||
const FloatType * | x, | ||
const FloatType * | y, | ||
const FloatType * | z = nullptr |
||
) | const |
Finds the candidate bins that contain each of the query points.
[out] | offsets | offset to the candidates array for each query point |
[out] | counts | stores the number of candidates per query point |
[out] | candidates | array of the candidate IDs for each query point |
[in] | numPts | the total number of query points supplied |
[in] | x | array of x-coordinates |
[in] | y | array of y-coordinates |
[in] | z | array of z-coordinates, may be nullptr if 2D |
void axom::spin::BVH< NDIMS, ExecSpace, FloatType >::findRays | ( | IndexType * | offsets, |
IndexType * | counts, | ||
IndexType *& | candidates, | ||
IndexType | numRays, | ||
const FloatType * | x0, | ||
const FloatType * | nx, | ||
const FloatType * | y0, | ||
const FloatType * | ny, | ||
const FloatType * | z0 = nullptr , |
||
const FloatType * | nz = nullptr |
||
) | const |
Finds the candidate bins that intersect the given rays.
[out] | offsets | offset to the candidates array for each ray |
[out] | counts | stores the number of candidates for each ray |
[out] | candidates | array of candidate IDs for each ray |
[in] | numRays | the total number of rays |
[in] | x0 | array consisting the ray source point x-coordinates. |
[in] | nx | array consisting the ray normal x-components. |
[in] | y0 | array consisting the ray source point y-coordinates |
[in] | ny | array consisting the ray normal y-components |
[in] | z0 | array consisting the ray source point z-coorindates (in 3D) |
[in] | nz | array consisting the ray normal z-components (in 3D) |
void axom::spin::BVH< NDIMS, ExecSpace, FloatType >::findBoundingBoxes | ( | IndexType * | offsets, |
IndexType * | counts, | ||
IndexType *& | candidates, | ||
IndexType | numBoxes, | ||
const FloatType * | xmin, | ||
const FloatType * | xmax, | ||
const FloatType * | ymin, | ||
const FloatType * | ymax, | ||
const FloatType * | zmin = nullptr , |
||
const FloatType * | zmax = nullptr |
||
) | const |
Finds the candidate bins that intersect the given bounding boxes.
[out] | offsets | offset to the candidates array for each bounding box |
[out] | counts | stores the number of candidates for each bounding box |
[out] | candidates | array of candidate IDs for each bounding box |
[in] | numBoxes | the total number of bounding boxes |
[in] | xmin | array of x-coordinates of lower bounding box corner |
[in] | xmax | array of x-coordinates of upper bounding box corner |
[in] | ymin | array of y-coordinates of lower bounding box corner |
[in] | ymax | array of y-coordinates of upper bounding box corner |
[in] | zmin | array of z-coordinates of lower bounding box corner, may be nullptr if 2D |
[in] | zmax | array of z-coordinates of upper bounding box corner, may be nullptr if 2D |
Referenced by axom::quest::getMeshTriangle().
void axom::spin::BVH< NDIMS, ExecSpace, FloatType >::writeVtkFile | ( | const std::string & | fileName | ) | const |
Writes the BVH to the specified VTK file for visualization.
[in] | fileName | the name of VTK file. |