O --- O
libPEDSIM Documentation
[HOME] [EXAMPLES] [ECOSYSTEM] [DOCUMENTATION] [DOWNLOAD]
O --- O
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Ped::Tscene Class Reference

#include <ped_scene.h>

Public Member Functions

 Tscene ()
 
 Tscene (double left, double top, double width, double height)
 
virtual ~Tscene ()
 
virtual void clear ()
 
virtual void addAgent (Tagent *a)
 
virtual void addObstacle (Tobstacle *o)
 
virtual void addWaypoint (Twaypoint *w)
 
virtual bool removeAgent (Tagent *a)
 
virtual bool removeObstacle (Tobstacle *o)
 
virtual bool removeWaypoint (Twaypoint *w)
 
virtual void cleanup ()
 
virtual void moveAgents (double h)
 
set< const Ped::Tagent * > getNeighbors (double x, double y, double dist) const
 
const vector< Tagent * > & getAllAgents () const
 
const vector< Tobstacle * > & getAllObstacles () const
 
const vector< Twaypoint * > & getAllWaypoints () const
 
void setOutputWriter (OutputWriter *ow)
 

Protected Member Functions

void placeAgent (const Ped::Tagent *a)
 
void moveAgent (const Ped::Tagent *a)
 
void getNeighbors (list< const Ped::Tagent * > &neighborList, double x, double y, double dist) const
 

Protected Attributes

vector< Tagent * > agents
 
vector< Tobstacle * > obstacles
 
vector< Twaypoint * > waypoints
 
Ttreetree
 
long int timestep
 

Friends

class Ped::Tagent
 
class Ped::Ttree
 

Detailed Description

The Tscene class contains the spatial representation of the "world" the agents live in. Theoretically, in a continuous model, there are no boundaries to the size of the world. Agents know their position (the x/y co-ordinates). However, to find the nearest neighbors of an agent, it makes sense to put them in some kind of "boxes". In this implementation, the infinite world is divided by a dynamic quadtree structure. There are some CPU cycles required to update the structure with each agent position change. But the gain in looking up the neighbors is worth this. The quadtree structure only needs to be changed when an agent leaves its box, which might only happen every 100th or 1000th timestep, depending on the box size. The Tscene class needs an outer boundary in order to construct the initial box of the quadtree. Agents are not allowed to go outside that boundary. If you do not know how far they will walk, choose a rather big boundary box. The quadtree algorythm will dynamically assign smaller sub-boxes within if required. If all (most) agents walk out of a box, it is no longer needed. It can be colleted. If there are some agents left, they will be assigned to the box above in the hierarchy. You must trigger this collection process periodically by calling cleanup() manually.

Author
chgloor
Date
2010-02-12
Examples:
examples/example01.cpp, examples/example02.cpp, examples/example03.cpp, examples/example04.cpp, and examples/example05.cpp.

Definition at line 68 of file ped_scene.h.

Constructor & Destructor Documentation

Ped::Tscene::Tscene ( )

Default constructor. If this constructor is used, there will be no quadtree created. This is faster for small scenarios or less than 1000 Tagents.

Date
2012-01-17

Definition at line 23 of file ped_scene.cpp.

Ped::Tscene::Tscene ( double  left,
double  top,
double  width,
double  height 
)

Constructor used to create a quadtree statial representation of the Tagents. Use this constructor when you have a sparsely populated world with many agents (>1000). The agents must not be outside the boundaries given here. If in doubt, use an initial boundary that is way to big.

Definition at line 36 of file ped_scene.cpp.

Ped::Tscene::~Tscene ( )
virtual

Destructor

Date
2012-02-04

Definition at line 42 of file ped_scene.cpp.

Member Function Documentation

void Ped::Tscene::addAgent ( Ped::Tagent a)
virtual

Used to add a Tagent to the Tscene.

Date
2012-01-17
Warning
addAgent() does call Tagent::setscene() to assign itself to the agent.
Parameters
*aA pointer to the Tagent to add.
Examples:
examples/example01.cpp, examples/example02.cpp, examples/example03.cpp, examples/example04.cpp, and examples/example05.cpp.

Definition at line 71 of file ped_scene.cpp.

void Ped::Tscene::addObstacle ( Ped::Tobstacle o)
virtual

Used to add a Tobstacle to the Tscene.

Date
2012-01-17
Parameters
*oA pointer to the Tobstacle to add.
Note
Obstacles added to the Scene are not deleted if the Scene is destroyed. The reason for this is because they could be member of another Scene theoretically.
Examples:
examples/example01.cpp, examples/example02.cpp, examples/example03.cpp, examples/example04.cpp, and examples/example05.cpp.

Definition at line 84 of file ped_scene.cpp.

void Ped::Tscene::cleanup ( )
virtual

This triggers a cleanup of the tree structure. Unused leaf nodes are collected in order to save memory. Ideally cleanup() is called every second, or about every 20 timestep.

Date
2012-01-28

Definition at line 205 of file ped_scene.cpp.

set< const Ped::Tagent * > Ped::Tscene::getNeighbors ( double  x,
double  y,
double  dist 
) const

Returns the list of neighbors within dist of the point x/y. This can be the position of an agent, but it is not limited to this.

Date
2012-01-29
Returns
The list of neighbors
Parameters
xthe x coordinate
ythe y coordinate
distthe distance around x/y that will be searched for agents (search field is a square in the current implementation)

Definition at line 217 of file ped_scene.cpp.

void Ped::Tscene::moveAgent ( const Ped::Tagent a)
protected

Moves a Tagent within the tree structure. The new position is taken from the agent. So it basically updates the tree structure for that given agent. Ped::Tagent::move(double h) calls this method automatically.

Date
2012-01-28
Parameters
*athe agent to move.

Definition at line 197 of file ped_scene.cpp.

void Ped::Tscene::moveAgents ( double  h)
virtual

This is a convenience method. It calls Ped::Tagent::move(double h) for all agents in the Tscene.

Date
2012-02-03
Parameters
hThis tells the simulation how far the agents should proceed.
See Also
Ped::Tagent::move(double h)
Examples:
examples/example01.cpp, examples/example02.cpp, examples/example03.cpp, examples/example04.cpp, and examples/example05.cpp.

Definition at line 167 of file ped_scene.cpp.

void Ped::Tscene::placeAgent ( const Ped::Tagent a)
protected

Internally used to update the quadtree.

Date
2012-01-28
Parameters

Definition at line 187 of file ped_scene.cpp.

bool Ped::Tscene::removeAgent ( Ped::Tagent a)
virtual

Remove an agent from the scene.

Warning
Used to delete the agent. I don't think Tscene has ownership of the assigned objects. Will not delete from now on.

Definition at line 109 of file ped_scene.cpp.

bool Ped::Tscene::removeObstacle ( Ped::Tobstacle o)
virtual

Remove an obstacle from the scene.

Warning
Used to delete the obstacle. I don't think Tscene has ownership of the assigned objects. Will not delete from now on.

Definition at line 132 of file ped_scene.cpp.

bool Ped::Tscene::removeWaypoint ( Ped::Twaypoint w)
virtual

Remove a waypoint from the scene.

Warning
Used to delete the waypoint. I don't think Tscene has ownership of the assigned objects. Will not delete from now on.

Definition at line 144 of file ped_scene.cpp.


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

⁠(c) Christian Gloor [ c|h|g|l|o|o|r|@|s|i|l|m|a|r|i|l|.|o|r|g| ]