Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RectGridGenerator.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 __RECT_GRID_GENERATOR_H__
46 #define __RECT_GRID_GENERATOR_H__
47 
48 #include "mengeCommon.h"
51 #include <vector>
52 
53 namespace Menge {
54 
55  namespace Agents {
60  class MENGE_API RectGridGenerator : public AgentGenerator {
61  public:
66 
72  virtual size_t agentCount() { return _xCount * _yCount; }
73 
81  virtual Vector2 agentPos( size_t i );
82 
88  void setAnchor( const Vector2 & p ) { _anchor.set( p ); }
89 
95  void setOffset( const Vector2 & o ) { _offset.set( o ); }
96 
102  void setXCount( size_t count ) { _xCount = count; }
103 
109  void setYCount( size_t count ) { _yCount = count; }
110 
117  void setAgentCounts( size_t xCount, size_t yCount ) { _xCount = xCount; _yCount = yCount; }
118 
124  void setRotationDeg( float angle );
125 
126  protected:
132 
138 
142  size_t _xCount;
143 
147  size_t _yCount;
148 
153  float _cosRot;
154 
159  float _sinRot;
160 
161  };
162 
164 
169  public:
174 
183  virtual const char * name() const { return "rect_grid"; }
184 
192  virtual const char * description() const {
193  return "Agent generation is done via the specification of a rectangular grid.";
194  };
195 
196  protected:
207  AgentGenerator * instance() const { return new RectGridGenerator(); }
208 
227  virtual bool setFromXML( AgentGenerator * gen, TiXmlElement * node, const std::string & specFldr ) const;
228 
232  size_t _anchorXID;
233 
237  size_t _anchorYID;
238 
242  size_t _offsetXID;
243 
247  size_t _offsetYID;
248 
252  size_t _xCountID;
253 
257  size_t _yCountID;
258 
262  size_t _rotID;
263  };
264  } // namespace Agents
265 } // namespace Menge
266 
267 #endif // __RECT_GRID_GENERATOR_H__
size_t _rotID
The identifier for the "rotation" float parameter.
Definition: RectGridGenerator.h:262
size_t _offsetXID
The identifier for the "offset_x" float parameter.
Definition: RectGridGenerator.h:242
The factory for parsing xml data and instantiating agent generator implementations.
virtual size_t agentCount()
Reports the number of agents created.
Definition: RectGridGenerator.h:72
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
size_t _xCountID
The identifier for the "count_x" size_t parameter.
Definition: RectGridGenerator.h:252
float _cosRot
The cosine of the amount the lattice is rotated around its anchor point. positive rotation values are...
Definition: RectGridGenerator.h:153
The base class inital agent generation.
Definition: AgentGenerator.h:104
AgentGenerator * instance() const
Create an instance of this class's agent generator implementation.
Definition: RectGridGenerator.h:207
Vector2 _anchor
The anchor point of the lattice. One agent will be positioned at this world coordainte.
Definition: RectGridGenerator.h:131
virtual const char * name() const
The name of the generator type.
Definition: RectGridGenerator.h:183
void setAnchor(const Vector2 &p)
Sets the anchor position.
Definition: RectGridGenerator.h:88
virtual const char * description() const
A description of the agent generator.
Definition: RectGridGenerator.h:192
float _sinRot
The sine of the amount the lattice is rotated around its anchor point. positive rotation values are c...
Definition: RectGridGenerator.h:159
size_t _yCountID
The identifier for the "count_y" size_t parameter.
Definition: RectGridGenerator.h:257
Vector2 _offset
The offset from one agent to the next agent (along the local x- and y-axes, respectively.
Definition: RectGridGenerator.h:137
Definition of an agent generator class which produces agents based on the positions of intersections ...
Definition: RectGridGenerator.h:60
size_t _xCount
The number of agents along the local x-axis.
Definition: RectGridGenerator.h:142
Factory for RectGridGenerator.
Definition: RectGridGenerator.h:168
size_t _anchorYID
The identifier for the "anchor_y" float parameter.
Definition: RectGridGenerator.h:237
void setOffset(const Vector2 &o)
Sets the offset value.
Definition: RectGridGenerator.h:95
void setAgentCounts(size_t xCount, size_t yCount)
Sets the number of agents in the local x- and y-directions.
Definition: RectGridGenerator.h:117
size_t _offsetYID
The identifier for the "offset_y" float parameter.
Definition: RectGridGenerator.h:247
A class for parsing the xml description of an agent generator and instantiating particular instances...
Definition: AgentGeneratorFactory.h:59
The definition of the agent generator element. Defines the intial numbers and positions of agents in ...
void setYCount(size_t count)
Sets the number of agents in the local y-direction.
Definition: RectGridGenerator.h:109
The namespace that contains the basic simulation mechanisms.
size_t _anchorXID
The identifier for the "anchor_x" float parameter.
Definition: RectGridGenerator.h:232
size_t _yCount
The number of agents along the local y-axis.
Definition: RectGridGenerator.h:147
void setXCount(size_t count)
Sets the number of agents in the local x-direction.
Definition: RectGridGenerator.h:102