Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Menge::BFSM::Goal Class Referenceabstract

The base, abstract class defining goals. More...

#include <Goal.h>

Inheritance diagram for Menge::BFSM::Goal:
Menge::Element Menge::BFSM::AABBGoal Menge::BFSM::CircleGoal Menge::BFSM::OBBGoal Menge::BFSM::PointGoal

Public Member Functions

 Goal ()
 Basic constructor.
 
virtual float squaredDistance (const Vector2 &pt) const =0
 Reports the squared distance from the given point to the goal. More...
 
virtual void setDirections (const Vector2 &q, float r, Agents::PrefVelocity &directions) const =0
 Set the preferred velocity directions w.r.t. the goal: left, right, and preferred. More...
 
virtual Vector2 getTargetPoint (const Vector2 &q, float r) const =0
 Returns the closest "target" point in the goal to the given query point. More...
 
virtual Vector2 getCentroid () const =0
 Return the centroid of the goal.
 
bool hasCapacity () const
 Reports if the goal still has capacity. More...
 
void assign (const Agents::BaseAgent *agent)
 Inform the goal that it has been assigned. More...
 
void free ()
 Inform the goal that an assignment has been removed.
 
void setGoalSet (GoalSet *goalSet)
 Sets this goal's goal set. More...
 
GoalSetgetGoalSet ()
 Returns a pointer to this agent's goal set. More...
 
const GoalSetgetGoalSet () const
 Returns a const pointer to this agent's goal set. More...
 
void setWeight (float weight)
 Sets the goal's weight. More...
 
float getWeight () const
 Retrieves the goal's weight. More...
 
void setCapacity (size_t capacity)
 Sets the goal's capacity. More...
 
size_t getCapacity () const
 Returns this goal's capacity. More...
 
void setID (size_t id)
 Sets the id of the goal. More...
 
size_t getID () const
 Gets the id of the goal. More...
 
virtual void drawGL () const
 Draws the goal into an OpenGL context.
 
- Public Member Functions inherited from Menge::Element
void destroy ()
 This supplants the destructor. More...
 
virtual BFSM::TaskgetTask ()
 Return an optional task associated with this element. More...
 
virtual SceneGraph::GLNodegetSGNode ()
 Returns an optional visualization element associated with the element. More...
 

Static Public Attributes

static const size_t MAX_CAPACITY = -1
 The maximum capacity any goal can hold.
 

Protected Member Functions

virtual ~Goal ()
 Destructor.
 
virtual void drawGLGeometry () const
 Draws the goal geometry.
 

Protected Attributes

float _weight
 The relative weight of this goal.
 
size_t _capacity
 The maximum capacity of this goal.
 
size_t _id
 The id of this goal in its goal set.
 
GoalSet_goalSet
 The goal set to which this goal belongs.
 
size_t _population
 The current "population" of this goal. More...
 
ReadersWriterLock _lock
 The lock to maintain readers-writer access to the structure which control available goals.
 

Friends

class GoalSet
 

Detailed Description

The base, abstract class defining goals.

Member Function Documentation

void Menge::BFSM::Goal::assign ( const Agents::BaseAgent agent)

Inform the goal that it has been assigned.

Parameters
agentThe agent that has been assigned to this goal.
size_t Menge::BFSM::Goal::getCapacity ( ) const
inline

Returns this goal's capacity.

Returns
The goal's capacity.
GoalSet* Menge::BFSM::Goal::getGoalSet ( )
inline

Returns a pointer to this agent's goal set.

A dynamic goal (such as would be created by a hold-position goal will return NULL, which means it isn't owned by a goal set and should be destroyed when finished.

// TODO: Handle goal sharing and persistence.

Returns
A pointer to the goal set to which this goal belongs.
const GoalSet* Menge::BFSM::Goal::getGoalSet ( ) const
inline

Returns a const pointer to this agent's goal set.

A dynamic goal (such as would be created by a hold-position goal will return NULL, which means it isn't owned by a goal set and should be destroyed when finished.

// TODO: Handle goal sharing and persistence.

Returns
A const pointer to the goal set to which this goal belongs.
size_t Menge::BFSM::Goal::getID ( ) const
inline

Gets the id of the goal.

Returns
The goal's id.
virtual Vector2 Menge::BFSM::Goal::getTargetPoint ( const Vector2 q,
float  r 
) const
pure virtual

Returns the closest "target" point in the goal to the given query point.

A "valid" target point is the nearest point to the query point that is sufficiently inside the goal region that a disk with the given radius is completely inside the goal. It need not be literally the best value, an approximation is sufficient.

In the case where the goal region is too small to hold the agent, then the "deepest" point in the region is a good approximation.

Parameters
qThe query point.
rThe radius of clearance.
Returns
A 2D position representing the target point.

Implemented in Menge::BFSM::OBBGoal, Menge::BFSM::AABBGoal, Menge::BFSM::CircleGoal, and Menge::BFSM::PointGoal.

float Menge::BFSM::Goal::getWeight ( ) const
inline

Retrieves the goal's weight.

Returns
This goal's weight.
bool Menge::BFSM::Goal::hasCapacity ( ) const

Reports if the goal still has capacity.

Returns
True if the goal has remaining capacity, false otherwise.
void Menge::BFSM::Goal::setCapacity ( size_t  capacity)
inline

Sets the goal's capacity.

Parameters
capacityThe target capacity for this goal.
virtual void Menge::BFSM::Goal::setDirections ( const Vector2 q,
float  r,
Agents::PrefVelocity directions 
) const
pure virtual

Set the preferred velocity directions w.r.t. the goal: left, right, and preferred.

The Agents::PrefVelocity class represents a span of velocities that will reach the goal. For a goal that covers a 2D region, the directions in the Agents::PrefVelocity should span the arc subtended by the goal from the query point's perspective. Furthermore, it should have sufficient clearance for a disk with the given radius to pass through. This should be overridden by subclasses to account for their unique geometry.

Parameters
qThe query point.
rThe radius of clearance.
directionsAn instance of Agents::PrefVelocity.

Implemented in Menge::BFSM::OBBGoal, Menge::BFSM::AABBGoal, Menge::BFSM::CircleGoal, and Menge::BFSM::PointGoal.

void Menge::BFSM::Goal::setGoalSet ( GoalSet goalSet)
inline

Sets this goal's goal set.

Parameters
goalSetA pointer to the goal set to which this goal belongs.
void Menge::BFSM::Goal::setID ( size_t  id)
inline

Sets the id of the goal.

Parameters
idThe goal's new id.
void Menge::BFSM::Goal::setWeight ( float  weight)
inline

Sets the goal's weight.

Parameters
weightThe weight value for this goal.
virtual float Menge::BFSM::Goal::squaredDistance ( const Vector2 pt) const
pure virtual

Reports the squared distance from the given point to the goal.

Parameters
ptThe query point.
Returns
The squared distance from the point to the goal.

Implemented in Menge::BFSM::OBBGoal, Menge::BFSM::AABBGoal, Menge::BFSM::CircleGoal, and Menge::BFSM::PointGoal.

Member Data Documentation

size_t Menge::BFSM::Goal::_population
mutableprotected

The current "population" of this goal.

In other words, it is the number of times "getGoalPoint" has been called on this goal. If a goal is to support


The documentation for this class was generated from the following files: