-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdijkstra.h
67 lines (61 loc) · 1.62 KB
/
dijkstra.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef DIJKSTRA_H
#define DIJKSTRA_H
#include <QPointF>
#include <unordered_map>
#include "environment.h"
#include <vector>
#include <list>
#include <QList>
using namespace std;
struct Point{
int x;
int y;
float value;
Point* parent;
};
struct Step{
int x;
int y;
float value;
Step(int x_, int y_, float value_):x(x_), y(y_), value(value_){};
};
static vector<Step> Move = {Step(-1, 1, 1.4142),
Step(0, 1, 1.0),
Step(1, 1, 1.4142),
Step(1, 0, 1.0),
Step(1, -1, 1.4142),
Step(0, -1, 1.0),
Step(-1, -1, 1.4142),
Step(-1, 0, 1.0)};
class Dijkstra
{
public:
Dijkstra();
Dijkstra(Environment* env, QPointF start, QPointF destination, float radius);
void planning();
int calcKeyFromPoint(const Point &point);
int calcNextKey(const int ¤tKey, int index);
int getMinfromOpen();
bool inClosed(int key);
bool inOpen(int key);
void calcPlanningPath();
void calcVisitedPath();
Point startPoint;
Point destinationPoint;
unordered_map<int, Point> global_map; //全局网格地图
//算法的辅助队列
list<int> open;
list<int> closed;
//存储访问过的节点
vector<int> visitedPoint;
vector<int> path;
QList<QPointF> planningPath;
QList<QPointF> visitedPath;
int width;
int high;
int min_x;
int min_y;
int grideSize;
private:
};
#endif // DIJKSTRA_H