Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HexLatticeGenerator.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 
46 #ifndef __LATTICE_AGENT_GENERATOR_H__
47 #define __LATTICE_AGENT_GENERATOR_H__
48 
49 #include "mengeCommon.h"
52 
53 namespace Menge {
54 
55  namespace Agents {
75  class MENGE_API HexLatticeGenerator : public AgentGenerator {
76  public:
83  RIGHT_CORNER
84  };
85 
91  ROW_Y
92  };
93 
98 
104  virtual size_t agentCount() { return _totalPop; }
105 
113  virtual Vector2 agentPos( size_t i );
114 
126  void set( const Vector2 & anchor, AnchorAlignEnum align, LatticeRowEnum dir,
127  float width, float density, size_t tgtPopulation, float angle );
128 
133  void setRotationDeg( float angle );
134 
135  protected:
141 
146 
151  float _cosRot;
152 
157  float _sinRot;
158 
163  size_t _totalPop;
164 
168  float _rowDist;
169 
174  float _nbrDist;
175 
180  size_t _rowPop;
181 
185  size_t _rowCount;
186 
187  };
188 
190 
195  public:
200 
209  virtual const char * name() const { return "hex_lattice"; }
210 
218  virtual const char * description() const {
219  return "Agent generation is done via the specification of a bounded hexagonal lattice.";
220  };
221 
222  protected:
233  AgentGenerator * instance() const { return new HexLatticeGenerator(); }
234 
253  virtual bool setFromXML( AgentGenerator * gen, TiXmlElement * node, const std::string & specFldr ) const;
254 
258  size_t _anchorXID;
259 
263  size_t _anchorYID;
264 
268  size_t _alignID;
269 
273  size_t _rowDirID;
274 
278  size_t _densityID;
279 
283  size_t _widthID;
284 
288  size_t _popID;
289 
293  size_t _rotID;
294  };
295  } // namespace Agents
296 } // namespace Menge
297 #endif // __LATTICE_AGENT_GENERATOR_H__
AnchorAlignEnum
Enumeration specifying arrangement relative to the anchor point.
Definition: HexLatticeGenerator.h:80
The factory for parsing xml data and instantiating agent generator implementations.
size_t _anchorXID
The identifier for the "anchor_x" float parameter.
Definition: HexLatticeGenerator.h:258
size_t _rowPop
The population of the major row (interpreted differently depending on lattice row direction...
Definition: HexLatticeGenerator.h:180
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
virtual const char * description() const
A description of the agent generator.
Definition: HexLatticeGenerator.h:218
float _rowDist
The distance between rows for the given target density.
Definition: HexLatticeGenerator.h:168
The base class inital agent generation.
Definition: AgentGenerator.h:104
AgentGenerator * instance() const
Create an instance of this class's agent generator implementation.
Definition: HexLatticeGenerator.h:233
size_t _alignID
The identifier for the "alignment" string parameter.
Definition: HexLatticeGenerator.h:268
Vector2 _anchor
The anchor point of the lattice. One agent will be positioned at this world coordainte.
Definition: HexLatticeGenerator.h:140
size_t _anchorYID
The identifier for the "anchor_y" float parameter.
Definition: HexLatticeGenerator.h:263
The front boundary's "left" corner is on the anchor.
Definition: HexLatticeGenerator.h:82
size_t _rowDirID
The identifier for the "row_direction" string parameter.
Definition: HexLatticeGenerator.h:273
The front boundary is centered on the anchor.
Definition: HexLatticeGenerator.h:81
size_t _rotID
The identifier for the "rotation" float parameter.
Definition: HexLatticeGenerator.h:293
The rows run parallel with the local x-axis.
Definition: HexLatticeGenerator.h:90
size_t _densityID
The identifier for the "density" float parameter.
Definition: HexLatticeGenerator.h:278
size_t _rowCount
The number of rows to create.
Definition: HexLatticeGenerator.h:185
size_t _totalPop
The actual number of agents to create based on run-time parameters. This value is only valid AFTER fi...
Definition: HexLatticeGenerator.h:163
float _nbrDist
The distance between neighbors in a single row for the given target density.
Definition: HexLatticeGenerator.h:174
virtual size_t agentCount()
Reports the number of agents created.
Definition: HexLatticeGenerator.h:104
Definition of an agent generator class which produces agents based on the positions of intersections ...
Definition: HexLatticeGenerator.h:75
float _sinRot
The sine of the amount the lattice is rotated around its anchor point. positive rotation values are c...
Definition: HexLatticeGenerator.h:157
Factory for HexLatticeGenerator.
Definition: HexLatticeGenerator.h:194
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 ...
LatticeRowEnum
Enumeration indicating which axis the regular rows occur.
Definition: HexLatticeGenerator.h:89
LatticeRowEnum _rowDir
The direction of the row layout.
Definition: HexLatticeGenerator.h:145
size_t _widthID
The identifier for the "width" float parameter.
Definition: HexLatticeGenerator.h:283
The namespace that contains the basic simulation mechanisms.
size_t _popID
The identifier for the "count" size_t parameter.
Definition: HexLatticeGenerator.h:288
float _cosRot
The cosine of the amount the lattice is rotated around its anchor point. positive rotation values are...
Definition: HexLatticeGenerator.h:151
virtual const char * name() const
The name of the generator type.
Definition: HexLatticeGenerator.h:209