16 #ifndef SURGSIM_DATASTRUCTURES_GRID_H 17 #define SURGSIM_DATASTRUCTURES_GRID_H 20 #include <unordered_map> 27 namespace DataStructures
46 template <
typename T,
size_t N>
53 Grid(
const Eigen::Matrix<double, N, 1>& cellSize,
const Eigen::AlignedBox<double, N>& bounds);
65 template <
class Derived>
66 void addElement(
const T element,
const Eigen::MatrixBase<Derived>& position);
76 template <
class Derived>
77 const std::vector<T>&
getNeighbors(
const Eigen::MatrixBase<Derived>& position);
88 typedef Eigen::Matrix<int, N, 1>
NDId;
94 size_t operator()(
const NDId& nd)
const;
119 void getNeighborsCellIds(NDId cellId,
125 bool isNdGreaterOrEqual(
const NDId& a,
const NDId& b);
133 #endif // SURGSIM_DATASTRUCTURES_GRID_H Definition: CompoundShapeToGraphics.cpp:29
Templated function to compute a power of 3 at compile time (useful for template parameter) ...
Definition: Grid.h:32
Eigen::AlignedBox< double, N > m_aabb
Grid min and max.
Definition: Grid.h:107
Eigen::Matrix< double, N, 1 > m_size
Size of each cell (same on all dimension)
Definition: Grid.h:104
std::vector< T > neighbors
Definition: Grid.h:84
bool m_neighborsDirtyFlag
Does the neighbors needs to be recomputed ?
Definition: Grid.h:110
Data structure for a cell's content (the list of elements and the list of all the neighbors) ...
Definition: Grid.h:81
Enable the NDId to be used as a key in an unordered map.
Definition: Grid.h:91
std::unordered_map< T, NDId > m_cellIds
Mapping from element to cell id containing the element.
Definition: Grid.h:101
Definitions of small fixed-size vector types.
n-dimensional grid structure with uniform non-cubic cells This data structure is useful to search for...
Definition: Grid.h:47
std::vector< T > elements
Definition: Grid.h:83
Eigen::Matrix< int, N, 1 > NDId
The type of the n-dimensional cell Id.
Definition: Grid.h:88
std::vector< OctreePath > getNeighbors(const OctreePath &origin, int type)
Fetch a list of neighbors, indicated by the type, Face, Edge and Vertex are possible types and can be...
Definition: OctreeNode.cpp:216
std::unordered_map< NDId, CellContent, NDIdHash > m_activeCells
Active cells (referenced by their ids (spatial hashing)) with their content.
Definition: Grid.h:98