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 Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
Menge::NavMesh Class Reference

The class for defining a navigation mesh. A decomposition of the free space into a connected mesh of convex (or near convex) polygons used for global planning in planar or non-planar environments. More...

#include <NavMesh.h>

Inheritance diagram for Menge::NavMesh:
Menge::Resource

Public Member Functions

 NavMesh (const std::string &name)
 Constructor. More...
 
void clear ()
 Clears the navigation mesh - removes edges and nodes.
 
virtual const std::string & getLabel () const
 Returns a unique resource label to be used to identify different resource types which use the same underlying file data.
 
size_t getVertexCount () const
 Reports the number of vertices in the navigation mesh. More...
 
size_t getNodeCount () const
 Reports the number of nodes in the navigation mesh. More...
 
NavMeshNodegetNode (unsigned int i)
 Returns a reference to the ith node. More...
 
const NavMeshNodegetNode (unsigned int i) const
 Returns a const reference to the ith node. More...
 
size_t getEdgeCount () const
 Reports the number of edges in the navigation mesh. More...
 
NavMeshEdgegetEdge (unsigned int i)
 Returns a reference to the ith edge. More...
 
const NavMeshEdgegetEdge (unsigned int i) const
 Returns a const reference to the ith edge. More...
 
size_t getObstacleCount () const
 Returns the number of obstacles connected to this node. More...
 
NavMeshObstaclegetObstacle (unsigned int i)
 Returns a reference to the ith obstacle. More...
 
const NavMeshObstaclegetObstacle (unsigned int i) const
 Returns a const reference to the ith obstacle. More...
 
Vector2getVertices ()
 Returns a pointer to the array of vertices. More...
 
const Vector2getVertices () const
 Returns a const pointer to the array of vertices. More...
 
float getElevation (unsigned int nodeID, const Vector2 &p) const
 Computes the elevation at a particular point based on the given node's geometry. More...
 
Vector2 getGradient (unsigned int nodeID, const Vector2 &p) const
 Computes the gradient at a particular point based on the given node's geometry. More...
 
void setVertexCount (size_t count)
 Allocates memory for the given number of vertices. All previous vertices will be deleted. More...
 
void setVertex (unsigned int i, float x, float y)
 Sets the value of the ith vertex. More...
 
void setNodeCount (size_t count)
 Allocates memory for the given number of nodes. All previous nodes will be deleted. More...
 
void setEdgeCount (size_t count)
 Allocates memory for the given number of edges. All previous edges will be deleted. More...
 
void setObstacleCount (size_t count)
 Allocates memory for the given number of obstacles. All previous obstacles will be delete.d. More...
 
bool finalize ()
 After initializing the navigation mesh's components this function needs to be called to make the mesh functional.
 
bool addGroup (const std::string &grpName, size_t grpSize)
 Adds a group of polygons to the navigation mesh. More...
 
std::vector
< Agents::ObstacleVertexList
getObstacles ()
 Gets the navigation mesh's obstacles for the simulator. More...
 
- Public Member Functions inherited from Menge::Resource
 Resource (const std::string &fileName)
 Constructor. More...
 
void destroy ()
 This supplants the destructor. More...
 
const std::string & getName () const
 Return the file name for this resource. More...
 
int incRef ()
 Increment references to the managed data. More...
 
int decRef ()
 Decrement references to the managed data. More...
 
bool isUnreferenced () const
 Reports if the data is referenced. More...
 

Static Public Member Functions

static Resourceload (const std::string &fileName)
 Parses a navigation mesh definition and returns a pointer to it. More...
 

Static Public Attributes

static const std::string LABEL
 The unique label for this data type to be used with resource management.
 

Protected Member Functions

 ~NavMesh ()
 Destructor.
 
- Protected Member Functions inherited from Menge::Resource
virtual ~Resource ()
 Virtual destructor.
 

Protected Attributes

size_t _vCount
 The number of vertices.
 
Vector2_vertices
 An array containing all vertices.
 
size_t _nCount
 The number of nodes (aka polygons in the mesh).
 
NavMeshNode_nodes
 An array containing all nodes.
 
size_t _eCount
 The number of edges (aka portals or shared edges between polygons).
 
NavMeshEdge_edges
 An array containing all edges.
 
size_t _obstCount
 The number of obstacles in the scene.
 
NavMeshObstacle_obstacles
 An array of obstacles.
 
std::map< const std::string,
NMNodeGroup
_nodeGroups
 The mapping from node group name to an instance of a NMNodeGroup.
 
- Protected Attributes inherited from Menge::Resource
const std::string _fileName
 The file which contains the resource's data.
 
int _refCount
 The number of data wrappers using this managed data.
 
SimpleLock _lock
 Simple lock to handle reference counts safely.
 

Friends

class NavMeshFactory
 
class PathPlanner
 

Detailed Description

The class for defining a navigation mesh. A decomposition of the free space into a connected mesh of convex (or near convex) polygons used for global planning in planar or non-planar environments.

It represents the minimum data required to do path planning. The navigation mesh is represented in 2.5D. The boundaries of mesh's polygons are only defined on the ground plane. The nodes themselves include a definition of the polygon's plane off the plane. Likewise, the vertices all lie on the plane.

Constructor & Destructor Documentation

Menge::NavMesh::NavMesh ( const std::string &  name)

Constructor.

Parameters
nameThe name of the underlying navigation mesh.

Member Function Documentation

bool Menge::NavMesh::addGroup ( const std::string &  grpName,
size_t  grpSize 
)

Adds a group of polygons to the navigation mesh.

The group name must be unique from all other group names in the navigation mesh. The number of polygons in the group extends the number of reported nodes in the mesh (see NavMesh::getNodeCount). Even if the nodes are not yet defined at this point, they are allocated and considered viable.

Parameters
grpNameThe name of the group.
grpSizeThe number of nodes in the group.
Returns
Returns a boolean reporting success (true) or failure (false).
NavMeshEdge & Menge::NavMesh::getEdge ( unsigned int  i)

Returns a reference to the ith edge.

Parameters
iThe index of the desired edge. The validitity of the index is only tested in debug build.
Returns
A reference to the ith edge.
const NavMeshEdge & Menge::NavMesh::getEdge ( unsigned int  i) const

Returns a const reference to the ith edge.

Parameters
iThe index of the desired edge. The validitity of the index is only tested in debug build.
Returns
A const reference to the ith edge.
size_t Menge::NavMesh::getEdgeCount ( ) const
inline

Reports the number of edges in the navigation mesh.

Returns
The integer number of edges.
float Menge::NavMesh::getElevation ( unsigned int  nodeID,
const Vector2 p 
) const

Computes the elevation at a particular point based on the given node's geometry.

Parameters
nodeIDThe node to use in computing elevation.
pThe point to evaluate the elevation for.
Returns
The elevation at point p based on the geometry of nodeID.
Vector2 Menge::NavMesh::getGradient ( unsigned int  nodeID,
const Vector2 p 
) const

Computes the gradient at a particular point based on the given node's geometry.

Parameters
nodeIDThe node to use in computing gradient.
pThe point to evaluate the gradient for.
Returns
The gradient at point p based on the geometry of nodeID.
NavMeshNode & Menge::NavMesh::getNode ( unsigned int  i)

Returns a reference to the ith node.

Parameters
iThe index of the desired node. The validitity of the index is only tested in debug build.
Returns
A reference to the ith node.
const NavMeshNode & Menge::NavMesh::getNode ( unsigned int  i) const

Returns a const reference to the ith node.

Parameters
iThe index of the desired node. The validitity of the index is only tested in debug build.
Returns
A const reference to the ith node.
size_t Menge::NavMesh::getNodeCount ( ) const
inline

Reports the number of nodes in the navigation mesh.

Returns
Thenumber of nodes.
NavMeshObstacle & Menge::NavMesh::getObstacle ( unsigned int  i)

Returns a reference to the ith obstacle.

Parameters
iThe index of the desired obstacle. The validity of the index is only tested in debug build.
Returns
A reference to the ith obstacle.
const NavMeshObstacle & Menge::NavMesh::getObstacle ( unsigned int  i) const

Returns a const reference to the ith obstacle.

Parameters
iThe index of the desired obstacle. The validity of the index is only tested in debug build.
Returns
A reference to the ith obstacle.
size_t Menge::NavMesh::getObstacleCount ( ) const
inline

Returns the number of obstacles connected to this node.

Returns
The number of attached obstacles.
std::vector< Agents::ObstacleVertexList > Menge::NavMesh::getObstacles ( )

Gets the navigation mesh's obstacles for the simulator.

Returns
Vertex lists of the various obstacles
size_t Menge::NavMesh::getVertexCount ( ) const
inline

Reports the number of vertices in the navigation mesh.

Returns
The number of vertices.
Vector2* Menge::NavMesh::getVertices ( )
inline

Returns a pointer to the array of vertices.

Returns
The pointer to the array of vertices.
const Vector2* Menge::NavMesh::getVertices ( ) const
inline

Returns a const pointer to the array of vertices.

Returns
The const pointer to the array of vertices.
Resource * Menge::NavMesh::load ( const std::string &  fileName)
static

Parses a navigation mesh definition and returns a pointer to it.

This function works in conjunction with the ResourceManager. That is why it returns a pointer, not to a NavMesh, but to a Resource. The ResourceManager uses it to load and instantiate VectorField instances.

Parameters
fileNameThe path to the file containing the NavMesh definition.
Returns
A pointer to the new NavMesh (if the file is valid), NULL if invalid.
void Menge::NavMesh::setEdgeCount ( size_t  count)

Allocates memory for the given number of edges. All previous edges will be deleted.

Parameters
countThe number of edges.
void Menge::NavMesh::setNodeCount ( size_t  count)

Allocates memory for the given number of nodes. All previous nodes will be deleted.

Parameters
countThe number of nodes.
void Menge::NavMesh::setObstacleCount ( size_t  count)

Allocates memory for the given number of obstacles. All previous obstacles will be delete.d.

Parameters
countThe number of obstacles.
void Menge::NavMesh::setVertex ( unsigned int  i,
float  x,
float  y 
)

Sets the value of the ith vertex.

Parameters
iThe index of the vertex. Validity of the index is only tested in the debug build.
xThe x-value of the vertex.
yThe y-value of the vertex.
void Menge::NavMesh::setVertexCount ( size_t  count)

Allocates memory for the given number of vertices. All previous vertices will be deleted.

Parameters
countThe number of vertices.

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