Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AgentInitializer.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 
45 #ifndef __AGENT_INITIALIZER_H__
46 #define __AGENT_INITIALIZER_H__
47 
48 #include "CoreConfig.h"
49 #include <string>
51 
52 // forward declaration
53 class TiXmlElement;
54 
55 namespace Menge {
56 
57  // Forward declarations
58  namespace Math {
59  class FloatGenerator;
60  class IntGenerator;
61  }
62 
63  using namespace Math;
64 
65  namespace Agents {
66  // forward declaration
67  class BaseAgent;
68 
75  class MENGE_API AgentInitializer {
76  public:
81  enum ParseResult {
82  FAILURE = 0,
84  ACCEPTED
85  };
86 
93 
100  AgentInitializer( const AgentInitializer & init );
101 
105  virtual ~AgentInitializer();
106 
137  bool parseProperties( TiXmlElement * node, const std::string & sceneFldr );
138 
152  virtual bool setProperties( BaseAgent * agent );
153 
161  virtual void setDefaults();
162 
170  virtual AgentInitializer * copy() const { return new AgentInitializer( *this ); }
171 
175  static bool VERBOSE;
176 
177  protected:
193  virtual bool isRelevant( const ::std::string & tagName );
194 
209  virtual ParseResult setFromXMLAttribute( const ::std::string & paramName, const ::std::string & value );
210 
222  bool parsePropertySpec( TiXmlElement * node );
223 
241  virtual ParseResult processProperty( ::std::string propName, TiXmlElement * node );
242 
262  ParseResult constFloatGenerator( FloatGenerator * & gen, const ::std::string & valueStr, float scale=1.f );
263 
282  ParseResult constFloat( float & numValue, const ::std::string & valueStr, float scale=1.f );
283 
300  ParseResult constIntGenerator( IntGenerator * & gen, const ::std::string & valueStr );
301 
317  ParseResult constSizet( size_t & numValue, const ::std::string & valueStr );
318 
339  ParseResult getFloatGenerator( FloatGenerator * & gen, TiXmlElement * node, float scale=1.f );
340 
357  ParseResult getIntGenerator( IntGenerator * & gen, TiXmlElement * node );
358 
363 
368 
373 
378 
384 
389 
395 
400  size_t _obstacleSet;
401 
405  float _priority;
406 
410  size_t _class;
411 
415  std::vector<BFSM::VelModifier *> _velModifiers;
416 
417  };
418  } // namespace Agents
419 } // namespace Menge
420 #endif // __AGENT_INITIALIZER_H__
The XML data was ignored by the function.
Definition: AgentInitializer.h:83
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
FloatGenerator * _radius
The agent's radius. See Agents::BaseAgent::_radius for details.
Definition: AgentInitializer.h:388
IntGenerator * _maxNeighbors
The number of nearby agents used to plan dynamic respones.
Definition: AgentInitializer.h:377
Generic abstract class which generates a scalar float value.
Definition: RandGenerator.h:99
Sets up the proper compiler directives for platform and dll export/import.
FloatGenerator * _neighborDist
The maximum distance at which another agent will be considered for a response.
Definition: AgentInitializer.h:383
FloatGenerator * _maxSpeed
The maximum speed the agent can take.
Definition: AgentInitializer.h:362
The definition of how preferred velocity is modified by a filter.
Class which determines the agent properties for each new agent.
Definition: AgentInitializer.h:75
FloatGenerator * _maxAngVel
The agent's maximum angular velocity (in radians/sec) – used for controlling the changes in agent or...
Definition: AgentInitializer.h:394
size_t _obstacleSet
A mask indicating which obstacles affect the agent. See Agents::BaseAgent::_obstacleSet for details...
Definition: AgentInitializer.h:400
ParseResult
Return type for parsing efforts. Helps the various derived classes coordinate their work...
Definition: AgentInitializer.h:81
The namespace for math primitives for simulation and visualization.
float _priority
The priority of each agent. See Agents::BaseAgent::_priority for details.
Definition: AgentInitializer.h:405
static bool VERBOSE
Determines if the agent properties parsing process will be verbose.
Definition: AgentInitializer.h:175
virtual AgentInitializer * copy() const
Creates a copy of this AgentInitializer instance.
Definition: AgentInitializer.h:170
Generic abstract class which generates a scalar integer value.
Definition: RandGenerator.h:486
size_t _class
The population class for this agent. See Agents::BaseAgent::_class for details.
Definition: AgentInitializer.h:410
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
The namespace that contains the basic simulation mechanisms.
std::vector< BFSM::VelModifier * > _velModifiers
Velocity Modifiers to be applied to this class.
Definition: AgentInitializer.h:415
FloatGenerator * _maxAccel
The maximum acceleration the agent can experience (interpreted isotropically).
Definition: AgentInitializer.h:367
FloatGenerator * _prefSpeed
The preferred speed of the agent.
Definition: AgentInitializer.h:372