CellModules
PrimoCell< B > Class Template Reference

Represents a cell in the simulation. More...

#include <PrimoCell.hpp>

Inheritance diagram for PrimoCell< B >:
MecaCell::ConnectableCell< PrimoCell< B >, B >

Public Types

using Cell = PrimoCell
 
using World = MecaCell::World< PrimoCell< B > >
 
using body_t = B< PrimoCell< B > >
 
using embedded_plugin_t = typename body_t::embedded_plugin_t
 

Public Member Functions

void setWorld (World *w)
 Sets the world for the cell. More...
 
 PrimoCell (const MecaCell::Vec &v, Model *m)
 Constructs a PrimoCell with a position and model. More...
 
 PrimoCell (Model *m)
 Constructs a PrimoCell with a model. More...
 
 PrimoCell (PrimoCell< B > *mother)
 Constructs a PrimoCell from a mother cell. More...
 
void init ()
 Initializes the cell. More...
 
ModelgetModel () const
 @ignore More...
 
Type getType () const
 Gets the type of the cell. More...
 
void setType (Type t)
 Sets the type of the cell and modifies parameters accordingly. More...
 
State getState ()
 Gets the state of the cell. More...
 
void setState (State s)
 Sets the state of the cell. More...
 
double getRadius ()
 Gets the radius of the cell. More...
 
void setRadius (const double &_radius)
 Sets the radius of the cell. More...
 
void setPosition (const MecaCell::Vec &_pos)
 Sets the position of the cell. More...
 
bool isType (Type t)
 Checks if the cell is of a specific type. More...
 
bool isInContactWith (Type t)
 Checks if the cell is in contact with a cell of a specific type. More...
 
int countNeighborType (Type t)
 Counts the number of neighboring cells of a specific type. More...
 
bool isInContact ()
 Checks if the cell is in contact with any other cell. More...
 
void updateBehavior ()
 @ignore More...
 
int getId () const
 Gets the ID of the cell. More...
 
int getMotherId () const
 Gets the mother ID of the cell. More...
 
const PreSetCellgetParametersFrom (Type type) const
 Gets the parameters for a specific cell type. More...
 
void eraseConnectedCell (PrimoCell< B > *cell)
 disconnect a neighboring cell More...
 
void addConnectedCell (PrimoCell< B > *c)
 
void clearConnectedCells ()
 
bool isConnectedTo (PrimoCell< B > *c)
 
void die ()
 flags the cell as dead so it can be cleanly removed from the world More...
 
bool isDead ()
 
Vector3D getPosition () const
 
void setColorRGB (size_t r, size_t g, size_t b)
 
void setColorRGB (std::array< int, 3 > rgb)
 
void setColorRGB (std::array< double, 3 > rgb)
 
void setColorHSV (double H, double S, double V)
 
void setColorHSV (std::array< double, 3 > hsv)
 
void setVisible (bool v)
 should a viewer displpay this cell ? More...
 
string toString ()
 dumps internal infos More...
 
body_tgetBody ()
 
const body_tgetConstBody () const
 
double getBoundingBoxRadius () const
 
double getColor (unsigned int i) const
 
const std::vector< PrimoCell< B > * > & getConnectedCells () const
 
bool getVisible ()
 
int getNbConnections () const
 
 EXPORTABLE (ConnectableCell, KV(body), KV(id))
 

Public Attributes

int mother_id = -1
 @ignore More...
 
friend body_t
 
friend embedded_plugin_t
 
size_t id
 

Protected Member Functions

PrimoCell< B > * selfptr ()
 
PrimoCell< B > & self ()
 
const PrimoCell< B > & selfconst () const
 

Protected Attributes

body_t body
 
bool dead
 
bool isVisible
 
array< double, 3 > color
 
unique_vector< PrimoCell< B > * > connectedCells
 

Private Types

using Base = MecaCell::ConnectableCell< PrimoCell< B >, B >
 

Private Member Functions

void behave ()
 @ignore More...
 
void nextState ()
 @ignore More...
 
CellcreateCell ()
 Creates a new cell. More...
 
CellcreateCell (Type t)
 Creates a new cell of a specific type. More...
 

Private Attributes

Modelmodel
 @ignore More...
 
Type type
 
State state
 
Worldworld
 
bool _alreadyNextState = false
 @ignore More...
 
bool _firstInit = true
 @ignore More...
 

Detailed Description

template<template< typename > class B>
class PrimoCell< B >

Represents a cell in the simulation.

Template Parameters
BThe base class template.

Definition at line 58 of file PrimoCell.hpp.

Member Typedef Documentation

◆ Base

template<template< typename > class B>
using PrimoCell< B >::Base = MecaCell::ConnectableCell<PrimoCell<B>, B>
private

Definition at line 59 of file PrimoCell.hpp.

◆ body_t

using MecaCell::ConnectableCell< PrimoCell< B > , B >::body_t = B <PrimoCell< B > >
inherited

Definition at line 36 of file connectablecell.hpp.

◆ Cell

template<template< typename > class B>
using PrimoCell< B >::Cell = PrimoCell

Definition at line 61 of file PrimoCell.hpp.

◆ embedded_plugin_t

using MecaCell::ConnectableCell< PrimoCell< B > , B >::embedded_plugin_t = typename body_t::embedded_plugin_t
inherited

Definition at line 37 of file connectablecell.hpp.

◆ World

template<template< typename > class B>
using PrimoCell< B >::World = MecaCell::World<PrimoCell<B> >

Definition at line 62 of file PrimoCell.hpp.

Constructor & Destructor Documentation

◆ PrimoCell() [1/3]

template<template< typename > class B>
PrimoCell< B >::PrimoCell ( const MecaCell::Vec v,
Model m 
)
inline

Constructs a PrimoCell with a position and model.

Parameters
vThe position vector.
mPointer to the model.

Definition at line 178 of file PrimoCell.hpp.

◆ PrimoCell() [2/3]

template<template< typename > class B>
PrimoCell< B >::PrimoCell ( Model m)
inline

Constructs a PrimoCell with a model.

Parameters
mPointer to the model.

Definition at line 189 of file PrimoCell.hpp.

◆ PrimoCell() [3/3]

template<template< typename > class B>
PrimoCell< B >::PrimoCell ( PrimoCell< B > *  mother)
inline

Constructs a PrimoCell from a mother cell.

Parameters
motherPointer to the mother cell.

Definition at line 200 of file PrimoCell.hpp.

Member Function Documentation

◆ addConnectedCell()

void MecaCell::ConnectableCell< PrimoCell< B > , B >::addConnectedCell ( PrimoCell< B > *  c)
inlineinherited

Definition at line 70 of file connectablecell.hpp.

◆ behave()

template<template< typename > class B>
void PrimoCell< B >::behave ( )
inlineprivate

@ignore

Definition at line 76 of file PrimoCell.hpp.

◆ clearConnectedCells()

void MecaCell::ConnectableCell< PrimoCell< B > , B >::clearConnectedCells ( )
inlineinherited

Definition at line 71 of file connectablecell.hpp.

◆ countNeighborType()

template<template< typename > class B>
int PrimoCell< B >::countNeighborType ( Type  t)
inline

Counts the number of neighboring cells of a specific type.

Parameters
tThe type to count.
Returns
The number of neighboring cells of the specified type.

Definition at line 303 of file PrimoCell.hpp.

◆ createCell() [1/2]

template<template< typename > class B>
Cell * PrimoCell< B >::createCell ( )
inlineprivate

Creates a new cell.

The new cell is initialized with the same Type as the mother cell and added to the world.

Returns
Pointer to the newly created cell.

Definition at line 116 of file PrimoCell.hpp.

◆ createCell() [2/2]

template<template< typename > class B>
Cell * PrimoCell< B >::createCell ( Type  t)
inlineprivate

Creates a new cell of a specific type.

The new cell is initialized with the specified type and added to the world.

Parameters
tThe type of the new cell.
Returns
Pointer to the newly created cell.

Definition at line 135 of file PrimoCell.hpp.

◆ die()

void MecaCell::ConnectableCell< PrimoCell< B > , B >::die ( )
inlineinherited

flags the cell as dead so it can be cleanly removed from the world

Definition at line 118 of file connectablecell.hpp.

◆ eraseConnectedCell()

void MecaCell::ConnectableCell< PrimoCell< B > , B >::eraseConnectedCell ( PrimoCell< B > *  cell)
inlineinherited

disconnect a neighboring cell

removes it from the connectedCells contianer

Parameters
cellpointer to the cell to be disconnected

Definition at line 69 of file connectablecell.hpp.

◆ EXPORTABLE()

MecaCell::ConnectableCell< PrimoCell< B > , B >::EXPORTABLE ( ConnectableCell< PrimoCell< B >, B >  ,
KV(body ,
KV(id  
)
inherited

◆ getBody()

body_t & MecaCell::ConnectableCell< PrimoCell< B > , B >::getBody ( )
inlineinherited

Definition at line 152 of file connectablecell.hpp.

◆ getBoundingBoxRadius()

double MecaCell::ConnectableCell< PrimoCell< B > , B >::getBoundingBoxRadius ( ) const
inlineinherited

Definition at line 154 of file connectablecell.hpp.

◆ getColor()

double MecaCell::ConnectableCell< PrimoCell< B > , B >::getColor ( unsigned int  i) const
inlineinherited

Definition at line 155 of file connectablecell.hpp.

◆ getConnectedCells()

const std::vector< PrimoCell< B > * > & MecaCell::ConnectableCell< PrimoCell< B > , B >::getConnectedCells ( ) const
inlineinherited

Definition at line 159 of file connectablecell.hpp.

◆ getConstBody()

const body_t & MecaCell::ConnectableCell< PrimoCell< B > , B >::getConstBody ( ) const
inlineinherited

Definition at line 153 of file connectablecell.hpp.

◆ getId()

template<template< typename > class B>
int PrimoCell< B >::getId ( ) const
inline

Gets the ID of the cell.

Returns
The ID of the cell.

Definition at line 329 of file PrimoCell.hpp.

◆ getModel()

template<template< typename > class B>
Model * PrimoCell< B >::getModel ( ) const
inline

@ignore

Definition at line 226 of file PrimoCell.hpp.

◆ getMotherId()

template<template< typename > class B>
int PrimoCell< B >::getMotherId ( ) const
inline

Gets the mother ID of the cell.

Returns
The mother ID of the cell.

Definition at line 336 of file PrimoCell.hpp.

◆ getNbConnections()

int MecaCell::ConnectableCell< PrimoCell< B > , B >::getNbConnections ( ) const
inlineinherited

Definition at line 163 of file connectablecell.hpp.

◆ getParametersFrom()

template<template< typename > class B>
const PreSetCell & PrimoCell< B >::getParametersFrom ( Type  type) const
inline

Gets the parameters for a specific cell type.

Parameters
typeThe type of the cell.
Returns
The parameters for the specified cell type.

Definition at line 345 of file PrimoCell.hpp.

◆ getPosition()

Vector3D MecaCell::ConnectableCell< PrimoCell< B > , B >::getPosition ( ) const
inlineinherited

Definition at line 120 of file connectablecell.hpp.

◆ getRadius()

template<template< typename > class B>
double PrimoCell< B >::getRadius ( )
inline

Gets the radius of the cell.

Returns
The radius of the cell.

Definition at line 261 of file PrimoCell.hpp.

◆ getState()

template<template< typename > class B>
State PrimoCell< B >::getState ( )
inline

Gets the state of the cell.

Returns
The state of the cell.

Definition at line 247 of file PrimoCell.hpp.

◆ getType()

template<template< typename > class B>
Type PrimoCell< B >::getType ( ) const
inline

Gets the type of the cell.

Returns
The type of the cell.

Definition at line 233 of file PrimoCell.hpp.

◆ getVisible()

bool MecaCell::ConnectableCell< PrimoCell< B > , B >::getVisible ( )
inlineinherited

Definition at line 162 of file connectablecell.hpp.

◆ init()

template<template< typename > class B>
void PrimoCell< B >::init ( )
inline

Initializes the cell.

This function resets the cell's parameters and calls the code inside the "Cell Instantiation".

Definition at line 212 of file PrimoCell.hpp.

◆ isConnectedTo()

bool MecaCell::ConnectableCell< PrimoCell< B > , B >::isConnectedTo ( PrimoCell< B > *  c)
inlineinherited

Definition at line 72 of file connectablecell.hpp.

◆ isDead()

bool MecaCell::ConnectableCell< PrimoCell< B > , B >::isDead ( )
inlineinherited

Definition at line 119 of file connectablecell.hpp.

◆ isInContact()

template<template< typename > class B>
bool PrimoCell< B >::isInContact ( )
inline

Checks if the cell is in contact with any other cell.

Returns
True if the cell is in contact with any other cell, false otherwise.

Definition at line 315 of file PrimoCell.hpp.

◆ isInContactWith()

template<template< typename > class B>
bool PrimoCell< B >::isInContactWith ( Type  t)
inline

Checks if the cell is in contact with a cell of a specific type.

Parameters
tThe type to check.
Returns
True if the cell is in contact with a cell of the specified type, false otherwise.

Definition at line 291 of file PrimoCell.hpp.

◆ isType()

template<template< typename > class B>
bool PrimoCell< B >::isType ( Type  t)
inline

Checks if the cell is of a specific type.

Parameters
tThe type to check.
Returns
True if the cell is of the specified type, false otherwise.

Definition at line 283 of file PrimoCell.hpp.

◆ nextState()

template<template< typename > class B>
void PrimoCell< B >::nextState ( )
inlineprivate

@ignore

Definition at line 93 of file PrimoCell.hpp.

◆ self()

PrimoCell< B > & MecaCell::ConnectableCell< PrimoCell< B > , B >::self ( )
inlineprotectedinherited

Definition at line 58 of file connectablecell.hpp.

◆ selfconst()

const PrimoCell< B > & MecaCell::ConnectableCell< PrimoCell< B > , B >::selfconst ( ) const
inlineprotectedinherited

Definition at line 59 of file connectablecell.hpp.

◆ selfptr()

PrimoCell< B > * MecaCell::ConnectableCell< PrimoCell< B > , B >::selfptr ( )
inlineprotectedinherited

Definition at line 57 of file connectablecell.hpp.

◆ setColorHSV() [1/2]

void MecaCell::ConnectableCell< PrimoCell< B > , B >::setColorHSV ( double  H,
double  S,
double  V 
)
inlineinherited

Definition at line 128 of file connectablecell.hpp.

◆ setColorHSV() [2/2]

void MecaCell::ConnectableCell< PrimoCell< B > , B >::setColorHSV ( std::array< double, 3 >  hsv)
inlineinherited

Definition at line 129 of file connectablecell.hpp.

◆ setColorRGB() [1/3]

void MecaCell::ConnectableCell< PrimoCell< B > , B >::setColorRGB ( size_t  r,
size_t  g,
size_t  b 
)
inlineinherited

Definition at line 122 of file connectablecell.hpp.

◆ setColorRGB() [2/3]

void MecaCell::ConnectableCell< PrimoCell< B > , B >::setColorRGB ( std::array< double, 3 >  rgb)
inlineinherited

Definition at line 127 of file connectablecell.hpp.

◆ setColorRGB() [3/3]

void MecaCell::ConnectableCell< PrimoCell< B > , B >::setColorRGB ( std::array< int, 3 >  rgb)
inlineinherited

Definition at line 126 of file connectablecell.hpp.

◆ setPosition()

template<template< typename > class B>
void PrimoCell< B >::setPosition ( const MecaCell::Vec _pos)
inline

Sets the position of the cell.

Parameters
_posThe position vector.

Definition at line 275 of file PrimoCell.hpp.

◆ setRadius()

template<template< typename > class B>
void PrimoCell< B >::setRadius ( const double &  _radius)
inline

Sets the radius of the cell.

Parameters
_radiusThe radius to set.

Definition at line 268 of file PrimoCell.hpp.

◆ setState()

template<template< typename > class B>
void PrimoCell< B >::setState ( State  s)
inline

Sets the state of the cell.

Parameters
sThe state to set.

Definition at line 254 of file PrimoCell.hpp.

◆ setType()

template<template< typename > class B>
void PrimoCell< B >::setType ( Type  t)
inline

Sets the type of the cell and modifies parameters accordingly.

Parameters
tThe type to set.

Definition at line 240 of file PrimoCell.hpp.

◆ setVisible()

void MecaCell::ConnectableCell< PrimoCell< B > , B >::setVisible ( bool  v)
inlineinherited

should a viewer displpay this cell ?

Parameters
v

Definition at line 136 of file connectablecell.hpp.

◆ setWorld()

template<template< typename > class B>
void PrimoCell< B >::setWorld ( World w)
inline

Sets the world for the cell.

Parameters
wPointer to the world.

Definition at line 155 of file PrimoCell.hpp.

◆ toString()

string MecaCell::ConnectableCell< PrimoCell< B > , B >::toString ( )
inlineinherited

dumps internal infos

Returns
a formatted string

Definition at line 143 of file connectablecell.hpp.

◆ updateBehavior()

template<template< typename > class B>
void PrimoCell< B >::updateBehavior ( )
inline

@ignore

Definition at line 318 of file PrimoCell.hpp.

Member Data Documentation

◆ _alreadyNextState

template<template< typename > class B>
bool PrimoCell< B >::_alreadyNextState = false
private

@ignore

Definition at line 70 of file PrimoCell.hpp.

◆ _firstInit

template<template< typename > class B>
bool PrimoCell< B >::_firstInit = true
private

@ignore

Definition at line 72 of file PrimoCell.hpp.

◆ body

body_t MecaCell::ConnectableCell< PrimoCell< B > , B >::body
protectedinherited

Definition at line 43 of file connectablecell.hpp.

◆ body_t

friend MecaCell::ConnectableCell< PrimoCell< B > , B >::body_t
inherited

Definition at line 39 of file connectablecell.hpp.

◆ color

array<double, 3> MecaCell::ConnectableCell< PrimoCell< B > , B >::color
protectedinherited

Definition at line 51 of file connectablecell.hpp.

◆ connectedCells

unique_vector<PrimoCell< B > *> MecaCell::ConnectableCell< PrimoCell< B > , B >::connectedCells
protectedinherited

Definition at line 54 of file connectablecell.hpp.

◆ dead

bool MecaCell::ConnectableCell< PrimoCell< B > , B >::dead
protectedinherited

Definition at line 44 of file connectablecell.hpp.

◆ embedded_plugin_t

Definition at line 40 of file connectablecell.hpp.

◆ id

size_t MecaCell::ConnectableCell< PrimoCell< B > , B >::id
inherited

Definition at line 74 of file connectablecell.hpp.

◆ isVisible

bool MecaCell::ConnectableCell< PrimoCell< B > , B >::isVisible
protectedinherited

Definition at line 49 of file connectablecell.hpp.

◆ model

template<template< typename > class B>
Model* PrimoCell< B >::model
private

@ignore

Definition at line 65 of file PrimoCell.hpp.

◆ mother_id

template<template< typename > class B>
int PrimoCell< B >::mother_id = -1

@ignore

Definition at line 148 of file PrimoCell.hpp.

◆ state

template<template< typename > class B>
State PrimoCell< B >::state
private

Definition at line 67 of file PrimoCell.hpp.

◆ type

template<template< typename > class B>
Type PrimoCell< B >::type
private

Definition at line 66 of file PrimoCell.hpp.

◆ world

template<template< typename > class B>
World* PrimoCell< B >::world
private

Definition at line 68 of file PrimoCell.hpp.


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