AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
|
A spatial index defined by origin, spacing, and resolution. More...
#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/v0.9.1/src/axom/spin/UniformGrid.hpp>
Inherits policy::DynamicGridStorage< T >.
Classes | |
struct | QueryObject |
Public Types | |
enum | { INVALID_BIN_INDEX = -1 } |
A special value indicating any location not in the UniformGrid. More... | |
using | BoxType = primal::BoundingBox< double, NDIMS > |
The type used for specifying spatial extent of the contents. More... | |
using | PointType = primal::Point< double, NDIMS > |
The type used to query the index. More... | |
Public Member Functions | |
UniformGrid (const double *lower_bound, const double *upper_bound, const int *res, int allocatorID=axom::execution_space< ExecSpace >::allocatorID()) | |
Constructor specifying bounding box (min and max points) and number of bins. More... | |
UniformGrid (const BoxType &bbox, const int *res, int allocatorID=axom::execution_space< ExecSpace >::allocatorID()) | |
Constructor specifying bounding box and number of bins. More... | |
UniformGrid (const primal::NumericArray< int, NDIMS > &res, axom::ArrayView< const BoxType > bboxes, axom::ArrayView< const T > objs, int allocatorID=axom::execution_space< ExecSpace >::allocatorID()) | |
Constructor specifying objects to initialize the UniformGrid with. More... | |
void | initialize (axom::ArrayView< const BoxType > bboxes, axom::ArrayView< const T > objs) |
Reinitializes a UniformGrid with an array of objects and associated bounding boxes. More... | |
int | getBinIndex (const PointType &pt) const |
Returns the index of the bin containing the specified point. More... | |
bool | isBinEmpty (int index) const |
Returns whether the bin specified by index is empty. More... | |
const std::vector< int > | getBinsForBbox (const BoxType &BB) const |
Returns the indices of the bins for a given bounding box. More... | |
void | getCandidatesAsArray (axom::ArrayView< const BoxType > queryObjs, axom::ArrayView< IndexType > outOffsets, axom::ArrayView< IndexType > outCounts, axom::Array< IndexType > &outCandidates) const |
Returns a list of candidates in the vicinity of a set of query bounding boxes. More... | |
void | insert (const BoxType &BB, const T &obj) |
Inserts obj into each bin overlapped by BB. More... | |
QueryObject | getQueryObject () const |
A spatial index defined by origin, spacing, and resolution.
T | The type of object that this UniformGrid will hold |
NDIMS | The UniformGrid dimensionality: supported values are 2 or 3 |
ExecSpace | The execution space in which operations will take place |
The UniformGrid class is parameterized on the type of object it will contain and the dimensionality of the grid. Currently the UniformGrid will index 2D and 3D space.
The UniformGrid divides space into a number of bins, extending in a block from an origin point and arranged in row-major order. Each bin extends over an axis-aligned rectangle or parallelepiped. The size of a bin is specified by the spacing constructor argument, and the number of bins is specified by the res constructor argument.
To use this class, a user will instantiate a UniformGrid and insert a number of objects (each with its own bounding box). The insert operation puts the object into some of the bins. The user may retrieve the bin index of any point, then retrieve any objects associated with the bin at that index.
using axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::BoxType = primal::BoundingBox<double, NDIMS> |
The type used for specifying spatial extent of the contents.
using axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::PointType = primal::Point<double, NDIMS> |
The type used to query the index.
anonymous enum |
A special value indicating any location not in the UniformGrid.
Returned by getBinIndex() if that function is passed an exterior point. An error is thrown if getBinContents() is passed INVALID_BIN_INDEX. clear(INVALID_BIN_INDEX) is a no-op; isBinEmpty(INVALID_BIN_INDEX) returns true.
Enumerator | |
---|---|
INVALID_BIN_INDEX |
axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::UniformGrid | ( | const double * | lower_bound, |
const double * | upper_bound, | ||
const int * | res, | ||
int | allocatorID = axom::execution_space<ExecSpace>::allocatorID() |
||
) |
Constructor specifying bounding box (min and max points) and number of bins.
The lower and upper bounds are specified as double arrays. Each argument points to an array of at least length NDIMS. The nth element in each array specifies, for the nth dimension, the lower bound (inclusive), the upper bound (exclusive), and the number of bins. Thus, UniformGrid({0., 0.}, {2., 4.}, {2, 4}); defines an index extending from 0 up to 2 divided into two bins in the x-dimension and from 0 up to 4 divided into four bins in the y dimension.
axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::UniformGrid | ( | const BoxType & | bbox, |
const int * | res, | ||
int | allocatorID = axom::execution_space<ExecSpace>::allocatorID() |
||
) |
Constructor specifying bounding box and number of bins.
References SLIC_ASSERT.
axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::UniformGrid | ( | const primal::NumericArray< int, NDIMS > & | res, |
axom::ArrayView< const BoxType > | bboxes, | ||
axom::ArrayView< const T > | objs, | ||
int | allocatorID = axom::execution_space<ExecSpace>::allocatorID() |
||
) |
Constructor specifying objects to initialize the UniformGrid with.
References axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::initialize().
void axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::initialize | ( | axom::ArrayView< const BoxType > | bboxes, |
axom::ArrayView< const T > | objs | ||
) |
Reinitializes a UniformGrid with an array of objects and associated bounding boxes.
References AXOM_HOST_LAMBDA, AXOM_LAMBDA, axom::Array< T, DIM, SPACE >::fill(), axom::detail::getAllocatorID(), axom::primal::BoundingBox< T, NDIMS >::getMax(), axom::primal::BoundingBox< T, NDIMS >::getMin(), axom::utilities::max(), axom::ArrayView< T, DIM, SPACE >::size(), and SLIC_ASSERT.
int axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::getBinIndex | ( | const PointType & | pt | ) | const |
Returns the index of the bin containing the specified point.
If the specified point is outside the grid, the function returns a special value (INVALID_BIN_INDEX). Note that the upper boundaries of a UniformGrid are not in a bin. Thus, if a UniformGrid divides the region from (0., 0.) to (10., 10.) into 10 x 10 bins, the code getBinIndex(PointType::makePoint(10., 10.)) will return INVALID_BIN_INDEX,
[in] | pt | The point to query. |
bool axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::isBinEmpty | ( | int | index | ) | const |
Returns whether the bin specified by index is empty.
Returns true if index is invalid.
[in] | index | The index of the bin to test. |
const std::vector< int > axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::getBinsForBbox | ( | const BoxType & | BB | ) | const |
Returns the indices of the bins for a given bounding box.
This method returns the indices of the bins that intersect BB. Any part of BB that falls outside this UniformGrid is disregarded. If BB falls completely outside this UniformGrid, this method returns an empty list.
References axom::primal::BoundingBox< T, NDIMS >::getMax(), and axom::primal::BoundingBox< T, NDIMS >::getMin().
void axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::getCandidatesAsArray | ( | axom::ArrayView< const BoxType > | queryObjs, |
axom::ArrayView< IndexType > | outOffsets, | ||
axom::ArrayView< IndexType > | outCounts, | ||
axom::Array< IndexType > & | outCandidates | ||
) | const |
Returns a list of candidates in the vicinity of a set of query bounding boxes.
[in] | queryObjs | The array of query objects |
[out] | outOffsets | Offsets into the candidates array for each query object |
[out] | outCounts | The number of candidates for each query object |
[out] | candidates | The candidate IDs for each query object |
References AXOM_LAMBDA, axom::Array< T, DIM, SPACE >::data(), axom::ArrayView< T, DIM, SPACE >::data(), axom::detail::getAllocatorID(), axom::Array< T, DIM, SPACE >::push_back(), axom::ArrayView< T, DIM, SPACE >::size(), SLIC_ASSERT, and axom::Array< T, DIM, SPACE >::view().
void axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::insert | ( | const BoxType & | BB, |
const T & | obj | ||
) |
Inserts obj into each bin overlapped by BB.
No error is signalled if BB falls partly or wholly outside the UniformGrid.
[in] | BB | The region in which to record obj |
[in] | obj | The object to insert into any bins overlapped by BB |
References SLIC_ASSERT.
UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::QueryObject axom::spin::UniformGrid< T, NDIMS, ExecSpace, StoragePolicy >::getQueryObject |