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

A kd-tree for performing nearest-neighbor searches. More...

#include <AgentKDTree.h>

Public Member Functions

 AgentKDTree ()
 Constructs an Agent kd-tree instance.
 
void setAgents (const std::vector< BaseAgent * > &agents)
 Define the set of agents on which kd-tree will query.
 
void buildTree ()
 Builds a kd-tree on the set of agents.
 
void agentQuery (ProximityQuery *filter) const
 gets agents within a range, and passes them to the supplied filter More...
 

Protected Member Functions

void buildTreeRecursive (size_t begin, size_t end, size_t node)
 Does the full work of constructing the kd-tree. More...
 
void queryTreeRecursive (ProximityQuery *filter, Vector2 pt, float &rangeSq, size_t node) const
 Computes the agent neighbors of the specified agent by doing a recursive search. More...
 

Protected Attributes

std::vector< const BaseAgent * > _agents
 The agents being partitioned by the kd-tree.
 
std::vector< AgentTreeNode > _tree
 The tree structure.
 

Static Protected Attributes

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

Detailed Description

A kd-tree for performing nearest-neighbor searches.

The agents are partitioned according to a greedy partitioning algorithm.

Member Function Documentation

void Menge::Agents::AgentKDTree::agentQuery ( ProximityQuery filter) const

gets agents within a range, and passes them to the supplied filter

Parameters
filtera pointer for the filter object
void Menge::Agents::AgentKDTree::buildTreeRecursive ( size_t  begin,
size_t  end,
size_t  node 
)
protected

Does the full work of constructing the kd-tree.

Parameters
beginThe index of the first agent in the region of the tree.
endThe index of the last (just outside). So, the agents in this branch are in the interval [begin, end)
nodeThe index of the node to build.
void Menge::Agents::AgentKDTree::queryTreeRecursive ( ProximityQuery filter,
Vector2  pt,
float &  rangeSq,
size_t  node 
) const
protected

Computes the agent neighbors of the specified agent by doing a recursive search.

Parameters
filterspatial query filter to use
ptthe start point for the query
rangeSqThe squared range around the agent.
nodeThe current node to search in.

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