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) |
| 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) |
| Constructor for an implicit grid from arrays of primitive types. More...
|
|
bool | isInitialized () const |
|
void | initialize (const SpatialBoundingBox &boundingBox, const GridCell *gridRes, int numElts) |
| 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 (SpatialBoundingBox bbox, IndexType idx) |
| Inserts an element with index idx and bounding box bbox into the implicit grid. More...
|
|
BitsetType | getCandidates (const SpacePoint &pt) const |
|
BitsetType | getCandidates (const SpatialBoundingBox &box) const |
|
template<typename QueryGeom > |
std::vector< IndexType > | getCandidatesAsArray (const QueryGeom &query) const |
|
bool | contains (const GridCell &gridCell, IndexType idx) const |
|
template<int NDIMS, typename TheIndexType = int>
class axom::spin::ImplicitGrid< NDIMS, 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 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::utilities::max(), axom::primal::Vector< T, NDIMS >::norm(), axom::primal::BoundingBox< T, NDIMS >::range(), axom::spin::rectangular_lattice_from_bounding_box(), and SLIC_ASSERT.
Referenced by axom::spin::ImplicitGrid< NDIMS, TheIndexType >::ImplicitGrid().
template<int NDIMS, typename TheIndexType = int>
template<typename QueryGeom >
template<int NDIMS, typename TheIndexType = int>
Tests whether grid cell gridPt indexes the element with index idx
- Parameters
-
[in] | gridCell | The cell within the ImplicitGrid that we are testing |
[in] | idx | An element index from the IndexSet to test |
- Precondition
- idx should be in the IndexSet. I.e. 0 <= idx < numIndexElements()
- Returns
- True if the bounding box of element idx overlaps with GridCell gridCell.
References axom::utilities::clampLower(), axom::utilities::clampUpper(), axom::slam::OrderedSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy, IndirectionPolicy, SubsettingPolicy >::isValidIndex(), axom::slam::OrderedSet< PosType, ElemType, SizePolicy, OffsetPolicy, StridePolicy, IndirectionPolicy, SubsettingPolicy >::size(), and SLIC_ASSERT.