CellModules
Grid2D::Plugin2DGrid< cell_t > Class Template Reference

Template class for a 2D grid physics-based plugin. More...

#include <Plugin2DGrid.hpp>

Public Member Functions

 Plugin2DGrid ()
 Default constructor. More...
 
void resizeCellGrid (int w, int h)
 Resizes the cell grid to the given width and height. More...
 
void resizeCellGrid (int size)
 Resizes the cell grid to a square of the given size. More...
 
void setToreX (bool b)
 Sets the toric property on the X-axis. More...
 
void setToreY (bool b)
 Sets the toric property on the Y-axis. More...
 
void setTore (bool x, bool y)
 Sets the toric properties on both X and Y axes. More...
 
double getNbOccupiedPositions () const
 Gets the number of occupied positions. More...
 
double getOccupationSurfaceRatio () const
 Gets the occupation surface ratio. More...
 
template<typename world_t >
double getGlobalDensity (world_t *w) const
 Gets the global density of the grid. More...
 
CellGrid< cell_t > * getCellGrid ()
 Gets the cell grid. More...
 
template<typename world_t >
void onAddCell (world_t *w)
 Hook called when cells is added to the world. More...
 
template<typename world_t >
void preBehaviorUpdate (world_t *w)
 Hook called before the behavior update of the world. More...
 
template<typename world_t >
void preDeleteDeadCellsUpdate (world_t *w)
 Hook called before deleting dead cells from the world. More...
 

Private Member Functions

void updateNeighbouringLocation (cell_t *c)
 Updates the number of neighbouring locations for a cell. More...
 
void computeNeighbouringCells (cell_t *c)
 Computes the neighbouring cells for a given cell. More...
 

Private Attributes

double nbOccupiedPositions = 0
 
CellGrid< cell_t > cellGrid
 

Detailed Description

template<typename cell_t>
class Grid2D::Plugin2DGrid< cell_t >

Template class for a 2D grid physics-based plugin.

Template Parameters
cell_tType of the cell used in the grid.

Definition at line 28 of file Plugin2DGrid.hpp.

Constructor & Destructor Documentation

◆ Plugin2DGrid()

template<typename cell_t >
Grid2D::Plugin2DGrid< cell_t >::Plugin2DGrid ( )
inline

Default constructor.

Definition at line 106 of file Plugin2DGrid.hpp.

Member Function Documentation

◆ computeNeighbouringCells()

template<typename cell_t >
void Grid2D::Plugin2DGrid< cell_t >::computeNeighbouringCells ( cell_t *  c)
inlineprivate

Computes the neighbouring cells for a given cell.

Parameters
cPointer to the cell

Definition at line 63 of file Plugin2DGrid.hpp.

◆ getCellGrid()

template<typename cell_t >
CellGrid< cell_t > * Grid2D::Plugin2DGrid< cell_t >::getCellGrid ( )
inline

Gets the cell grid.

Returns
Pointer to the cell grid

Definition at line 182 of file Plugin2DGrid.hpp.

◆ getGlobalDensity()

template<typename cell_t >
template<typename world_t >
double Grid2D::Plugin2DGrid< cell_t >::getGlobalDensity ( world_t *  w) const
inline

Gets the global density of the grid.

Template Parameters
world_tType of the world
Parameters
wPointer to the world
Returns
Global density

Definition at line 174 of file Plugin2DGrid.hpp.

◆ getNbOccupiedPositions()

template<typename cell_t >
double Grid2D::Plugin2DGrid< cell_t >::getNbOccupiedPositions ( ) const
inline

Gets the number of occupied positions.

Returns
Number of occupied positions

Definition at line 153 of file Plugin2DGrid.hpp.

◆ getOccupationSurfaceRatio()

template<typename cell_t >
double Grid2D::Plugin2DGrid< cell_t >::getOccupationSurfaceRatio ( ) const
inline

Gets the occupation surface ratio.

Returns
Occupation surface ratio

Returns the ratio of occupied positions to the total number of possible locations.

Definition at line 163 of file Plugin2DGrid.hpp.

◆ onAddCell()

template<typename cell_t >
template<typename world_t >
void Grid2D::Plugin2DGrid< cell_t >::onAddCell ( world_t *  w)
inline

Hook called when cells is added to the world.

Template Parameters
world_tType of the world
Parameters
wPointer to the world

Definition at line 190 of file Plugin2DGrid.hpp.

◆ preBehaviorUpdate()

template<typename cell_t >
template<typename world_t >
void Grid2D::Plugin2DGrid< cell_t >::preBehaviorUpdate ( world_t *  w)
inline

Hook called before the behavior update of the world.

Template Parameters
world_tType of the world
Parameters
wPointer to the world

Definition at line 204 of file Plugin2DGrid.hpp.

◆ preDeleteDeadCellsUpdate()

template<typename cell_t >
template<typename world_t >
void Grid2D::Plugin2DGrid< cell_t >::preDeleteDeadCellsUpdate ( world_t *  w)
inline

Hook called before deleting dead cells from the world.

Template Parameters
world_tType of the world
Parameters
wPointer to the world

Definition at line 217 of file Plugin2DGrid.hpp.

◆ resizeCellGrid() [1/2]

template<typename cell_t >
void Grid2D::Plugin2DGrid< cell_t >::resizeCellGrid ( int  size)
inline

Resizes the cell grid to a square of the given size.

Parameters
sizeSize of the grid (both width and height)

Definition at line 122 of file Plugin2DGrid.hpp.

◆ resizeCellGrid() [2/2]

template<typename cell_t >
void Grid2D::Plugin2DGrid< cell_t >::resizeCellGrid ( int  w,
int  h 
)
inline

Resizes the cell grid to the given width and height.

Parameters
wWidth of the grid
hHeight of the grid

Definition at line 114 of file Plugin2DGrid.hpp.

◆ setTore()

template<typename cell_t >
void Grid2D::Plugin2DGrid< cell_t >::setTore ( bool  x,
bool  y 
)
inline

Sets the toric properties on both X and Y axes.

Parameters
xBoolean value to set toreX
yBoolean value to set toreY

Definition at line 147 of file Plugin2DGrid.hpp.

◆ setToreX()

template<typename cell_t >
void Grid2D::Plugin2DGrid< cell_t >::setToreX ( bool  b)
inline

Sets the toric property on the X-axis.

Parameters
bBoolean value to set toreX

Definition at line 130 of file Plugin2DGrid.hpp.

◆ setToreY()

template<typename cell_t >
void Grid2D::Plugin2DGrid< cell_t >::setToreY ( bool  b)
inline

Sets the toric property on the Y-axis.

Parameters
bBoolean value to set toreY

Definition at line 138 of file Plugin2DGrid.hpp.

◆ updateNeighbouringLocation()

template<typename cell_t >
void Grid2D::Plugin2DGrid< cell_t >::updateNeighbouringLocation ( cell_t *  c)
inlineprivate

Updates the number of neighbouring locations for a cell.

Parameters
cPointer to the cell

Sets the number of locations based on the Moore neighbourhood, taking toricity into account.

Definition at line 41 of file Plugin2DGrid.hpp.

Member Data Documentation

◆ cellGrid

template<typename cell_t >
CellGrid<cell_t> Grid2D::Plugin2DGrid< cell_t >::cellGrid
private

Grid containing the cells

Definition at line 33 of file Plugin2DGrid.hpp.

◆ nbOccupiedPositions

template<typename cell_t >
double Grid2D::Plugin2DGrid< cell_t >::nbOccupiedPositions = 0
private

Number of occupied locations

Definition at line 31 of file Plugin2DGrid.hpp.


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