16 #ifndef SURGSIM_DATASTRUCTURES_GRID_H 17 #define SURGSIM_DATASTRUCTURES_GRID_H 20 #include <unordered_map> 27 namespace DataStructures
34 enum { value = 3 *
powerOf3<N-1>::value };
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);
71 const std::vector<T>& getNeighbors(
const T& element);
76 template <
class Derived>
77 const std::vector<T>& getNeighbors(
const Eigen::MatrixBase<Derived>& position);
83 std::vector<T> elements;
84 std::vector<T> neighbors;
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);
131 #include "SurgSim/DataStructures/Grid-inl.h" 133 #endif // SURGSIM_DATASTRUCTURES_GRID_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
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
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
Eigen::Matrix< int, N, 1 > NDId
The type of the n-dimensional cell Id.
Definition: Grid.h:88
std::unordered_map< NDId, CellContent, NDIdHash > m_activeCells
Active cells (referenced by their ids (spatial hashing)) with their content.
Definition: Grid.h:98