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.3.3/src/axom/spin/BVH.hpp>
Public Member Functions | |
AXOM_STATIC_ASSERT_MSG (((NDIMS==2)||(NDIMS==3)), "The BVH class may be used only in 2D or 3D.") | |
AXOM_STATIC_ASSERT_MSG (std::is_floating_point< FloatType >::value, "A valid FloatingType must be used for the BVH.") | |
AXOM_STATIC_ASSERT_MSG (axom::execution_space< ExecSpace >::valid(), "A valid execution space must be supplied to the BVH.") | |
BVH ()=delete | |
Default constructor. Disabled. More... | |
BVH (const FloatType *boxes, IndexType numItems) | |
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... | |
void | setScaleFactor (FloatType scale_factor) |
Sets the scale factor for scaling the supplied bounding boxes. 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 | writeVtkFile (const std::string &fileName) const |
Writes the BVH to the specified VTK file for visualization. More... | |
void | find (IndexType *offsets, IndexType *counts, IndexType *&candidates, IndexType numPts, const FloatType *x, const FloatType *y) const |
Finds the candidate geometric entities that contain each of the given query points. More... | |
void | find (IndexType *offsets, IndexType *counts, IndexType *&candidates, IndexType numPts, const FloatType *x, const FloatType *y, const FloatType *z) const |
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 | ||
) |
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. |
axom::spin::BVH< NDIMS, ExecSpace, FloatType >::~BVH | ( | ) |
Destructor.
axom::spin::BVH< NDIMS, ExecSpace, FloatType >::AXOM_STATIC_ASSERT_MSG | ( | ((NDIMS==2)||(NDIMS==3)) | , |
"The BVH< NDIMS, ExecSpace, FloatType > class may be used only in 2D or 3D." | |||
) |
Referenced by axom::spin::BVH< NDIMS, ExecSpace, FloatType >::find().
axom::spin::BVH< NDIMS, ExecSpace, FloatType >::AXOM_STATIC_ASSERT_MSG | ( | std::is_floating_point< FloatType >::value | , |
"A valid FloatingType must be used for the BVH< NDIMS, ExecSpace, FloatType >." | |||
) |
axom::spin::BVH< NDIMS, ExecSpace, FloatType >::AXOM_STATIC_ASSERT_MSG | ( | axom::execution_space< ExecSpace > | ::valid(), |
"A valid execution space must be supplied to the BVH< NDIMS, ExecSpace, FloatType >." | |||
) |
|
inline |
Sets the scale factor for scaling the supplied bounding boxes.
[in] | scale_factor | the scale factor |
References AXOM_HOST_DEVICE, axom::spin::BVH< NDIMS, ExecSpace, FloatType >::build(), axom::spin::BVH< NDIMS, ExecSpace, FloatType >::find(), axom::spin::BVH< NDIMS, ExecSpace, FloatType >::getBounds(), axom::utilities::max(), axom::utilities::min(), and axom::spin::BVH< NDIMS, ExecSpace, FloatType >::writeVtkFile().
int axom::spin::BVH< NDIMS, ExecSpace, FloatType >::build | ( | ) |
Generates the BVH.
References AXOM_LAMBDA, axom::spin::BVH_BUILD_OK, axom::deallocate(), and SLIC_ASSERT.
Referenced by axom::spin::BVH< NDIMS, ExecSpace, FloatType >::setScaleFactor().
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. |
References SLIC_ASSERT.
Referenced by axom::spin::BVH< NDIMS, ExecSpace, FloatType >::setScaleFactor().
void axom::spin::BVH< NDIMS, ExecSpace, FloatType >::find | ( | IndexType * | offsets, |
IndexType * | counts, | ||
IndexType *& | candidates, | ||
IndexType | numPts, | ||
const FloatType * | x, | ||
const FloatType * | y | ||
) | const |
Finds the candidate geometric entities that contain each of the given 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 |
References AXOM_LAMBDA, axom::spin::BVH< NDIMS, ExecSpace, FloatType >::AXOM_STATIC_ASSERT_MSG(), and SLIC_ASSERT.
Referenced by axom::spin::BVH< NDIMS, ExecSpace, FloatType >::setScaleFactor().
void axom::spin::BVH< NDIMS, ExecSpace, FloatType >::find | ( | IndexType * | offsets, |
IndexType * | counts, | ||
IndexType *& | candidates, | ||
IndexType | numPts, | ||
const FloatType * | x, | ||
const FloatType * | y, | ||
const FloatType * | z | ||
) | const |
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. |
Referenced by axom::spin::BVH< NDIMS, ExecSpace, FloatType >::setScaleFactor().