00001 // -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*- 00002 #ifndef __ROADMAP_H__ 00003 #define __ROADMAP_H__ 00004 00005 #include <vector> 00006 #include <boost/shared_ptr.hpp> 00007 #include "Configuration.h" 00008 #include "RoadmapNode.h" 00009 #include "exportdef.h" 00010 00011 namespace PathEngine{ 00012 class PathPlanner; 00013 class Roadmap; 00014 typedef boost::shared_ptr<Roadmap> RoadmapPtr; 00015 00019 class HRPPLANNER_API Roadmap{ 00020 public: 00024 Roadmap(PathPlanner *planner) : planner_(planner), m_nEdges(0) {} 00025 00031 ~Roadmap(); 00032 00037 void addNode(RoadmapNodePtr node) { nodes_.push_back(node); } 00038 00044 void addEdge(RoadmapNodePtr from, RoadmapNodePtr to); 00045 00052 bool removeEdge(RoadmapNodePtr from, RoadmapNodePtr to); 00053 00060 void integrate(RoadmapPtr rdmp); 00061 00066 unsigned int nNodes() const { return nodes_.size(); } 00067 00068 unsigned int nEdges() const { return m_nEdges; } 00069 00075 RoadmapNodePtr node(unsigned int index); 00076 00083 void findNearestNode(const Configuration& cfg, RoadmapNodePtr &node, double &distance); 00084 00089 RoadmapNodePtr lastAddedNode(); 00090 00096 int indexOfNode(RoadmapNodePtr node); 00097 00104 std::vector<RoadmapNodePtr > DFS(RoadmapNodePtr startNode, RoadmapNodePtr goalNode); 00105 00112 void tryConnection(RoadmapNodePtr from, RoadmapNodePtr to, bool tryReversed=true); 00113 00117 void clear(); 00118 private: 00122 std::vector<RoadmapNodePtr> nodes_; 00123 PathPlanner *planner_; 00124 unsigned int m_nEdges; 00125 }; 00126 }; 00127 00128 #endif