n-dimensional grid structure with uniform non-cubic cells This data structure is useful to search for neighbors in a given range (the size of each cell)
More...
#include <Grid.h>
|
struct | CellContent |
| Data structure for a cell's content (the list of elements and the list of all the neighbors) More...
|
|
class | NDIdHash |
| Enable the NDId to be used as a key in an unordered map. More...
|
|
|
| Grid (const Eigen::Matrix< double, N, 1 > &cellSize, const Eigen::AlignedBox< double, N > &bounds) |
| Constructor. More...
|
|
virtual | ~Grid () |
| Destructor.
|
|
void | reset () |
| Reset the grid content and the neighbors' mapping.
|
|
template<class Derived > |
void | addElement (const T element, const Eigen::MatrixBase< Derived > &position) |
| Add an element in the grid. More...
|
|
const std::vector< T > & | getNeighbors (const T &element) |
| Retrieve an elements' neighbors. More...
|
|
template<class Derived > |
const std::vector< T > & | getNeighbors (const Eigen::MatrixBase< Derived > &position) |
| Retrieve the neighbors of a location. More...
|
|
|
typedef Eigen::Matrix< int, N, 1 > | NDId |
| The type of the n-dimensional cell Id.
|
|
|
std::unordered_map< NDId, CellContent, NDIdHash > | m_activeCells |
| Active cells (referenced by their ids (spatial hashing)) with their content.
|
|
std::unordered_map< T, NDId > | m_cellIds |
| Mapping from element to cell id containing the element.
|
|
Eigen::Matrix< double, N, 1 > | m_size |
| Size of each cell (same on all dimension)
|
|
Eigen::AlignedBox< double, N > | m_aabb |
| Grid min and max.
|
|
bool | m_neighborsDirtyFlag |
| Does the neighbors needs to be recomputed ?
|
|
template<typename T, size_t N>
class SurgSim::DataStructures::Grid< T, N >
n-dimensional grid structure with uniform non-cubic cells This data structure is useful to search for neighbors in a given range (the size of each cell)
- Template Parameters
-
T | Element type to be stored |
N | The dimension of the grid (i.e. 2 => 2D, 3 => 3D) |
§ Grid()
template<typename T , size_t N>
Constructor.
- Parameters
-
cellSize | The size of each cell in dimension N (i.e. cells are not necessarily cubic). |
bounds | The dimension-N boundaries of the space covered by the grid. |
§ addElement()
template<typename T , size_t N>
template<class Derived >
Add an element in the grid.
- Parameters
-
element | to be added at this position |
position | of the element in the n-D space |
- Note
- If the position is outside of the grid, the element is simply not added to the grid
Flag that the neighbors list will need to be recomputed on the next access
§ getNeighbors() [1/2]
template<typename T , size_t N>
Retrieve an elements' neighbors.
- Parameters
-
element | The element for which the neighbors are requested |
- Returns
- The element's neighbors list (including the element itself)
§ getNeighbors() [2/2]
template<typename T , size_t N>
template<class Derived >
Retrieve the neighbors of a location.
- Parameters
-
position | The position for which the neighbors are requested |
- Returns
- The neighbors for this position, i.e. all the elements in the positions cell and all surrounding cells
The documentation for this class was generated from the following files: