|
| BVH () |
| Default constructor. More...
|
|
template<typename BoxIndexable > |
int | initialize (const BoxIndexable boxes, IndexType numItems) |
| Initializes a BVH instance, of specified dimension, over a given set of geometric entities, each represented by its corresponding axis-aligned bounding box. More...
|
|
bool | isInitialized () const |
|
void | setAllocatorID (int allocatorID) |
| Sets the ID of the allocator used by the BVH. 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 | getScaleFactor () const |
| Returns the scale factor used when constructing the BVH. More...
|
|
void | setTolerance (FloatType EPS) |
| Sets the tolerance used for querying the BVH. More...
|
|
FloatType | getTolerance () const |
| Returns the tolerance value used for BVH queries. More...
|
|
BoxType | getBounds () const |
| Returns the bounds of the BVH, given by the the root bounding box. More...
|
|
TraverserType | getTraverser () const |
| Returns a device-copyable object that can be used to traverse the BVH from inside a device kernel. More...
|
|
template<typename PointIndexable > |
void | findPoints (axom::ArrayView< IndexType > offsets, axom::ArrayView< IndexType > counts, axom::Array< IndexType > &candidates, IndexType numPts, PointIndexable points) const |
| Finds the candidate bins that contain each of the query points. More...
|
|
template<typename RayIndexable > |
void | findRays (axom::ArrayView< IndexType > offsets, axom::ArrayView< IndexType > counts, axom::Array< IndexType > &candidates, IndexType numRays, RayIndexable rays) const |
| Finds the candidate bins that intersect the given rays. More...
|
|
template<typename BoxIndexable > |
void | findBoundingBoxes (axom::ArrayView< IndexType > offsets, axom::ArrayView< IndexType > counts, axom::Array< IndexType > &candidates, IndexType numBoxes, BoxIndexable boxes) 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...
|
|
template<int NDIMS, typename ExecSpace = axom::SEQ_EXEC, typename FloatType = double, BVHType BVHImpl = BVHType::LinearBVH>
class axom::spin::BVH< NDIMS, ExecSpace, FloatType, BVHImpl >
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.
- Template Parameters
-
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. |
- Note
- The last template parameter is optional. Defaults to double precision if not specified.
- Precondition
- The spin::BVH class requires RAJA and Umpire with CUDA_EXEC.
- Note
- The Execution Space, supplied as the 2nd template argument, specifies
- Where and how the BVH is generated and stored
- Where and how subsequent queries are performed
- The default memory space, bound to the corresponding execution space
- See also
- axom::execution_space for more details.
A simple example illustrating how to use the BVH class is given below:
constexpr int DIMENSION = 3;
const primal::BoundingBox<float, DIMENSION>* aabbs = ...
spin::BVH< DIMENSION, axom::OMP_EXEC > bvh;
bvh.initialize( aabbs, numItems );
const double* qx = ...
const double* qy = ...
const double* qz = ...
ZipPoint qpts {{qx,qy,qz}};
bvh.findPoints( offsets, counts, candidates, numPoints, qpts );
...
axom::deallocate( candidates );
std::int32_t IndexType
Definition: Types.hpp:66
#define SLIC_ASSERT(EXP)
Asserts that a given expression is true. If the expression is not true an error will be logged and th...
Definition: slic_macros.hpp:336
template<int NDIMS, typename ExecSpace , typename FloatType , BVHType Impl>
template<typename BoxIndexable >
Initializes a BVH instance, of specified dimension, over a given set of geometric entities, each represented by its corresponding axis-aligned bounding box.
- Parameters
-
[in] | boxes | buffer consisting of bounding boxes for each entity. |
[in] | numItems | the total number of items to store in the BVH. |
- Returns
- status set to BVH_BUILD_OK on success.
- Note
- If an allocatorID has not been set in a call to setAllocatorID(), the code will use the default allocator ID for the execution space specified via axom::execution_space<ExecSpace>::allocatorID() when the BVH object is instantiated.
- Warning
- The supplied boxes array must point to a buffer in a memory space that is compatible with the execution space. For example, when using CUDA_EXEC, boxes must be in unified memory or GPU memory. The code currently does not check for that.
- Precondition
- boxes != nullptr
-
numItems > 0
References AXOM_LAMBDA, AXOM_PERF_MARK_FUNCTION, axom::spin::BVH_BUILD_OK, axom::deallocate(), and SLIC_ASSERT.