The main class of the library. More...
#include <SimulationEngine.h>
Public Member Functions | |
SimulationEngine () | |
~SimulationEngine () | |
void | init (float xRange, float yRange) |
Initialization of the simulation engine. All characters in the library have the same time step. More... | |
void | updateSimulation () |
Performs a simulation/integration step i.e. updates the acceleration, velocity and position of the simulated characters. | |
bool | endSimulation () |
This function determines whether the simulation has to stop i.e. when all characters have reached their goals or the simulation steps have exceeded the maximum allowed number. More... | |
void | updateVisualisation () |
Outputs a simulation step in the console. | |
void | exportSimulation (std::ofstream &file) |
Outputs a simulation step in a file. More... | |
void | addAgent (AgentInitialParameters ¶meters) |
Add a new agent to the simulation given its default parameters. More... | |
void | addObstacle (const std::pair< Vector2D, Vector2D > &lineSegment) |
Add a new line obstacle to the simulation. More... | |
Get/Set functionality | |
SpatialProximityDatabase * | getSpatialDatabase () |
Returns a pointer to the proximity database of the engine. | |
const vector< Agent * > & | getAgents () |
Returns the list of agents in the simulation. | |
const vector< LineObstacle * > & | getObstacles () |
Returns the list of obstacles. | |
Agent * | getAgent (int id) |
Returns the corresponding agent given its id. More... | |
LineObstacle * | getObstacle (int id) |
Returns the corresponding line obstacle given its id. More... | |
float | getTimeStep () const |
Returns the time step of the simulation. | |
void | setTimeStep (float dt) |
Sets the time step of the simulation. More... | |
int | getMaxSteps () const |
Returns the number of simulations steps. | |
void | setMaxSteps (int steps) |
Sets the maximum number of simulation steps. More... | |
float | getGlobalTime () const |
Returns the global time of the simulation. Initially this time is set to zero. | |
int | getNumAgents () const |
Returns the number of agents in the simulation. | |
int | getIterationNumber () const |
Returns the current simulation step. | |
Protected Attributes | |
float | _dt |
The time step in the simulation. | |
float | _globalTime |
The current time in the simulation. | |
int | _iteration |
The current iteration step. | |
int | _maxSteps |
The maximum number of simulation steps. | |
bool | _reachedGoals |
Determine whether all agents have reached their goals. | |
SpatialProximityDatabase * | _spatialDatabase |
The proximity database. | |
vector< Agent * > | _agents |
The agents in the simulation. | |
vector< LineObstacle * > | _obstacles |
The obstacles in the simulation. | |
The main class of the library.
TTC::SimulationEngine::SimulationEngine | ( | ) |
Default Costructor.
TTC::SimulationEngine::~SimulationEngine | ( | ) |
Destructor.
void TTC::SimulationEngine::addAgent | ( | AgentInitialParameters & | parameters | ) |
Add a new agent to the simulation given its default parameters.
parameters | The agent's parameters |
Add a new line obstacle to the simulation.
lineSegment | The start and end point of the line segment |
bool TTC::SimulationEngine::endSimulation | ( | ) |
This function determines whether the simulation has to stop i.e. when all characters have reached their goals or the simulation steps have exceeded the maximum allowed number.
void TTC::SimulationEngine::exportSimulation | ( | std::ofstream & | file | ) |
Outputs a simulation step in a file.
file | The file for exporting the simulation. |
|
inline |
Returns the corresponding agent given its id.
id | The id of the agent. |
|
inline |
Returns the corresponding line obstacle given its id.
id | The id of the obstacle. |
void TTC::SimulationEngine::init | ( | float | xRange, |
float | yRange | ||
) |
Initialization of the simulation engine. All characters in the library have the same time step.
xRange | The range of the x-dimension of the environment. |
yRange | The range of the y-dimension of the environment. |
|
inline |
Sets the maximum number of simulation steps.
steps | The maximum number of simulation steps. |
|
inline |
Sets the time step of the simulation.
dt | The time step of the simulation. |