BioDynaMo
v1.05.120-25dc9790
|
Go to the documentation of this file.
24 #include <type_traits>
25 #include <unordered_map>
49 box_idx_(other.box_idx_),
50 run_behavior_loop_idx_(other.run_behavior_loop_idx_),
51 propagate_staticness_neighborhood_(
52 other.propagate_staticness_neighborhood_),
53 is_static_next_ts_(other.is_static_next_ts_) {
66 box_idx_ =
event.existing_agent->GetBoxIdx();
89 if (!beginning &&
GetDiameter() > env->GetLargestAgentSize()) {
100 auto set_staticness =
L2F([
this](
Agent* neighbor,
real_t squared_distance) {
103 if (squared_distance < distance * distance) {
107 env->ForEachNeighbor(set_staticness, *
this,
108 env->GetLargestAgentSizeSquared());
135 for (
unsigned int i = 0; i <
behaviors_.size(); i++) {
164 const auto& existing_agent_behaviors =
event.existing_agent->behaviors_;
165 event.new_behaviors.clear();
167 for (
auto* behavior : existing_agent_behaviors) {
168 if (behavior->WillBeCopied(event.
GetUid())) {
169 event.new_behaviors.clear();
172 event.new_behaviors.push_back(nagent->behaviors_[cnt]);
174 event.existing_behavior = behavior;
175 auto* new_behavior = behavior->New();
176 new_behavior->Initialize(event);
187 bool copied = behavior->WillBeCopied(event.
GetUid());
188 if (!behavior->WillBeRemoved(event.
GetUid())) {
189 event.new_behaviors.clear();
192 auto* new_behavior = new_agent->behaviors_[cnt];
193 event.new_behaviors.push_back(new_behavior);
196 behavior->Update(event);
198 cnt += copied ? 1 : 0;
203 auto* behavior = *it;
204 if (behavior->WillBeRemoved(event.
GetUid())) {
void SetStaticnessNextTimestep(bool value) const
void InitializeBehaviors(const NewAgentEvent &event)
void RunBehaviors()
Execute all behaviorsq.
void UpdateBehaviors(const NewAgentEvent &event)
Function to invoke the Update method of the behavior or remove it from current. Forwards the call to ...
virtual void RemoveFromSimulation()
bool is_static_
If an agent is static, we should not compute the mechanical forces.
virtual void Initialize(const NewAgentEvent &event)
const InlineVector< Behavior *, 2 > & GetAllBehaviors() const
Return all behaviors.
const AgentUid & GetUid() const
virtual real_t GetDiameter() const =0
void SetPropagateStaticness(bool value=true)
bool is_static_next_ts_
Flag to determine of an agent is static in the next timestep.
LambdaFunctor< decltype(&TLambda::operator())> L2F(const TLambda &l)
Contains code required by all agents.
uint16_t run_behavior_loop_idx_
void SetBoxIdx(uint32_t idx)
virtual void RunDiscretization()
InlineVector< Agent *, 3 > new_agents
AgentUidGenerator * GetAgentUidGenerator()
void AddBehavior(Behavior *behavior)
Add a behavior to this agent.
uint32_t GetBoxIdx() const
bool propagate_staticness_neighborhood_
ExecutionContext * GetExecutionContext()
Returns a thread local execution context.
Environment * GetEnvironment()
InlineVector< Behavior *, 2 > behaviors_
collection of behaviors which define the internal behavior
virtual NewAgentEventUid GetUid() const =0
virtual void Update(const NewAgentEvent &event)
void RemoveBehavior(const Behavior *behavior)
const Param * GetParam() const
Returns the simulation parameters.
void PropagateStaticness(bool beginning=false)
static Simulation * GetActive()
This function returns the currently active Simulation simulation.
uint32_t box_idx_
Grid box index.
virtual void RemoveAgent(const AgentUid &uid)=0