CellModules
Grid2D::Body2DGrid< cell_t, plugin_t > Class Template Reference

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

#include <Body2DGrid.hpp>

Inheritance diagram for Grid2D::Body2DGrid< cell_t, plugin_t >:
MecaCell::Movable BaseBody< plugin_t >

Public Member Functions

 Body2DGrid ()=default
 Default constructor. More...
 
 Body2DGrid (const MecaCell::Vector3D &pos)
 Constructor with position. More...
 
int getNbNeighbouringLocations () const
 Gets the number of neighbouring locations. More...
 
void setNbNeighbouringLocations (int n)
 Sets the number of neighbouring locations. More...
 
int getNbNeighbouringCells () const
 Gets the number of neighbouring cells. More...
 
void setNbNeighbouringCells (int n)
 Sets the number of neighbouring cells. More...
 
double getDensity () const
 Gets the density of the cell. More...
 
double getBoundingBoxRadius () const
 Gets the bounding box radius. More...
 
void setRadius (double _radius)
 Sets the bounding box radius. More...
 
Vec2D get2DPosition () const
 Gets the 2D position of the cell. More...
 
MecaCell::Vector3D getPosition () const
 Gets the 3D position of the cell. More...
 
void set2DPosition (const Vec2D &p)
 Sets the 2D position of the cell. More...
 
void set2DPosition (int i, int j)
 Sets the 2D position of the cell. More...
 
void setPosition (const MecaCell::Vector3D &p)
 Sets the 3D position of the cell. More...
 
CellGrid< cell_t > * getCellGrid ()
 Gets the cell grid. More...
 
Vec2D findLowestDensityPosition (int range)
 Finds one of the lowest density positions within a range. if there are multiple positions with the same lowest density, one is chosen randomly. More...
 
bool isMovementEnabled ()
 
void disableMovement ()
 
void enableMovement ()
 
Vec getPrevposition () const
 
Vec getVelocity () const
 
Vec getForce () const
 
double getMass () const
 
void setPrevposition (const Vec &p)
 
void setVelocity (const Vec &v)
 
void setForce (const Vec &f)
 
void setMass (const double m)
 
void receiveForce (const double &intensity, const Vec &direction, const bool &compressive)
 
void receiveForce (const Vec &f)
 
void resetVelocity ()
 
void resetForce ()
 
void setCellPlugin (plugin_t *_cellPlugin)
 
void onCellPluginLinking ()
 

Protected Attributes

Vec prevposition = Vec::zero()
 
Vec velocity = Vec::zero()
 
Vec force = Vec::zero()
 
bool movementEnabled = true
 
double mass = Config::DEFAULT_CELL_MASS
 
double totalForce = 0
 
plugin_t * cellPlugin
 

Private Attributes

double radius = MecaCell::Config::DEFAULT_CELL_RADIUS
 
Vec2D position2D = Vec2D(0, 0)
 
int nbNeighbouringLocations = 9
 
int nbNeighbouringCells = 1
 
CellGrid< cell_t > * cellGrid = nullptr
 
MecaCell::Vector3D position
 

Detailed Description

template<typename cell_t, class plugin_t>
class Grid2D::Body2DGrid< cell_t, plugin_t >

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

Template Parameters
cell_tType of the cell used in the grid.
plugin_tType of the plugin used with the body.

Definition at line 31 of file Body2DGrid.hpp.

Constructor & Destructor Documentation

◆ Body2DGrid() [1/2]

template<typename cell_t , class plugin_t >
Grid2D::Body2DGrid< cell_t, plugin_t >::Body2DGrid ( )
inlineexplicitdefault

Default constructor.

◆ Body2DGrid() [2/2]

template<typename cell_t , class plugin_t >
Grid2D::Body2DGrid< cell_t, plugin_t >::Body2DGrid ( const MecaCell::Vector3D pos)
inlineexplicit

Constructor with position.

Parameters
posInitial position of the cell in 3D space

Sets the position of the cell in the 3D space and in the 2D grid.

Definition at line 56 of file Body2DGrid.hpp.

Member Function Documentation

◆ disableMovement()

void MecaCell::Movable::disableMovement ( )
inlineinherited

Definition at line 24 of file movable.h.

◆ enableMovement()

void MecaCell::Movable::enableMovement ( )
inlineinherited

Definition at line 25 of file movable.h.

◆ findLowestDensityPosition()

template<typename cell_t , class plugin_t >
Vec2D Grid2D::Body2DGrid< cell_t, plugin_t >::findLowestDensityPosition ( int  range)
inline

Finds one of the lowest density positions within a range. if there are multiple positions with the same lowest density, one is chosen randomly.

Parameters
rangeRange to search for the lowest density position
Returns
2D position with the lowest density

Definition at line 168 of file Body2DGrid.hpp.

◆ get2DPosition()

template<typename cell_t , class plugin_t >
Vec2D Grid2D::Body2DGrid< cell_t, plugin_t >::get2DPosition ( ) const
inline

Gets the 2D position of the cell.

Returns
2D position

Definition at line 108 of file Body2DGrid.hpp.

◆ getBoundingBoxRadius()

template<typename cell_t , class plugin_t >
double Grid2D::Body2DGrid< cell_t, plugin_t >::getBoundingBoxRadius ( ) const
inline

Gets the bounding box radius.

Returns
Bounding box radius

Definition at line 96 of file Body2DGrid.hpp.

◆ getCellGrid()

template<typename cell_t , class plugin_t >
CellGrid< cell_t > * Grid2D::Body2DGrid< cell_t, plugin_t >::getCellGrid ( )
inline

Gets the cell grid.

Returns
Pointer to the cell grid

Definition at line 161 of file Body2DGrid.hpp.

◆ getDensity()

template<typename cell_t , class plugin_t >
double Grid2D::Body2DGrid< cell_t, plugin_t >::getDensity ( ) const
inline

Gets the density of the cell.

Returns
Density of the cell

Counts the cell itself in the density.

Definition at line 90 of file Body2DGrid.hpp.

◆ getForce()

Vec MecaCell::Movable::getForce ( ) const
inlineinherited

Definition at line 29 of file movable.h.

◆ getMass()

double MecaCell::Movable::getMass ( ) const
inlineinherited

Definition at line 30 of file movable.h.

◆ getNbNeighbouringCells()

template<typename cell_t , class plugin_t >
int Grid2D::Body2DGrid< cell_t, plugin_t >::getNbNeighbouringCells ( ) const
inline

Gets the number of neighbouring cells.

Returns
Number of neighbouring cells

Definition at line 76 of file Body2DGrid.hpp.

◆ getNbNeighbouringLocations()

template<typename cell_t , class plugin_t >
int Grid2D::Body2DGrid< cell_t, plugin_t >::getNbNeighbouringLocations ( ) const
inline

Gets the number of neighbouring locations.

Returns
Number of neighbouring locations

Definition at line 64 of file Body2DGrid.hpp.

◆ getPosition()

template<typename cell_t , class plugin_t >
MecaCell::Vector3D Grid2D::Body2DGrid< cell_t, plugin_t >::getPosition ( ) const
inline

Gets the 3D position of the cell.

Returns
3D position

Returns the 3D position based on the 2D position with z = 0.

Definition at line 116 of file Body2DGrid.hpp.

◆ getPrevposition()

Vec MecaCell::Movable::getPrevposition ( ) const
inlineinherited

Definition at line 27 of file movable.h.

◆ getVelocity()

Vec MecaCell::Movable::getVelocity ( ) const
inlineinherited

Definition at line 28 of file movable.h.

◆ isMovementEnabled()

bool MecaCell::Movable::isMovementEnabled ( )
inlineinherited

Definition at line 23 of file movable.h.

◆ onCellPluginLinking()

void BaseBody< plugin_t >::onCellPluginLinking ( )
inlineinherited

Definition at line 15 of file BaseBody.hpp.

◆ receiveForce() [1/2]

void MecaCell::Movable::receiveForce ( const double &  intensity,
const Vec direction,
const bool &  compressive 
)
inlineinherited

Definition at line 39 of file movable.h.

◆ receiveForce() [2/2]

void MecaCell::Movable::receiveForce ( const Vec f)
inlineinherited

Definition at line 44 of file movable.h.

◆ resetForce()

void MecaCell::Movable::resetForce ( )
inlineinherited

Definition at line 46 of file movable.h.

◆ resetVelocity()

void MecaCell::Movable::resetVelocity ( )
inlineinherited

Definition at line 45 of file movable.h.

◆ set2DPosition() [1/2]

template<typename cell_t , class plugin_t >
void Grid2D::Body2DGrid< cell_t, plugin_t >::set2DPosition ( const Vec2D p)
inline

Sets the 2D position of the cell.

Parameters
p2D position

Definition at line 122 of file Body2DGrid.hpp.

◆ set2DPosition() [2/2]

template<typename cell_t , class plugin_t >
void Grid2D::Body2DGrid< cell_t, plugin_t >::set2DPosition ( int  i,
int  j 
)
inline

Sets the 2D position of the cell.

Parameters
iX-coordinate
jY-coordinate

Definition at line 149 of file Body2DGrid.hpp.

◆ setCellPlugin()

void BaseBody< plugin_t >::setCellPlugin ( plugin_t *  _cellPlugin)
inlineinherited

Definition at line 14 of file BaseBody.hpp.

◆ setForce()

void MecaCell::Movable::setForce ( const Vec f)
inlineinherited

Definition at line 34 of file movable.h.

◆ setMass()

void MecaCell::Movable::setMass ( const double  m)
inlineinherited

Definition at line 35 of file movable.h.

◆ setNbNeighbouringCells()

template<typename cell_t , class plugin_t >
void Grid2D::Body2DGrid< cell_t, plugin_t >::setNbNeighbouringCells ( int  n)
inline

Sets the number of neighbouring cells.

Parameters
nNumber of neighbouring cells

Definition at line 82 of file Body2DGrid.hpp.

◆ setNbNeighbouringLocations()

template<typename cell_t , class plugin_t >
void Grid2D::Body2DGrid< cell_t, plugin_t >::setNbNeighbouringLocations ( int  n)
inline

Sets the number of neighbouring locations.

Parameters
nNumber of neighbouring locations

Definition at line 70 of file Body2DGrid.hpp.

◆ setPosition()

template<typename cell_t , class plugin_t >
void Grid2D::Body2DGrid< cell_t, plugin_t >::setPosition ( const MecaCell::Vector3D p)
inline

Sets the 3D position of the cell.

Parameters
p3D position

Definition at line 155 of file Body2DGrid.hpp.

◆ setPrevposition()

void MecaCell::Movable::setPrevposition ( const Vec p)
inlineinherited

Definition at line 32 of file movable.h.

◆ setRadius()

template<typename cell_t , class plugin_t >
void Grid2D::Body2DGrid< cell_t, plugin_t >::setRadius ( double  _radius)
inline

Sets the bounding box radius.

Parameters
_radiusBounding box radius

Definition at line 102 of file Body2DGrid.hpp.

◆ setVelocity()

void MecaCell::Movable::setVelocity ( const Vec v)
inlineinherited

Definition at line 33 of file movable.h.

Member Data Documentation

◆ cellGrid

template<typename cell_t , class plugin_t >
CellGrid<cell_t>* Grid2D::Body2DGrid< cell_t, plugin_t >::cellGrid = nullptr
private

Pointer to the grid containing all the cells

Definition at line 39 of file Body2DGrid.hpp.

◆ cellPlugin

plugin_t * BaseBody< plugin_t >::cellPlugin
protectedinherited

Definition at line 9 of file BaseBody.hpp.

◆ force

Vec MecaCell::Movable::force = Vec::zero()
protectedinherited

Definition at line 11 of file movable.h.

◆ mass

double MecaCell::Movable::mass = Config::DEFAULT_CELL_MASS
protectedinherited

Definition at line 13 of file movable.h.

◆ movementEnabled

bool MecaCell::Movable::movementEnabled = true
protectedinherited

Definition at line 12 of file movable.h.

◆ nbNeighbouringCells

template<typename cell_t , class plugin_t >
int Grid2D::Body2DGrid< cell_t, plugin_t >::nbNeighbouringCells = 1
private

Number of neighbouring cells

Definition at line 37 of file Body2DGrid.hpp.

◆ nbNeighbouringLocations

template<typename cell_t , class plugin_t >
int Grid2D::Body2DGrid< cell_t, plugin_t >::nbNeighbouringLocations = 9
private

Number of neighbouring locations, includes the cell location

Definition at line 36 of file Body2DGrid.hpp.

◆ position

template<typename cell_t , class plugin_t >
MecaCell::Vector3D Grid2D::Body2DGrid< cell_t, plugin_t >::position
private

Definition at line 41 of file Body2DGrid.hpp.

◆ position2D

template<typename cell_t , class plugin_t >
Vec2D Grid2D::Body2DGrid< cell_t, plugin_t >::position2D = Vec2D(0, 0)
private

Position in the grid

Definition at line 35 of file Body2DGrid.hpp.

◆ prevposition

Vec MecaCell::Movable::prevposition = Vec::zero()
protectedinherited

Definition at line 9 of file movable.h.

◆ radius

template<typename cell_t , class plugin_t >
double Grid2D::Body2DGrid< cell_t, plugin_t >::radius = MecaCell::Config::DEFAULT_CELL_RADIUS
private

Definition at line 33 of file Body2DGrid.hpp.

◆ totalForce

double MecaCell::Movable::totalForce = 0
protectedinherited

Definition at line 14 of file movable.h.

◆ velocity

Vec MecaCell::Movable::velocity = Vec::zero()
protectedinherited

Definition at line 10 of file movable.h.


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