00001 #ifndef GRAPH_H 00002 #define GRAPH_H 00003 00004 #include "GridNodes.h" 00005 #include "GraphEdge.h" 00006 00007 00008 00017 00018 class GridNodes; 00019 class GraphEdge; 00020 class SearchDijkstra; 00021 00022 class Graph 00023 { 00024 public: 00025 //---------------------------------------------------------------------------------------------------------------------- 00032 //---------------------------------------------------------------------------------------------------------------------- 00033 Graph(int _width,int _height, int _precision,ngl::TransformStack *_t,ngl::Camera *_cam); 00034 //---------------------------------------------------------------------------------------------------------------------- 00036 //---------------------------------------------------------------------------------------------------------------------- 00037 ~Graph(); 00038 //---------------------------------------------------------------------------------------------------------------------- 00041 //---------------------------------------------------------------------------------------------------------------------- 00042 GridNodes* getNode(int _index); 00043 //---------------------------------------------------------------------------------------------------------------------- 00046 //---------------------------------------------------------------------------------------------------------------------- 00047 GraphEdge* getEdge(int _From, int _to); 00048 //---------------------------------------------------------------------------------------------------------------------- 00050 //---------------------------------------------------------------------------------------------------------------------- 00051 void addParticles(); 00052 //---------------------------------------------------------------------------------------------------------------------- 00054 //---------------------------------------------------------------------------------------------------------------------- 00055 void clearParticles(); 00056 //---------------------------------------------------------------------------------------------------------------------- 00058 //---------------------------------------------------------------------------------------------------------------------- 00059 void draw(); 00060 //---------------------------------------------------------------------------------------------------------------------- 00063 //---------------------------------------------------------------------------------------------------------------------- 00064 void assignOnOff(std::vector <int> _obstaclePositions); 00065 //---------------------------------------------------------------------------------------------------------------------- 00067 //---------------------------------------------------------------------------------------------------------------------- 00068 void sortNodes(); 00069 //---------------------------------------------------------------------------------------------------------------------- 00071 //---------------------------------------------------------------------------------------------------------------------- 00072 std::vector <ngl::Vec3> getObstacles(){return m_obstacles;} 00073 //---------------------------------------------------------------------------------------------------------------------- 00075 //---------------------------------------------------------------------------------------------------------------------- 00076 std::vector <ngl::Vec3> getNoObstacles(){return m_noObstacles;} 00077 //---------------------------------------------------------------------------------------------------------------------- 00079 //---------------------------------------------------------------------------------------------------------------------- 00080 inline ngl::TransformStack *getTransformStack() const {return m_tStack;} 00081 //---------------------------------------------------------------------------------------------------------------------- 00083 //---------------------------------------------------------------------------------------------------------------------- 00084 inline const ngl::Camera *getCamera() {return m_cam;} 00085 //---------------------------------------------------------------------------------------------------------------------- 00087 //---------------------------------------------------------------------------------------------------------------------- 00088 int inline getNumofNodes(){return m_numOfNodes;} 00089 //---------------------------------------------------------------------------------------------------------------------- 00091 //---------------------------------------------------------------------------------------------------------------------- 00092 void calculateEdges(); 00093 //---------------------------------------------------------------------------------------------------------------------- 00095 //---------------------------------------------------------------------------------------------------------------------- 00096 void setContours(); 00097 //---------------------------------------------------------------------------------------------------------------------- 00099 //---------------------------------------------------------------------------------------------------------------------- 00100 uint getInitialPosition(); 00101 //---------------------------------------------------------------------------------------------------------------------- 00103 //---------------------------------------------------------------------------------------------------------------------- 00104 std::vector <std::vector <GraphEdge *> > inline getEdgeList(){return m_edgeList;} 00105 //---------------------------------------------------------------------------------------------------------------------- 00108 //---------------------------------------------------------------------------------------------------------------------- 00109 std::vector <int> adjacentNodeEdges(int index); 00110 //---------------------------------------------------------------------------------------------------------------------- 00112 //---------------------------------------------------------------------------------------------------------------------- 00113 ngl::TransformStack *m_tStack; 00114 //---------------------------------------------------------------------------------------------------------------------- 00116 //---------------------------------------------------------------------------------------------------------------------- 00117 ngl::Camera *m_cam; 00118 00119 private: 00120 //---------------------------------------------------------------------------------------------------------------------- 00122 //---------------------------------------------------------------------------------------------------------------------- 00123 std::vector <GridNodes *> m_nodes; 00124 //---------------------------------------------------------------------------------------------------------------------- 00126 //---------------------------------------------------------------------------------------------------------------------- 00127 std::list <GraphEdge *> m_allEdges; 00128 //---------------------------------------------------------------------------------------------------------------------- 00130 //---------------------------------------------------------------------------------------------------------------------- 00131 std::vector <std::vector <GraphEdge *> > m_edgeList; 00132 //---------------------------------------------------------------------------------------------------------------------- 00134 //---------------------------------------------------------------------------------------------------------------------- 00135 std::vector <std::vector <GridNodes *> > m_nodeGridNodes; 00136 //---------------------------------------------------------------------------------------------------------------------- 00138 //---------------------------------------------------------------------------------------------------------------------- 00139 std::vector <ngl::Vec3> m_obstacles; 00140 //---------------------------------------------------------------------------------------------------------------------- 00142 //---------------------------------------------------------------------------------------------------------------------- 00143 std::vector <ngl::Vec3> m_noObstacles; 00144 //---------------------------------------------------------------------------------------------------------------------- 00146 //---------------------------------------------------------------------------------------------------------------------- 00147 std::vector <int> m_obstaclePositions; 00148 //---------------------------------------------------------------------------------------------------------------------- 00150 //---------------------------------------------------------------------------------------------------------------------- 00151 std::vector <int> m_noObstacleNodes; 00152 //---------------------------------------------------------------------------------------------------------------------- 00154 //---------------------------------------------------------------------------------------------------------------------- 00155 int m_width; 00156 //---------------------------------------------------------------------------------------------------------------------- 00158 //---------------------------------------------------------------------------------------------------------------------- 00159 int m_height; 00160 //---------------------------------------------------------------------------------------------------------------------- 00162 //---------------------------------------------------------------------------------------------------------------------- 00163 int m_precision; 00164 //---------------------------------------------------------------------------------------------------------------------- 00166 //---------------------------------------------------------------------------------------------------------------------- 00167 GLuint m_texID; 00168 //---------------------------------------------------------------------------------------------------------------------- 00170 //---------------------------------------------------------------------------------------------------------------------- 00171 int m_numOfNodes; 00172 //---------------------------------------------------------------------------------------------------------------------- 00174 //---------------------------------------------------------------------------------------------------------------------- 00175 GraphEdge *m_edge; 00176 //---------------------------------------------------------------------------------------------------------------------- 00178 //---------------------------------------------------------------------------------------------------------------------- 00179 SearchDijkstra* m_findPath; 00180 //---------------------------------------------------------------------------------------------------------------------- 00182 //---------------------------------------------------------------------------------------------------------------------- 00183 bool m_pathFound; 00184 00185 00186 }; 00187 00188 #endif // GRAPH_H