CellModules
basecell.hpp
Go to the documentation of this file.
1
#ifndef MECACELL_BASECELL_HPP
2
#define MECACELL_BASECELL_HPP
3
4
/*----------------------------------------------------------------------------*\
5
| |
6
| MecaCell::BaseCell |
7
| |
8
\*----------------------------------------------------------------------------*/
21
template
<
class
Derived,
template
<
class
>
class
Body = ContactSurfaceBody>
22
class
BaseCell
{
23
public
:
24
using
body_t
= Body<Derived>;
25
using
embedded_plugin_t
=
typename
body_t::embedded_plugin_t
;
26
using
vec_t
=
decltype
((
body_t
) nullptr->getPosition());
27
28
friend
body_t
;
29
friend
embedded_plugin_t
;
30
31
protected
:
32
body_t
body
;
// body contains cell physics implementation
33
bool
dead
=
false
;
// when a cell is dead it is flagged for destruction
34
35
public
:
36
/*----------------------------------------------------------------------------*\
37
| CONSTRUCTORS |
38
\*----------------------------------------------------------------------------*/
39
BaseCell
(
const
Derived &c) :
body
(static_cast<Derived *>(this)) {}
40
BaseCell
(
const
vec_t
&
pos
) :
body
(static_cast<Derived *>(this),
pos
) {}
41
42
/*----------------------------------------------------------------------------*\
43
| ID |
44
\*----------------------------------------------------------------------------*/
45
// A cell should have a unique id in its world, mostly for determinism & debugging
46
// purposes. Usually matches the order of insertion in the world.
47
size_t
id
= 0;
48
size_t
getId
() {
return
id
; }
49
50
/*----------------------------------------------------------------------------*\
51
| UTILITIES |
52
\*----------------------------------------------------------------------------*/
53
void
die
() {
dead
=
true
; }
// flag the cell for destruction
54
bool
isDead
() {
return
dead
; }
// simple getter
55
vec_t
getPosition
() {
return
body
.getPosition(); }
56
};
57
58
#endif
pos
MecaCell::Vec pos
Definition:
CellBody.hpp:34
embedded_plugin_t
CellPlugin< cell_t > embedded_plugin_t
Definition:
CellBody.hpp:39
BaseCell
Basis for every cell a user might want to use.
Definition:
basecell.hpp:22
BaseCell::die
void die()
Definition:
basecell.hpp:53
BaseCell::body
body_t body
Definition:
basecell.hpp:32
BaseCell::embedded_plugin_t
typename body_t::embedded_plugin_t embedded_plugin_t
Definition:
basecell.hpp:25
BaseCell::body_t
friend body_t
Definition:
basecell.hpp:28
BaseCell::id
size_t id
Definition:
basecell.hpp:47
BaseCell::embedded_plugin_t
friend embedded_plugin_t
Definition:
basecell.hpp:29
BaseCell::dead
bool dead
Definition:
basecell.hpp:33
BaseCell::body_t
Body< Derived > body_t
Definition:
basecell.hpp:24
BaseCell::vec_t
decltype((body_t) nullptr->getPosition()) vec_t
Definition:
basecell.hpp:26
BaseCell::getId
size_t getId()
Definition:
basecell.hpp:48
BaseCell::getPosition
vec_t getPosition()
Definition:
basecell.hpp:55
BaseCell::isDead
bool isDead()
Definition:
basecell.hpp:54
BaseCell::BaseCell
BaseCell(const Derived &c)
Definition:
basecell.hpp:39
BaseCell::BaseCell
BaseCell(const vec_t &pos)
Definition:
basecell.hpp:40
external
MecaCell
mecacell
basecell.hpp
Generated by
1.9.4