37 #ifndef OMPL_DATASTRUCTURES_GRID_N_ 38 #define OMPL_DATASTRUCTURES_GRID_N_ 40 #include "ompl/datastructures/Grid.h" 46 template <
typename _T>
61 struct Cell :
public BaseCell
69 Cell() : BaseCell(), neighbors(0), border(true)
140 Coord test = cell->coord;
154 BaseCellArray baselist;
156 list.reserve(list.size() + baselist.size());
157 for (
unsigned int i = 0 ; i < baselist.size() ; ++i)
158 list.push_back(static_cast<Cell*>(baselist[i]));
168 Cell *cell =
new Cell();
174 for (
typename BaseCellArray::iterator cl = list->begin() ; cl != list->end() ; ++cl)
176 Cell* c =
static_cast<Cell*
>(*cl);
184 cell->border =
false;
194 virtual bool remove(BaseCell *cell)
200 for (
typename BaseCellArray::iterator cl = list->begin() ; cl != list->end() ; ++cl)
202 Cell* c =
static_cast<Cell*
>(*cl);
223 cells.push_back(static_cast<Cell*>(i->second));
231 unsigned int result = 0;
234 for (
unsigned int i = 0 ; i < Grid<_T>::dimension_ ; ++i)
void neighbors(Coord &coord, CellArray &list) const
Get the list of neighbors for a given coordinate.
Representation of a simple grid.
unsigned int neighbors
The number of neighbors.
void setBounds(const Coord &low, const Coord &up)
Grid< _T >::CellArray BaseCellArray
Datatype for array of cells in base class.
void setInteriorCellNeighborLimit(unsigned int count)
Grid< _T >::Cell BaseCell
Datatype for cell in base class.
std::vector< int > Coord
Definition of a coordinate within this grid.
void getCells(CellArray &cells) const
Get the set of instantiated cells in the grid.
bool overrideCellNeighborsLimit_
virtual BaseCell * createCell(const Coord &coord, BaseCellArray *nbh=NULL)
Coord coord
The coordinate of the cell.
unsigned int numberOfBoundaryDimensions(const Coord &coord) const
Compute how many sides of a coordinate touch the boundaries of the grid.
void setDimension(unsigned int dimension)
Grid< _T >::Coord Coord
Datatype for cell coordinates.
std::vector< Cell * > CellArray
The datatype for arrays of cells.
Main namespace. Contains everything in this library.
Cell * getCell(const Coord &coord) const
Get the cell at a specified coordinate.
GridN(unsigned int dimension)
The constructor takes the dimension of the grid as argument.
bool border
A flag indicating whether this cell is on the border or not.
Representation of a grid where cells keep track of how many neighbors they have.
iterator end() const
Return the end() iterator for the grid.
std::vector< Cell * > CellArray
The datatype for arrays of cells.
void neighbors(const Coord &coord, CellArray &list) const
Get the list of neighbors for a given coordinate.
Coord lowBound_
If bounds are set, this defines the lower corner cell.
Definition of a cell in this grid.
bool hasBounds_
Flag indicating whether bounds are in effect for this grid.
unsigned int interiorCellNeighborsLimit_
iterator begin() const
Return the begin() iterator for the grid.
void neighbors(const Cell *cell, CellArray &list) const
Get the list of neighbors for a given cell.
void neighbors(const Cell *cell, CellArray &list) const
Get the list of neighbors for a given cell.
Cell * getCell(const Coord &coord) const
Get the cell at a specified coordinate.
Definition of a cell in this grid.
Coord upBound_
If bounds are set, this defines the upper corner cell.