Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CondSpace.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 __COND_SPACE_H__
46 #define __COND_SPACE_H__
47 
48 #include "CoreConfig.h"
49 #include "Transitions/Condition.h"
51 #include "Math/Geometry2D.h"
52 #include "fsmCommon.h"
53 
54 namespace Menge {
55 
56  namespace BFSM {
57  //forward declartions
58  class SpaceCondFactory;
59 
65  class MENGE_API SpaceCondition : public Condition {
66  public:
71 
77  SpaceCondition( const SpaceCondition & cond );
78 
79  protected:
83  ~SpaceCondition();
84 
85  public:
93  virtual bool conditionMet( Agents::BaseAgent * agent, const Goal * goal );
94 
95  friend class SpaceCondFactory;
96  protected:
105  virtual bool containsPoint( const Vector2 & pt ) const = 0;
106 
112  };
113 
115 
119  class MENGE_API SpaceCondFactory : public ConditionFactory {
120  public:
125 
126  protected:
145  virtual bool setFromXML( Condition * condition, TiXmlElement * node, const std::string & behaveFldr ) const;
146 
150  size_t _insideID;
151  };
152 
154 
161  class MENGE_API CircleCondition : public SpaceCondition, public CircleShape {
162  public:
166  CircleCondition();
167 
173  CircleCondition( const CircleCondition & cond );
174 
183  virtual Condition * copy();
184 
185  protected:
192  virtual bool containsPoint( const Vector2 & pt ) const { return CircleShape::containsPoint( pt ); }
193  };
194 
198  class MENGE_API CircleCondFactory : public SpaceCondFactory {
199  public:
204 
213  virtual const char * name() const { return "circle"; }
214 
222  virtual const char * description() const {
223  return "The circle condition. It becomes active when an agent achieves "\
224  "a particular relationship (inside/outside) with a static circle in the " \
225  "environment.";
226  }
227  protected:
238  virtual Condition * instance() const { return new CircleCondition(); }
239 
258  virtual bool setFromXML( Condition * condition, TiXmlElement * node, const std::string & behaveFldr ) const;
259 
263  size_t _centerXID;
264 
268  size_t _centerYID;
269 
273  size_t _radiusID;
274  };
275 
277 
284  class MENGE_API AABBCondition : public SpaceCondition, public AABBShape {
285  public:
289  AABBCondition();
290 
296  AABBCondition( const AABBCondition & cond );
297 
306  virtual Condition * copy();
307  protected:
314  virtual bool containsPoint( const Vector2 & pt ) const { return AABBShape::containsPoint( pt ); }
315  };
316 
320  class MENGE_API AABBCondFactory : public SpaceCondFactory {
321  public:
325  AABBCondFactory();
326 
335  virtual const char * name() const { return "AABB"; }
336 
344  virtual const char * description() const {
345  return "The axis-aligned bounding box (AABB) condition. It becomes active when an agent achieves "\
346  "a particular relationship (inside/outside) with a static axis-aligned bounding box in the " \
347  "environment.";
348  }
349  protected:
360  virtual Condition * instance() const { return new AABBCondition(); }
361 
380  virtual bool setFromXML( Condition * condition, TiXmlElement * node, const std::string & behaveFldr ) const;
381 
385  size_t _minXID;
386 
390  size_t _minYID;
391 
395  size_t _maxXID;
396 
400  size_t _maxYID;
401  };
402 
404 
411  class MENGE_API OBBCondition : public SpaceCondition, public OBBShape {
412  public:
416  OBBCondition();
417 
423  OBBCondition( const OBBCondition & cond );
424 
433  virtual Condition * copy();
434  protected:
441  virtual bool containsPoint( const Vector2 & pt ) const { return OBBShape::containsPoint( pt ); }
442  };
443 
447  class MENGE_API OBBCondFactory : public SpaceCondFactory {
448  public:
452  OBBCondFactory();
453 
462  virtual const char * name() const { return "OBB"; }
463 
471  virtual const char * description() const {
472  return "The oriented bounding box (OBB) condition. It becomes active when an agent achieves "\
473  "a particular relationship (inside/outside) with a static oriented bounding box in the " \
474  "environment.";
475  }
476  protected:
487  virtual Condition * instance() const { return new OBBCondition(); }
488 
507  virtual bool setFromXML( Condition * condition, TiXmlElement * node, const std::string & behaveFldr ) const;
508 
512  size_t _pivotXID;
513 
517  size_t _pivotYID;
518 
522  size_t _widthID;
523 
527  size_t _heightID;
528 
532  size_t _angleID;
533  };
534 
535  } // namespace BFSM
536 }
537 
538 #endif // __COND_SPACE_H__
virtual const char * description() const
A description of the action.
Definition: CondSpace.h:222
size_t _centerXID
The identifier for the "center_x" float attribute.
Definition: CondSpace.h:263
The core namespace. All elements of Menge are contained in this namespace.
Definition: AgentGenerator.cpp:43
virtual bool containsPoint(const Vector2 &pt) const
Determine if the point is inside the shape based on the instance properties.
Definition: Geometry2D.cpp:125
The class for parsing the xml description of a Condition and instantiating particular instances...
Definition: ConditionFactory.h:61
size_t _maxYID
The identifier for the "max_y" float attribute.
Definition: CondSpace.h:400
size_t _angleID
The identifier for the "angle" float attribute.
Definition: CondSpace.h:532
Sets up the proper compiler directives for platform and dll export/import.
The factory for parsing xml data for transition conditions and instantiating the appropriate class...
virtual Condition * instance() const
Create an instance of this class's condition.
Definition: CondSpace.h:238
virtual bool containsPoint(const Vector2 &pt) const
Determine if the point is inside the shape based on the instance properties.
Definition: Geometry2D.cpp:200
virtual bool containsPoint(const Vector2 &pt) const
Determine if the point is inside the shape based on the instance properties.
Definition: Geometry2D.cpp:72
The base, abstract class defining goals.
Definition: Goal.h:110
size_t _pivotYID
The identifier for the "pivot_y" float attribute.
Definition: CondSpace.h:517
A transition based on spatial relationship with an axis-aligned bounding box (AABB).
Definition: CondSpace.h:284
A transition based on spatial relationship with a circle.
Definition: CondSpace.h:161
size_t _maxXID
The identifier for the "max_x" float attribute.
Definition: CondSpace.h:395
A transition based on spatial relationship with an axis-aligned bounding box (AABB).
Definition: CondSpace.h:411
size_t _pivotXID
The identifier for the "pivot_x" float attribute.
Definition: CondSpace.h:512
virtual bool containsPoint(const Vector2 &pt) const
Determines if a point is inside the test region.
Definition: CondSpace.h:192
The factory for creating the OBBCondition.
Definition: CondSpace.h:447
Definition of various shapes for defining spatial relationships.
size_t _centerYID
The identifier for the "center_y" float attribute.
Definition: CondSpace.h:268
virtual bool containsPoint(const Vector2 &pt) const
Determines if a point is inside the test region.
Definition: CondSpace.h:441
size_t _minXID
The identifier for the "min_x" float attribute.
Definition: CondSpace.h:385
Oriented bounding box.
Definition: Geometry2D.h:292
virtual const char * name() const
The name of the action.
Definition: CondSpace.h:213
size_t _radiusID
The identifier for the "radius" float attribute.
Definition: CondSpace.h:273
The factory for creating the SpaceCondition.
Definition: CondSpace.h:198
virtual bool containsPoint(const Vector2 &pt) const
Determines if a point is inside the test region.
Definition: CondSpace.h:314
virtual const char * description() const
A description of the action.
Definition: CondSpace.h:344
virtual const char * name() const
The name of the action.
Definition: CondSpace.h:335
bool _outsideActive
Determines if the transition happens when the agent is outside (true) or inside (false).
Definition: CondSpace.h:111
size_t _minYID
The identifier for the "min_y" float attribute.
Definition: CondSpace.h:390
The factory for creating the SpaceCondition.
Definition: CondSpace.h:119
virtual const char * description() const
A description of the action.
Definition: CondSpace.h:471
The namespace contains the Behavior Finite State Machine (BFSM) definition.
Collection of convenient pre-compiler information for fsm definitions.
size_t _insideID
The identifier for the "inside" bool attribute.
Definition: CondSpace.h:150
The base class for transition conditions.
Definition: Condition.h:68
Defines the basic agent properties and functionality that all simulation agents share.
Definition: BaseAgent.h:123
size_t _heightID
The identifier for the "height" float attribute.
Definition: CondSpace.h:527
The factory for creating the AABBCondition.
Definition: CondSpace.h:320
Axis-aligned bounding box.
Definition: Geometry2D.h:193
The abstact base class for spatial conditions. This includes all conditions which define a geometric ...
Definition: CondSpace.h:65
Circle shape.
Definition: Geometry2D.h:97
virtual Condition * instance() const
Create an instance of this class's condition.
Definition: CondSpace.h:487
size_t _widthID
The identifier for the "width" float attribute.
Definition: CondSpace.h:522
virtual Condition * instance() const
Create an instance of this class's condition.
Definition: CondSpace.h:360
The basis for determining the conditions under which transitions become "active" (and are taken)...
virtual const char * name() const
The name of the action.
Definition: CondSpace.h:462