An implicit grid is an occupancy-based spatial index over an indexed set of objects in space.
More...
|
| ImplicitGrid () |
| Default constructor for an ImplicitGrid. More...
|
|
| ImplicitGrid (const SpatialBoundingBox &boundingBox, const GridCell *gridRes, int numElts, int allocatorID=axom::execution_space< ExecSpace >::allocatorID()) |
| Constructor for an implicit grid from a bounding box, a grid resolution a number of elements. More...
|
|
| ImplicitGrid (const double *bbMin, const double *bbMax, const int *gridRes, int numElts, int allocatorID=axom::execution_space< ExecSpace >::allocatorID()) |
| Constructor for an implicit grid from arrays of primitive types. More...
|
|
bool | isInitialized () const |
|
QueryObject | getQueryObject () const |
|
void | initialize (const SpatialBoundingBox &boundingBox, const GridCell *gridRes, int numElts, int allocatorID=axom::execution_space< ExecSpace >::allocatorID()) |
| Initializes an implicit grid or resolution gridRes over an axis aligned domain covered by boundingBox. The implicit grid indexes a set with numElts elements. More...
|
|
const GridCell & | gridResolution () const |
|
int | numIndexElements () const |
|
void | insert (const SpatialBoundingBox &bbox, IndexType idx) |
| Inserts an element with index idx and bounding box bbox into the implicit grid. More...
|
|
void | insert (IndexType nelems, const SpatialBoundingBox *bboxes, IndexType startIdx=0) |
| Inserts a set of elements represented by bounding boxes bboxes and beginning at index startIdx into the implicit grid. More...
|
|
BitsetType | getCandidates (const SpacePoint &pt) const |
|
BitsetType | getCandidates (const GridCell &gridCell) const |
|
BitsetType | getCandidates (const SpatialBoundingBox &box) const |
|
template<typename QueryGeom > |
std::vector< IndexType > | getCandidatesAsArray (const QueryGeom &query) const |
|
template<typename QueryGeom > |
void | getCandidatesAsArray (axom::IndexType qsize, const QueryGeom *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 objects. More...
|
|
void | getCandidatesAsArray (axom::ArrayView< const SpacePoint > queryObjs, axom::ArrayView< IndexType > outOffsets, axom::ArrayView< IndexType > outCounts, axom::Array< IndexType > &outCandidates) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
|
|
void | getCandidatesAsArray (axom::ArrayView< const SpatialBoundingBox > queryObjs, axom::ArrayView< IndexType > outOffsets, axom::ArrayView< IndexType > outCounts, axom::Array< IndexType > &outCandidates) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
|
|
bool | contains (const GridCell &gridCell, IndexType idx) const |
|
template<int NDIMS, typename ExecSpace = axom::SEQ_EXEC, typename TheIndexType = int>
class axom::spin::ImplicitGrid< NDIMS, ExecSpace, TheIndexType >
An implicit grid is an occupancy-based spatial index over an indexed set of objects in space.
An ImplicitGrid divides a given rectilinear slab of space (defined by an axis aligned bounding box) into uniformly sized cells of a specified resolution. The GridCells of the ImplicitGrid index a subset of the items from an indexed set whose cardinality is specified during the ImplicitGrid's initialization. Users can insert items from the indexed set into an ImplicitGrid by providing the item's bounding box and index.
In contrast to a spin::UniformGrid, which encodes an array of indices for each cell in the underlying multidimensional grid, the ImplicitGrid encodes a single array of bins per dimension, each of which has a bitset over the index space. Thus, the storage overhead of an ImplicitGrid is fixed at initialization time to \( numElts * sum_i { res[i] } \) bits. Queries are implemented in terms of unions and intersections of bitsets.
One might prefer an ImplicitGrid over a UniformGrid when one expects a relatively dense index relative to the grid resolution (i.e. that there will be many items indexed per bucket). The ImplicitGrid is designed for quick indexing and searching over a static (and relatively small index space) in a relatively coarse grid.
template<int NDIMS, typename ExecSpace = axom::SEQ_EXEC, typename TheIndexType = int>
Initializes an implicit grid or resolution gridRes over an axis aligned domain covered by boundingBox. The implicit grid indexes a set with numElts elements.
- Parameters
-
[in] | boundingBox | Bounding box of domain to index |
[in] | gridRes | Resolution for lattice covering bounding box |
[in] | numElts | The number of elements to be indexed |
- Precondition
- The ImplicitGrid has not already been initialized
- Note
- When gridRes is NULL, we use a heuristic to set the grid resolution to the N^th root of numElts. We also ensure that the resolution along any dimension is at least one.
References axom::primal::Point< T, NDIMS >::array(), axom::Array< T, DIM, SPACE >::fill(), axom::utilities::max(), axom::primal::Vector< T, NDIMS >::norm(), axom::primal::BoundingBox< T, NDIMS >::range(), axom::spin::rectangular_lattice_from_bounding_box(), and SLIC_ASSERT.
template<int NDIMS, typename ExecSpace = axom::SEQ_EXEC, typename TheIndexType = int>
Inserts a set of elements represented by bounding boxes bboxes and beginning at index startIdx into the implicit grid.
- Parameters
-
[in] | nelems | the number of elements to insert |
[in] | bboxes | an array of bounding boxes for each element |
[in] | startIdx | the index of the first bounding box in bboxes |
References AXOM_LAMBDA, axom::Array< T, DIM, SPACE >::data(), axom::slam::Map< T, S, IndPol, StrPol, IfacePol >::data(), axom::primal::BoundingBox< T, NDIMS >::expand(), axom::primal::BoundingBox< T, NDIMS >::getMax(), axom::primal::BoundingBox< T, NDIMS >::getMin(), axom::spin::RectangularLattice< NDIMS, SpaceCoordType, CellCoordType >::gridCell(), axom::slam::Map< T, S, IndPol, StrPol, IfacePol >::set(), axom::slam::Set< PosType, ElemType >::size(), and SLIC_ASSERT.
template<int NDIMS, typename ExecSpace = axom::SEQ_EXEC, typename TheIndexType = int>
template<typename QueryGeom >
Returns an explicit list of candidates in the vicinity of a query object
- Template Parameters
-
QueryGeom | The type of the query object (e.g. point or box) |
- Parameters
-
[in] | query | The query object |
- Returns
- A list of indexes from the IndexSet whose corresponding bounding boxes overlap the grid cell containing query
- Precondition
- This function is implemented in terms of ImplicitGrid::getCandidates(const QueryGeom& ). An overload for the actual QueryGeom type (e.g. SpacePoint or SpatialBoundingBox) must exist.
- Note
- This function returns the same information as getCandidates(), but in a different format. While the latter returns a bitset of the candidates, this function returns an explicit list of indices.
- See also
- getCandidates()
References axom::slam::BitSet::count(), axom::slam::BitSet::find_first(), and axom::slam::BitSet::find_next().
template<int NDIMS, typename ExecSpace , typename IndexType >
template<typename QueryGeom >
Returns a list of candidates in the vicinity of a set of query objects.
- Template Parameters
-
QueryGeom | The type of the query object (e.g. point or box) |
- Parameters
-
[in] | qsize | The number of objects to query against the implicit grid |
[in] | queryObjs | The array of query objects, of length qsize |
[out] | outOffsets | Offsets into the candidates array for each query object |
[out] | outCounts | The number of candidates for each query object |
[out] | outCandidates | The candidate IDs for each query object |
- Note
- outOffsets and outCounts should point to arrays allocated in a memory space accessible from the given execution space, and be of length qsize.
-
Upon completion, the ith query point has:
- counts[ i ] candidates
- Stored in the candidates array in the following range: [ offsets[ i ], offsets[ i ]+counts[ i ] ]
References AXOM_LAMBDA, axom::ArrayView< T, DIM, SPACE >::data(), axom::Array< T, DIM, SPACE >::push_back(), axom::ArrayView< T, DIM, SPACE >::size(), SLIC_ERROR_IF, and axom::Array< T, DIM, SPACE >::view().