Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SimulatorInterface.h
Go to the documentation of this file.
1 /*
2 
3 License
4 
5 Menge
6 Copyright © and trademark ™ 2012-14 University of North Carolina at Chapel Hill.
7 All rights reserved.
8 
9 Permission to use, copy, modify, and distribute this software and its documentation
10 for educational, research, and non-profit purposes, without fee, and without a
11 written agreement is hereby granted, provided that the above copyright notice,
12 this paragraph, and the following four paragraphs appear in all copies.
13 
14 This software program and documentation are copyrighted by the University of North
15 Carolina at Chapel Hill. The software program and documentation are supplied "as is,"
16 without any accompanying services from the University of North Carolina at Chapel
17 Hill or the authors. The University of North Carolina at Chapel Hill and the
18 authors do not warrant that the operation of the program will be uninterrupted
19 or error-free. The end-user understands that the program was developed for research
20 purposes and is advised not to rely exclusively on the program for any reason.
21 
22 IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE AUTHORS
23 BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
24 DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
25 DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL OR THE
26 AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS SPECIFICALLY
29 DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY STATUTORY WARRANTY
31 OF NON-INFRINGEMENT. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
32 THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL AND THE AUTHORS HAVE NO OBLIGATIONS
33 TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
34 
35 Any questions or comments should be sent to the authors {menge,geom}@cs.unc.edu
36 
37 */
38 
44 #ifndef __SIMULATOR_INTERFACE_H__
45 #define __SIMULATOR_INTERFACE_H__
46 
47 #include "CoreConfig.h"
48 #include "XMLSimulatorBase.h"
49 #include "Math/Vector2.h"
50 using namespace Menge::Math;
51 #include <vector>
52 #include "Core.h"
53 
54 namespace Menge {
55 
56  namespace Agents {
57  // forward declaration
58  class BaseAgent;
59  class SpatialQuery;
60  class Obstacle;
61  class Elevation;
62 
66  class MENGE_API SimulatorInterface: public XMLSimulatorBase {
67  public:
72 
76  virtual ~SimulatorInterface();
77 
83  virtual size_t getNumAgents() const = 0;
84 
94  virtual BaseAgent * getAgent( size_t agentNo ) = 0;
95 
105  virtual const BaseAgent * getAgent( size_t agentNo ) const = 0;
106 
112  virtual void doStep() = 0;
113 
124  virtual void finalize();
125 
131  inline float getGlobalTime() const { return _globalTime; }
132 
139  inline void setTimeStep(float timeStep) { LOGICAL_TIME_STEP = timeStep; updateEffTimeStep(); }
140 
150  inline void setSubSteps(size_t subSteps) { SUB_STEPS = subSteps; updateEffTimeStep(); }
151 
157  inline float getTimeStep() const { return LOGICAL_TIME_STEP; }
158 
165  float getElevation( const BaseAgent * agent ) const;
166 
173  float getElevation( const Vector2 & point ) const;
174 
180  void setElevationInstance( Elevation * elevation );
181 
187  Elevation * getElevationInstance() { return _elevation; }
188 
194  bool hasElevation() const { return _elevation != 0x0; }
195 
201  void setSpatialQuery( SpatialQuery * spatialQuery );
202 
208  SpatialQuery * getSpatialQuery() { return _spatialQuery;};
209 
215  bool hasSpatialQuery() const { return _spatialQuery != 0x0; }
216 
217 
235  bool queryVisibility(const Vector2& point1, const Vector2& point2, float radius = 0.0f) const;
236 
242  inline size_t getSubSteps() const { return SUB_STEPS; }
243 
244  protected:
245 
251  void updateEffTimeStep() { SIM_TIME_STEP = TIME_STEP = LOGICAL_TIME_STEP / ( 1.f + SUB_STEPS ); }
252 
258  static float LOGICAL_TIME_STEP;
259 
264  static float TIME_STEP;
265 
270  static size_t SUB_STEPS;
271 
275  float _globalTime;
276 
283 
288  };
289  } // namespace Agents
290 } // namespace Menge
291 #endif // __SIMULATOR_INTERFACE_H__
static size_t SUB_STEPS
The number of intermediate steps taken between subsequent simulation time steps.
Definition: SimulatorInterface.h:270
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
SpatialQuery * getSpatialQuery()
get the spatial query instance of the simulator.
Definition: SimulatorInterface.h:208
Sets up the proper compiler directives for platform and dll export/import.
float SIM_TIME_STEP
The simulation time step.
Definition: Core.cpp:49
float getGlobalTime() const
Returns the global time of the simulation.
Definition: SimulatorInterface.h:131
bool hasElevation() const
Reports if the elevation has been set.
Definition: SimulatorInterface.h:194
static float LOGICAL_TIME_STEP
The logical simulation time step. The simulation's state is communicated to the outside world at this...
Definition: SimulatorInterface.h:258
void setSubSteps(size_t subSteps)
Sets the number of intermediate computation sub steps to take.
Definition: SimulatorInterface.h:150
The basic simulator interface required by the fsm.
Definition: SimulatorInterface.h:66
bool hasSpatialQuery() const
Reports if the spatial query has been set.
Definition: SimulatorInterface.h:215
static float TIME_STEP
The effective simulation time step - takes into account time step and computation sub-steps...
Definition: SimulatorInterface.h:264
Definition: AgentGenerator.h:52
float _globalTime
The total accumulated simulation time.
Definition: SimulatorInterface.h:275
Definition of a vector in R2.
size_t getSubSteps() const
Reports the number of simulation substeps to take.
Definition: SimulatorInterface.h:242
void updateEffTimeStep()
Updates the effective time step – how large an actual simulation time step is due to computation sub...
Definition: SimulatorInterface.h:251
The set of operations used by SimXMLLoader to apply XML-parsed experiment specification to a simulato...
The base class for determining an agent's elevation.
Definition: Elevation.h:107
SpatialQuery * _spatialQuery
The data structure used to perform spatial queries.
Definition: SimulatorInterface.h:287
float getTimeStep() const
Returns the logical time step of the simulation.
Definition: SimulatorInterface.h:157
The base class for performing spatial queries.
Definition: SpatialQuery.h:114
Elevation * getElevationInstance()
Set the elevation instance of the simulator.
Definition: SimulatorInterface.h:187
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
The base class for extracting simulator settings from the XML specification.
Definition: XMLSimulatorBase.h:126
The namespace that contains the basic simulation mechanisms.
A set of global variables for use by the entire finite state machine.
Elevation * _elevation
Data structure for reporting the elevation data of agents. This allows the simulation to be more than...
Definition: SimulatorInterface.h:282
void setTimeStep(float timeStep)
Sets the time step of the simulation.
Definition: SimulatorInterface.h:139