lejos.robotics.pathfinding
Interface NavigationMesh

All Known Implementing Classes:
FourWayGridMesh

public interface NavigationMesh

A navigation mesh is a set of nodes covering a map area which represent branching pathways for the vehicle to move from one location to another. This interface is used by classes which build navigation meshes.

Author:
BB

Method Summary
 int addNode(Node node, int neighbors)
          Adds a node to this set and connects it with a number of neighboring nodes.
 boolean connect(Node node1, Node node2)
          Attempts to connect two nodes together by adding them as neighbors.
 boolean disconnect(Node node1, Node node2)
          Disconnects two nodes by removing them as neighbors.
 java.util.Collection<Node> getMesh()
          Returns a collection of all nodes within this navigation mesh.
 void regenerate()
          Throws away the previous set of nodes and recalculates them all.
 boolean removeNode(Node node)
          Removes a node from the set and removes any existing connections with its neighbors.
 

Method Detail

addNode

int addNode(Node node,
            int neighbors)
Adds a node to this set and connects it with a number of neighboring nodes. If it is unable to find any neighbors it will return 0. This might occur because the node is outside of the bounded area of the map.

Parameters:
node - The unconnected node to add to this mesh. Will be connected with others in the set.
neighbors - The maximum number of neighbors to attempt to connect with.
Returns:
the number of neighboring nodes it was able to connect with

removeNode

boolean removeNode(Node node)
Removes a node from the set and removes any existing connections with its neighbors. Note: There is no guarantee it is disconnecting from only nodes in this mesh. This method will disconnect the node from all the nodes registered as neighbors.

Parameters:
node - The node to remove.
Returns:
Returns true if the node was removed, false if it did not exist in this set.

connect

boolean connect(Node node1,
                Node node2)
Attempts to connect two nodes together by adding them as neighbors. If map data exists for this NavigationMesh, it will check the map data to see if the connection intersects or comes too close to map geometry. If it does they will not be connected and this method returns false.

Parameters:
node1 -
node2 -
Returns:
Boolean value, true if the nodes were connected successfully, false if they could not connect.

disconnect

boolean disconnect(Node node1,
                   Node node2)
Disconnects two nodes by removing them as neighbors. If they were not previously connected it returns false.

Parameters:
node1 -
node2 -
Returns:
Returns false if they were not previously connected.

getMesh

java.util.Collection<Node> getMesh()
Returns a collection of all nodes within this navigation mesh.

Returns:
A Collection of Nodes.

regenerate

void regenerate()
Throws away the previous set of nodes and recalculates them all. If any setting were changed, such as the spacing between nodes, then it will recalculate them with the new settings.