Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Funnel.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 
39 #ifndef __FUNNEL_H__
40 #define __FUNNEL_H__
41 
49 #include "mengeCommon.h"
50 #include <list>
51 
52 namespace Menge {
53 
58  // TODO: Determine which is faster.
59  //#define SIMPLE_FUNNEL
60 
61  // FORWARD DECLARATION
62  class PortalPath;
63  class FunnelPlanner;
64 
68  class FunnelApex {
69  public:
77  FunnelApex( size_t id, const Vector2 & point ): _id(id), _pos(point) {}
78 
86  inline void set( size_t id, const Vector2 & point ) { _id = id; _pos.set(point); }
87 
88  friend class FunnelPlanner;
89  protected:
95  size_t _id;
96 
101  };
102 
104 
108  class FunnelEdge {
109  public:
114 
115  #ifdef SIMPLE_FUNNEL
116 
123  FunnelEdge( size_t id, const Vector2 & dir ):_id(id), _dir(dir) {}
124  #else
125 
135  FunnelEdge( size_t id, size_t end, const Vector2 & dir, const Vector2 & origin ):_id(id), _endID(end), _dir(dir), _origin(origin) {}
136  #endif
137 
145  inline bool isOnLeft( const Vector2 & dir ) const { return det( _dir, dir ) > EPS; }
146 
154  inline bool isOnRight( const Vector2 & dir ) const { return det( dir, _dir ) > EPS; }
155 
162  inline void set( size_t id, const Vector2 & dir ) { _id = id; _dir.set( dir ); }
163 
164  friend class FunnelPlanner;
165 
166  protected:
167  #ifdef SIMPLE_FUNNEL
168 
171  size_t _id;
172 
173  #else
174 
177  size_t _id;
181  size_t _endID;
182 
187  #endif
188 
193  };
194 
196 
201  public:
205  FunnelPlanner();
206 
210  ~FunnelPlanner();
211 
221  void computeCrossing( float radius, const Vector2 & startPos, PortalPath * path, size_t startPortal=0 );
222 
223  #ifndef SIMPLE_FUNNEL
224  protected:
228  std::list< FunnelEdge > _left;
229 
233  std::list< FunnelEdge > _right;
234  #endif // SIMPLE_FUNNEL
235  };
236 } // namespace Menge
237 
238 #endif // __FUNNEL_H__
FunnelPlanner()
Constructor.
Definition: Funnel.cpp:50
Vector2 _pos
The position of the apex.
Definition: Funnel.h:100
The edge of a funnel.
Definition: Funnel.h:108
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
void set(size_t id, const Vector2 &point)
Sets the values of the apex.
Definition: Funnel.h:86
size_t _id
The identifier of the portal from which this wedge originates.
Definition: Funnel.h:177
FunnelEdge()
Default constructor. No initialization.
Definition: Funnel.h:113
size_t _id
The identifier associated with this apex point. if -1, it is the start position, otherwise, a point extracted from the portal with the given id.
Definition: Funnel.h:95
MENGE_API const float EPS
Suitably small number for testing for functional zero values.
Definition: geomQuery.cpp:52
void set(Type x, Type y)
Set the x- and y-values from scalar values.
Definition: Vector2.h:121
The apex of the funnel.
Definition: Funnel.h:68
std::list< FunnelEdge > _left
The queue for the left side of the funnel.
Definition: Funnel.h:228
void computeCrossing(float radius, const Vector2 &startPos, PortalPath *path, size_t startPortal=0)
Computes the crossings for the given path based on the funnel algorithm.
Definition: Funnel.cpp:60
FunnelApex(size_t id, const Vector2 &point)
Constructor.
Definition: Funnel.h:77
~FunnelPlanner()
Destructor.
Definition: Funnel.cpp:55
The class that implements the funnel algorithm.
Definition: Funnel.h:200
Vector2 _dir
The direction of this funnel edge.
Definition: Funnel.h:192
std::list< FunnelEdge > _right
The queue for the right side of the funnel.
Definition: Funnel.h:233
bool isOnRight(const Vector2 &dir) const
Reports if the given direction is to the right of this edge.
Definition: Funnel.h:154
The definition of a path through space comprising of a sequence of portals.
Definition: PortalPath.h:70
size_t _endID
The identifier of the portal that ENDS the wedge.
Definition: Funnel.h:181
void set(size_t id, const Vector2 &dir)
Sets the properties of the funnel edge.
Definition: Funnel.h:162
bool isOnLeft(const Vector2 &dir) const
Reports if the given direction is to the left of this edge.
Definition: Funnel.h:145
FunnelEdge(size_t id, size_t end, const Vector2 &dir, const Vector2 &origin)
Constructor.
Definition: Funnel.h:135
Vector2 _origin
The origin of the wedge.
Definition: Funnel.h:186