-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpath_planning.hpp
More file actions
88 lines (71 loc) · 2.53 KB
/
path_planning.hpp
File metadata and controls
88 lines (71 loc) · 2.53 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef _PATH_PLANNING_H
#define _PATH_PLANNING_H
#include "util.hpp"
#include "Event.hpp"
using namespace std;
class BoustrophedonCell;
class Obstacle;
class Polygon;
class SurveyArea;
segment_2d scanLine(double xCoord, Polygon *poly);
intersect_seq_t line_intersect(Polygon *poly, IEvent *eventPtr);
intersect_seq_t line_intersect(BoustrophedonCell *cell, IEvent *eventPtr);
pair<intersect_t, intersect_t> eventLine(SurveyArea *sa, IEvent *event);
class Polygon {
public:
enum polyTypes {INNER, OUTER};
// accepts 2d array of vertices of the survey area
Polygon(double coords[][2], int num_of_pts, polyTypes polyType);
vector<IEvent *> generateEvents(string startEventName, string endEventName, bool sorted);
inline pt_seq_t getVertices() { return vertices; }
inline edge_seq_t getEdges() { return edges; }
protected:
pt_seq_t vertices;
edge_seq_t edges;
polyTypes polyType;
private:
polygon_2d poly;
};
class SurveyArea : public Polygon {
public:
SurveyArea(double (*coords)[2], int num_of_pts);
~SurveyArea();
vector<IEvent *> generateEvents(bool sorted = true);
void update(IEvent *event);
vector<BoustrophedonCell *> openCells(IEvent *event,
vector<IEvent *>::iterator botEventIter, vector<IEvent *>::iterator topEventIter);
void closeCells(IEvent *event);
void updateCells(IEvent *event);
vector<BoustrophedonCell *> generateBCells();
inline vector<Obstacle *> getObstacles() { return obstacles; }
private:
vector<BoustrophedonCell *> cells;
vector<Obstacle *> obstacles;
};
class Obstacle : public Polygon {
public:
Obstacle(double coords[][2], int num_of_pts);
vector<IEvent *> generateEvents(bool sorted = true);
};
class BoustrophedonCell {
public:
BoustrophedonCell(double leftStartPoint, const segment_2d *startCeilSegPtr, const segment_2d *startFloorSegPtr, SurveyArea *sa);
// void update(IEvent *event);
void terminate(double rightEndPoint);
bool affected(IEvent *event);
inline void addCeilSegPtr(const segment_2d* ceilSegPtr) { ceilSegPtrs.push_back(ceilSegPtr); }
inline void addFloorSegPtr(const segment_2d* floorSegPtr) { floorSegPtrs.push_back(floorSegPtr); }
inline double fromX() { return start; }
inline double tillX() { return end; }
inline vector<const segment_2d*> getCeilSegPtrs() { return ceilSegPtrs; }
inline vector<const segment_2d*> getFloorSegPtrs() { return floorSegPtrs; }
inline SurveyArea *within() { return surveyArea; }
private:
bool terminated;
double start;
double end;
vector<const segment_2d*> ceilSegPtrs;
vector<const segment_2d*> floorSegPtrs;
SurveyArea *surveyArea;
};
#endif