All Classes Namespaces Files Functions Variables Typedefs Pages
Public Member Functions | Protected Attributes | List of all members
TTC::SimulationEngine Class Reference

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 &parameters)
 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
SpatialProximityDatabasegetSpatialDatabase ()
 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.
 
AgentgetAgent (int id)
 Returns the corresponding agent given its id. More...
 
LineObstaclegetObstacle (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.
 

Detailed Description

The main class of the library.

Constructor & Destructor Documentation

TTC::SimulationEngine::SimulationEngine ( )

Default Costructor.

TTC::SimulationEngine::~SimulationEngine ( )

Destructor.

Member Function Documentation

void TTC::SimulationEngine::addAgent ( AgentInitialParameters parameters)

Add a new agent to the simulation given its default parameters.

Parameters
parametersThe agent's parameters
void TTC::SimulationEngine::addObstacle ( const std::pair< Vector2D, Vector2D > &  lineSegment)

Add a new line obstacle to the simulation.

Parameters
lineSegmentThe 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.

Returns
The function returns true when the simulation has to stop. False otherwise.
void TTC::SimulationEngine::exportSimulation ( std::ofstream &  file)

Outputs a simulation step in a file.

Parameters
fileThe file for exporting the simulation.
Agent* TTC::SimulationEngine::getAgent ( int  id)
inline

Returns the corresponding agent given its id.

Parameters
idThe id of the agent.
LineObstacle* TTC::SimulationEngine::getObstacle ( int  id)
inline

Returns the corresponding line obstacle given its id.

Parameters
idThe 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.

Parameters
xRangeThe range of the x-dimension of the environment.
yRangeThe range of the y-dimension of the environment.
void TTC::SimulationEngine::setMaxSteps ( int  steps)
inline

Sets the maximum number of simulation steps.

Parameters
stepsThe maximum number of simulation steps.
void TTC::SimulationEngine::setTimeStep ( float  dt)
inline

Sets the time step of the simulation.

Parameters
dtThe time step of the simulation.

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