de.steeringbehaviors.simulation.simulationobjects
Class Simulation

java.lang.Object
  extended by de.steeringbehaviors.simulation.simulationobjects.Simulation
Direct Known Subclasses:
Neighborhood, PathFindingSimulation, VehicleInfoSimulation

public class Simulation
extends java.lang.Object

Simulation base class


Field Summary
protected  Geometrie m_background
          The background object
protected  java.util.Vector m_Obstacle
          Array with all the obstacles in the scene
protected  Simulation m_parent
          Reference to the parent simulation.
protected  java.util.Vector m_postSimulation
          Array with the simulation objects that have to run after the scene is recomputed
protected  java.util.Vector m_preSimulation
          Array with the simulation objects that have to run before the scene is recomputed
protected  java.util.Vector m_Scene
          Array with all the objects in the scene
protected  double m_sceneHeight
          The height of a scene in world coordinates
protected  double m_sceneWidth
          The width of a scene in world coordinates
protected  long m_simulationTime
          Contains the amount of time used for one simulation step in ms
protected  boolean m_useSceneConstraints
          Use this to test the vehicles for violation of scene constraints.
protected  java.util.Vector m_Vehicles
          Array with all the vehicles in the scene
protected  boolean m_wrapAround
          This flag is used to determine is vehicles start out on the other side of the scene, if they cross the boundary.
 
Constructor Summary
Simulation()
          Creates an empty simulation object.
 
Method Summary
 void addBackground(Geometrie newBackground)
          Adds a new background object to the scene description
 void addGeometrie(Geometrie geom)
          Adds a new background object to the scene description
 void addObstacle(Obstacle newObstacle)
          Adds a new obstacle to the scene description.
 void addPostSimulation(Simulation postSimulation)
          Adds a new post simulation step to the Simulation.
 void addPreSimulation(Simulation preSimulation)
          Adds a new pre-simulation step to the Simulation.
 void addVehicle(Vehicle newVehicle)
          Adds a new vehicle to the scene description.
 java.util.Vector getObstacle()
          Gives acces to the obstacles in the scene description
 Simulation getParent()
          Returns the parent simulation object.
 java.util.Vector getScene()
          Gives acces to the complete scene description
 long getSimulationTime()
          Returns the time in milliseconds used for the last simulation step
 java.util.Vector getVehicles()
          Gives acces to the vehicles in the scene description
 void removeAll()
          Removes all objects from the scene description.
 void removeGeometrie(Geometrie geom)
          Removes a Geometrie object from the scene description.
 void removeObstacle(Obstacle obst)
          Removes an Obstacle object from the scene description.
 void removeVehicle(Vehicle veh)
          Removes an Obstacle object from the scene description.
 void runSimulation()
          runSimulation is called to run a simulation step on all the vehicles and additional Simulations.
protected  void setParent(Simulation parent)
          Sets the parent simulation object.
 void setSceneHeight(double height)
          Sets the height of the scene in world coordinates.
 void setSceneWidth(double width)
          Sets the width of the scene in world coordinates.
 void setUseSceneConstraints(boolean useConstraints)
          Use this to turn the scene constraints on or off.
 void setWrapAround(boolean wrapAround)
          Toggles between constraining the vehicles inside the scene rectangle (wrapAround = false) and wrapping the vehicles
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_background

protected Geometrie m_background
The background object


m_Obstacle

protected java.util.Vector m_Obstacle
Array with all the obstacles in the scene


m_parent

protected Simulation m_parent
Reference to the parent simulation. Is null for the root simulation


m_preSimulation

protected java.util.Vector m_preSimulation
Array with the simulation objects that have to run before the scene is recomputed


m_postSimulation

protected java.util.Vector m_postSimulation
Array with the simulation objects that have to run after the scene is recomputed


m_Scene

protected java.util.Vector m_Scene
Array with all the objects in the scene


m_sceneWidth

protected double m_sceneWidth
The width of a scene in world coordinates


m_sceneHeight

protected double m_sceneHeight
The height of a scene in world coordinates


m_simulationTime

protected long m_simulationTime
Contains the amount of time used for one simulation step in ms


m_useSceneConstraints

protected boolean m_useSceneConstraints
Use this to test the vehicles for violation of scene constraints. For example if it is outside the scene boundary.


m_Vehicles

protected java.util.Vector m_Vehicles
Array with all the vehicles in the scene


m_wrapAround

protected boolean m_wrapAround
This flag is used to determine is vehicles start out on the other side of the scene, if they cross the boundary.

Constructor Detail

Simulation

public Simulation()
Creates an empty simulation object. Add scene objects and additional simulation steps afterwards.

Method Detail

addBackground

public void addBackground(Geometrie newBackground)
Adds a new background object to the scene description

Parameters:
newBackground - The background object to add to the scene

addGeometrie

public void addGeometrie(Geometrie geom)
Adds a new background object to the scene description

Parameters:
newBackground - The background object to add to the scene

addObstacle

public void addObstacle(Obstacle newObstacle)
Adds a new obstacle to the scene description. The obstacle is automatically added to all pre- and post-Simulations as well.

Parameters:
newObstacle - The obstacle object to add to the scene

addPostSimulation

public void addPostSimulation(Simulation postSimulation)
Adds a new post simulation step to the Simulation. The Simulation gets acces to the obstacles and vehicles already present in this Simulation automatically.

Parameters:
postSimulation - The simulation object to add

addPreSimulation

public void addPreSimulation(Simulation preSimulation)
Adds a new pre-simulation step to the Simulation. The Simulation gets acces to the obstacles and vehicles already present in this Simulation automatically.

Parameters:
preSimulation - The simulation object to add

addVehicle

public void addVehicle(Vehicle newVehicle)
Adds a new vehicle to the scene description. The vehicle is automatically added to all pre- and post-Simulations as well.

Parameters:
newVehicle - The vehicle object to add to the scene

removeAll

public void removeAll()
Removes all objects from the scene description. The pre- and post-simulations are also cleared of all objects


removeGeometrie

public void removeGeometrie(Geometrie geom)
Removes a Geometrie object from the scene description.

Parameters:
geom - The object to remove from the scene

removeObstacle

public void removeObstacle(Obstacle obst)
Removes an Obstacle object from the scene description. The object will also be removed from all pre- and post-simulations.

Parameters:
obst - The object to remove from the scene

removeVehicle

public void removeVehicle(Vehicle veh)
Removes an Obstacle object from the scene description. The object will also be removed from all pre- and post-simulations.

Parameters:
obst - The object to remove from the scene

setParent

protected void setParent(Simulation parent)
Sets the parent simulation object.

Parameters:
parent - The parent simulation

setSceneHeight

public void setSceneHeight(double height)
Sets the height of the scene in world coordinates. Negative values are ignored and leave the height unchanged.

Parameters:
height - The height of the scene

setSceneWidth

public void setSceneWidth(double width)
Sets the width of the scene in world coordinates. Negative values are ignored and leave the width unchanged.

Parameters:
width - The width of the scene

setUseSceneConstraints

public void setUseSceneConstraints(boolean useConstraints)
Use this to turn the scene constraints on or off. The constraints are based on the width and height of the scene. Use the setWrapAround function to toggle between constraining inside the rectangle, or wrapping around at the edges.

Parameters:
useConstraints - Turns constraints on or off

setWrapAround

public void setWrapAround(boolean wrapAround)
Toggles between constraining the vehicles inside the scene rectangle (wrapAround = false) and wrapping the vehicles

Parameters:
wrapAround - Turns wrapping around the scen on or off

getObstacle

public java.util.Vector getObstacle()
Gives acces to the obstacles in the scene description

Returns:
The obstacles used in this simulation

getParent

public Simulation getParent()
Returns the parent simulation object. For the root simulation this equals to null.

Returns:
The parent simulation

getScene

public java.util.Vector getScene()
Gives acces to the complete scene description

Returns:
The current scene

getSimulationTime

public long getSimulationTime()
Returns the time in milliseconds used for the last simulation step

Returns:
The time for the last simulation step in ms

getVehicles

public java.util.Vector getVehicles()
Gives acces to the vehicles in the scene description

Returns:
The vehicles used in this simulation

runSimulation

public void runSimulation()
runSimulation is called to run a simulation step on all the vehicles and additional Simulations. The idea of having a pre- and post simulation is, to allow additional simulation steps to be created and seamlessly plugged into the system.