-
Notifications
You must be signed in to change notification settings - Fork 20
/
Bresenham.h
42 lines (33 loc) · 1.04 KB
/
Bresenham.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
#ifndef BRESENHAM_H
#define BRESENHAM_H
#include "map.h"
#include "node.h"
#include <list>
class iBresenham {
protected:
void bresenham3d(int x1, int y1, int z1, const int x2, const int y2, const int z2); // 3D Bresenham algorithm
virtual bool ProcessPoint(int x, int y, int z) = 0; // Processes point in line. Return false, if line processing should be stopped
};
class LineOfSight : public iBresenham {
private:
bool force_stopped;
const Map& map;
protected:
virtual bool ProcessPoint(int i, int j, int h);
public:
LineOfSight(const Map&);
bool line_of_sight(int i0, int j0, int h0, int i1, int j1, int h1);
bool line_of_sight(const Node& from, const Node& to);
};
class Liner : public iBresenham {
private:
const Map& map;
std::list<Node> *path;
protected:
virtual bool ProcessPoint(int i, int j, int h);
public:
Liner(const Map&, std::list<Node> *init_path);
void append_line(int i0, int j0, int h0, int i1, int j1, int h1);
void append_line(const Node &from, const Node &to);
};
#endif //BRESENHAM_H