Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Roadmap.h

00001 #ifndef ROADMAP_H
00002 #define ROADMAP_H
00003 
00004 #include "ConMath.h"
00005 #include <vector>
00006 #include <string>
00007 
00008 
00009 #include "path.h"
00010 
00011 #include "config.h"
00012 #include "entity.h"
00013 
00014 /*
00015   The Roadmap is a set of 3D paths (edges) that intersect at nodes. Thus it has a representation
00016   as an undirected graph with the lengths of the paths as the weight of the edges. In order to avoid
00017   copying unnecessary 3D data, a subspace is a subset of the Roadmap, but in a discrete representation.
00018 */
00019 
00020 class Roadmap : public Entity{
00021 public:
00022   typedef enum{
00023         NO_ACCESS,
00024         INVALID_ID,
00025         NO_NODE
00026   } Error;
00027 
00028   Roadmap(const ConStruct& con);
00029   Roadmap() : edges(0), nodes(0), discrete(0) {};
00030   virtual ~Roadmap();
00031 
00032   /*
00033     Different roadmaps (GVG, vertex graph) can determine criteria
00034         for passable subspaces by overriding the member function.
00035   */
00036   virtual DiscreteGraph PassableSubspace() const;
00037 
00038   virtual Path GeneratePath(const Vector &start, const Vector &goal, const DiscreteGraph& subspace) const;
00039 
00040   //returns the edge's index and a point on the edge to access
00041   virtual Path::Point Access(const Vector& pos, int &edge, const DiscreteGraph& subspace) const;
00042 
00043   //returns the id of the node at the specifed position
00044   //throws NO_NODE if the position is not "close" to a node
00045   int GetNodeID(const Vector& position) const;
00046 
00047   //given the id of a node returns the ids of edges that connect to it
00048   std::vector<int> GetAdjoiningEdges(const int node_id) const;
00049 
00050   //returns Path representation of edge given the edge id
00051   const Path& GetEdge(const int edge_id) const;
00052 
00053   //adds edge to the roadmap (linking to it based on endpts) and returns new edge id
00054   int AddEdge(const Path& p);
00055 
00056   void RemoveEdge(const int edge_id);
00057 
00058   virtual void Render (void)=0;
00059 
00060 protected:
00061 
00062   class Edge : public Path {
00063   public:
00064         Edge(const ConStruct& con);
00065         Edge();
00066         int getBeginNode() const { return begin_node; };
00067         int getEndNode() const { return end_node; };
00068         bool isForward(const int begin, const int end) const;
00069         Edge& operator =(const Edge& e);
00070 
00071   protected:
00072         int begin_node, end_node;
00073   };
00074 
00075   struct NodeInfo{
00076         int target;
00077         int edge;
00078         bool forward;
00079   };
00080 
00081   class Node{
00082   public:
00083         Node(const int initid, const Vector &pos);
00084         Node(const Node &in);
00085         Node();
00086         ~Node();
00087 
00088         void Link(const NodeInfo& info);
00089         NodeInfo getNeighborbyID(const int request) const;
00090         NodeInfo getNeighbor(const int index) const;
00091         int getNeighborCount() const;
00092 
00093         Node& operator =(const Node& n);
00094 
00095   protected:
00096         int id;
00097         std::vector<NodeInfo> neighbors;
00098         Vector coords;
00099   };
00100   friend class Node;
00101 
00102   std::vector<Edge> edges;
00103   std::vector<Node> nodes;
00104   DiscreteGraph discrete;
00105   private:
00106 };
00107 
00108 #endif

Generated on Fri Jan 12 14:15:02 2007 for Construct by  doxygen 1.4.3-20050530