Loading...
Searching...
No Matches

Representation of a simple grid. More...

#include <ompl/datastructures/Grid.h>

Inheritance diagram for ompl::Grid< _T >:

Classes

struct  Cell
 Definition of a cell in this grid. More...
 
struct  EqualCoordPtr
 Equality operator for coordinate pointers. More...
 
struct  HashFunCoordPtr
 
struct  SortComponents
 Helper to sort components by size. More...
 

Public Types

using Coord = Eigen::VectorXi
 Definition of a coordinate within this grid.
 
using CellArray = std::vector< Cell * >
 The datatype for arrays of cells.
 
using iterator = typename CoordHash::const_iterator
 We only allow const iterators.
 

Public Member Functions

 Grid (unsigned int dimension)
 The constructor takes the dimension of the grid as argument.
 
virtual ~Grid ()
 Destructor.
 
virtual void clear ()
 Clear all cells in the grid.
 
unsigned int getDimension () const
 Return the dimension of the grid.
 
void setDimension (unsigned int dimension)
 
bool has (const Coord &coord) const
 Check if a cell exists at the specified coordinate.
 
CellgetCell (const Coord &coord) const
 Get the cell at a specified coordinate.
 
void neighbors (const Cell *cell, CellArray &list) const
 Get the list of neighbors for a given cell.
 
void neighbors (const Coord &coord, CellArray &list) const
 Get the list of neighbors for a given coordinate.
 
void neighbors (Coord &coord, CellArray &list) const
 Get the list of neighbors for a given coordinate.
 
std::vector< std::vector< Cell * > > components () const
 Get the connected components formed by the cells in this grid (based on neighboring relation)
 
virtual CellcreateCell (const Coord &coord, CellArray *nbh=nullptr)
 
virtual bool remove (Cell *cell)
 
virtual void add (Cell *cell)
 Add an instantiated cell to the grid.
 
virtual void destroyCell (Cell *cell) const
 Clear the memory occupied by a cell; do not call this function unless remove() was called first.
 
void getContent (std::vector< _T > &content) const
 Get the data stored in the cells we are aware of.
 
void getCoordinates (std::vector< Coord * > &coords) const
 Get the set of coordinates where there are cells.
 
void getCells (CellArray &cells) const
 Get the set of instantiated cells in the grid.
 
void printCoord (Coord &coord, std::ostream &out=std::cout) const
 Print the value of a coordinate to a stream.
 
bool empty () const
 Check if the grid is empty.
 
unsigned int size () const
 Check the size of the grid.
 
virtual void status (std::ostream &out=std::cout) const
 Print information about the data in this grid structure.
 
iterator begin () const
 Return the begin() iterator for the grid.
 
iterator end () const
 Return the end() iterator for the grid.
 

Protected Types

using CoordHash = std::unordered_map< Coord *, Cell *, HashFunCoordPtr, EqualCoordPtr >
 Define the datatype for the used hash structure.
 

Protected Member Functions

void freeMemory ()
 Free the allocated memory.
 

Protected Attributes

unsigned int dimension_
 The dimension of the grid.
 
unsigned int maxNeighbors_
 The maximum number of neighbors a cell can have (2 * dimension)
 
CoordHash hash_
 The hash holding the cells.
 

Detailed Description

template<typename _T>
class ompl::Grid< _T >

Representation of a simple grid.

Definition at line 51 of file Grid.h.

Member Typedef Documentation

◆ CellArray

template<typename _T >
using ompl::Grid< _T >::CellArray = std::vector<Cell *>

The datatype for arrays of cells.

Definition at line 74 of file Grid.h.

◆ Coord

template<typename _T >
using ompl::Grid< _T >::Coord = Eigen::VectorXi

Definition of a coordinate within this grid.

Definition at line 55 of file Grid.h.

◆ CoordHash

template<typename _T >
using ompl::Grid< _T >::CoordHash = std::unordered_map<Coord *, Cell *, HashFunCoordPtr, EqualCoordPtr>
protected

Define the datatype for the used hash structure.

Definition at line 352 of file Grid.h.

◆ iterator

template<typename _T >
using ompl::Grid< _T >::iterator = typename CoordHash::const_iterator

We only allow const iterators.

Definition at line 366 of file Grid.h.

Constructor & Destructor Documentation

◆ Grid()

template<typename _T >
ompl::Grid< _T >::Grid ( unsigned int  dimension)
inlineexplicit

The constructor takes the dimension of the grid as argument.

Definition at line 77 of file Grid.h.

◆ ~Grid()

template<typename _T >
virtual ompl::Grid< _T >::~Grid ( )
inlinevirtual

Destructor.

Definition at line 83 of file Grid.h.

Member Function Documentation

◆ add()

template<typename _T >
virtual void ompl::Grid< _T >::add ( Cell cell)
inlinevirtual

Add an instantiated cell to the grid.

Definition at line 246 of file Grid.h.

◆ begin()

template<typename _T >
iterator ompl::Grid< _T >::begin ( ) const
inline

Return the begin() iterator for the grid.

Definition at line 369 of file Grid.h.

◆ clear()

template<typename _T >
virtual void ompl::Grid< _T >::clear ( )
inlinevirtual

Clear all cells in the grid.

Reimplemented in ompl::GridB< CellData *, OrderCellsByImportance >, and ompl::GridB< _T, LessThanExternal, LessThanInternal >.

Definition at line 89 of file Grid.h.

◆ components()

template<typename _T >
std::vector< std::vector< Cell * > > ompl::Grid< _T >::components ( ) const
inline

Get the connected components formed by the cells in this grid (based on neighboring relation)

Definition at line 164 of file Grid.h.

◆ createCell()

template<typename _T >
virtual Cell * ompl::Grid< _T >::createCell ( const Coord coord,
CellArray nbh = nullptr 
)
inlinevirtual

Instantiate a new cell at given coordinates; optionally Return the list of future neighbors. Note: this call only creates the cell, but does not add it to the grid. It however updates the neighbor count for neighboring cells

Reimplemented in ompl::GridN< _T >, and ompl::GridB< _T, LessThanExternal, LessThanInternal >.

Definition at line 220 of file Grid.h.

◆ destroyCell()

template<typename _T >
virtual void ompl::Grid< _T >::destroyCell ( Cell cell) const
inlinevirtual

Clear the memory occupied by a cell; do not call this function unless remove() was called first.

Definition at line 252 of file Grid.h.

◆ empty()

template<typename _T >
bool ompl::Grid< _T >::empty ( ) const
inline

Check if the grid is empty.

Definition at line 288 of file Grid.h.

◆ end()

template<typename _T >
iterator ompl::Grid< _T >::end ( ) const
inline

Return the end() iterator for the grid.

Definition at line 375 of file Grid.h.

◆ freeMemory()

template<typename _T >
void ompl::Grid< _T >::freeMemory ( )
inlineprotected

Free the allocated memory.

Definition at line 312 of file Grid.h.

◆ getCell()

template<typename _T >
Cell * ompl::Grid< _T >::getCell ( const Coord coord) const
inline

Get the cell at a specified coordinate.

Definition at line 117 of file Grid.h.

◆ getCells()

template<typename _T >
void ompl::Grid< _T >::getCells ( CellArray cells) const
inline

Get the set of instantiated cells in the grid.

Definition at line 272 of file Grid.h.

◆ getContent()

template<typename _T >
void ompl::Grid< _T >::getContent ( std::vector< _T > &  content) const
inline

Get the data stored in the cells we are aware of.

Definition at line 258 of file Grid.h.

◆ getCoordinates()

template<typename _T >
void ompl::Grid< _T >::getCoordinates ( std::vector< Coord * > &  coords) const
inline

Get the set of coordinates where there are cells.

Definition at line 265 of file Grid.h.

◆ getDimension()

template<typename _T >
unsigned int ompl::Grid< _T >::getDimension ( ) const
inline

Return the dimension of the grid.

Definition at line 95 of file Grid.h.

◆ has()

template<typename _T >
bool ompl::Grid< _T >::has ( const Coord coord) const
inline

Check if a cell exists at the specified coordinate.

Definition at line 111 of file Grid.h.

◆ neighbors() [1/3]

template<typename _T >
void ompl::Grid< _T >::neighbors ( const Cell cell,
CellArray list 
) const
inline

Get the list of neighbors for a given cell.

Definition at line 125 of file Grid.h.

◆ neighbors() [2/3]

template<typename _T >
void ompl::Grid< _T >::neighbors ( const Coord coord,
CellArray list 
) const
inline

Get the list of neighbors for a given coordinate.

Definition at line 132 of file Grid.h.

◆ neighbors() [3/3]

template<typename _T >
void ompl::Grid< _T >::neighbors ( Coord coord,
CellArray list 
) const
inline

Get the list of neighbors for a given coordinate.

Definition at line 139 of file Grid.h.

◆ printCoord()

template<typename _T >
void ompl::Grid< _T >::printCoord ( Coord coord,
std::ostream &  out = std::cout 
) const
inline

Print the value of a coordinate to a stream.

Definition at line 279 of file Grid.h.

◆ remove()

template<typename _T >
virtual bool ompl::Grid< _T >::remove ( Cell cell)
inlinevirtual

Remove a cell from the grid. If the cell has not been Added to the grid, only update the neighbor list

Definition at line 231 of file Grid.h.

◆ setDimension()

template<typename _T >
void ompl::Grid< _T >::setDimension ( unsigned int  dimension)
inline

Update the dimension of the grid; this should not be done unless the grid is empty

Definition at line 102 of file Grid.h.

◆ size()

template<typename _T >
unsigned int ompl::Grid< _T >::size ( ) const
inline

Check the size of the grid.

Definition at line 294 of file Grid.h.

◆ status()

template<typename _T >
virtual void ompl::Grid< _T >::status ( std::ostream &  out = std::cout) const
inlinevirtual

Print information about the data in this grid structure.

Reimplemented in ompl::GridB< CellData *, OrderCellsByImportance >, and ompl::GridB< _T, LessThanExternal, LessThanInternal >.

Definition at line 300 of file Grid.h.

Member Data Documentation

◆ dimension_

template<typename _T >
unsigned int ompl::Grid< _T >::dimension_
protected

The dimension of the grid.

Definition at line 382 of file Grid.h.

◆ hash_

template<typename _T >
CoordHash ompl::Grid< _T >::hash_
protected

The hash holding the cells.

Definition at line 388 of file Grid.h.

◆ maxNeighbors_

template<typename _T >
unsigned int ompl::Grid< _T >::maxNeighbors_
protected

The maximum number of neighbors a cell can have (2 * dimension)

Definition at line 385 of file Grid.h.


The documentation for this class was generated from the following file: