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

Defines an obstacle kd-tree. More...

#include <ObstacleKDTree.h>

Public Member Functions

 ObstacleKDTree ()
 Constructs an Obstacle kd-tree instance.
 
 ~ObstacleKDTree ()
 Destroys this kd-tree instance.
 
void buildTree (const std::vector< Obstacle * > obstacles)
 Builds an obstacle kd-tree on the given set of obstacles.
 
void obstacleQuery (ProximityQuery *query) const
 Computes the obstacles within range square of a point. More...
 
bool queryVisibility (const Vector2 &q1, const Vector2 &q2, float radius) const
 Queries the visibility between two points within a specified radius. More...
 

Protected Member Functions

ObstacleTreeNodebuildTreeRecursive (const std::vector< Obstacle * > &obstacles)
 Does the full work of constructing the kd-tree. More...
 
void queryTreeRecursive (ProximityQuery *query, Vector2 pt, float &rangeSq, const ObstacleTreeNode *node) const
 Computes the obstacle neighbors of the specified point by doing a recursive search. More...
 
bool queryVisibilityRecursive (const Vector2 &q1, const Vector2 &q2, float radius, const ObstacleTreeNode *node) const
 Perform the work, recursively, to determine if q1 can see q2, w.r.t. the obstacles. More...
 
void deleteTree ()
 Recursively deletes the obstacle tree.
 
void deleteSubTree (ObstacleTreeNode *node)
 Recursively deletes an obstacle sub-tree. More...
 

Protected Attributes

std::vector< Obstacle * > _obstacles
 The set of obstacles managed by this query structure. More...
 
ObstacleTreeNode_tree
 The query tree root.
 

Static Protected Attributes

static const size_t MAX_LEAF_SIZE = 10
 The maximum number of obstacles allowed in a tree leaf node.
 

Detailed Description

Defines an obstacle kd-tree.

This structure will create a static kd-tree node on the provided set of obstacles. It will modify the obstacles in that some obstacles may be cut.

Member Function Documentation

ObstacleTreeNode * Menge::Agents::ObstacleKDTree::buildTreeRecursive ( const std::vector< Obstacle * > &  obstacles)
protected

Does the full work of constructing the kd-tree.

Parameters
obstaclesThe set of obstacles to construct this tree around
Returns
The root of the ObstacleKDTree for this set of obstacles
void Menge::Agents::ObstacleKDTree::deleteSubTree ( ObstacleTreeNode node)
protected

Recursively deletes an obstacle sub-tree.

Parameters
nodeThe root of the tree to delete.
void Menge::Agents::ObstacleKDTree::obstacleQuery ( ProximityQuery query) const

Computes the obstacles within range square of a point.

Parameters
querya pointer for the query to be performed
void Menge::Agents::ObstacleKDTree::queryTreeRecursive ( ProximityQuery query,
Vector2  pt,
float &  rangeSq,
const ObstacleTreeNode node 
) const
protected

Computes the obstacle neighbors of the specified point by doing a recursive search.

Parameters
querya pointer to the query being performed.
ptthe starting point from the query
rangeSqThe squared range around the agent.
nodeThe current node in the obstacle tree
bool Menge::Agents::ObstacleKDTree::queryVisibility ( const Vector2 q1,
const Vector2 q2,
float  radius 
) const

Queries the visibility between two points within a specified radius.

Parameters
q1The first point between which visibility is to be tested.
q2The second point between which visibility is to be tested.
radiusThe radius within which visibility is to be tested.
Returns
True if q1 and q2 are mutually visible within the radius; false otherwise.
bool Menge::Agents::ObstacleKDTree::queryVisibilityRecursive ( const Vector2 q1,
const Vector2 q2,
float  radius,
const ObstacleTreeNode node 
) const
protected

Perform the work, recursively, to determine if q1 can see q2, w.r.t. the obstacles.

Parameters
q1The originating position.
q2The target position.
radiusThe radius within which visibility is to be tested.
nodeThe root of the tree to recursively search.
Returns
True if q1 and q2 are mutually visible within the radius, false otherwise.

Member Data Documentation

std::vector<Obstacle*> Menge::Agents::ObstacleKDTree::_obstacles
protected

The set of obstacles managed by this query structure.

This is not necessarily the same as the obstacles assigned. The set of obstacles can change as some obstacles may be sub-divided during the spatial decomposition. This needs to be corrected.


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