forked from tlvb/shull
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shull.h
50 lines (43 loc) · 974 Bytes
/
shull.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
#include <stdint.h>
#include <unistd.h>
#include <stdbool.h>
#include <unordered_set>
#include <unordered_map>
#define SHFLT double
#define PSHFLT "f"
class sh_triangle;
class sh_point {
public:
SHFLT x;
SHFLT y;
float value;
int idx;
std::unordered_set<int> neighbors; // index of neighbor point in points array
double grad[2];
};
class sh_edge {
public:
sh_point *p[2];
sh_triangle *t[2];
unsigned int flipcount;
};
class sh_triangle {
public:
sh_point *p[3];
sh_edge *e[3];
sh_point cc;
SHFLT ccr2;
};
typedef struct {
ll_node *hull_edges;
ll_node *internal_edges;
ll_node *triangles;
double minX = 180;
double minY = 90;
double maxX = -180;
double maxY = -90;
sh_point *pts;
} sh_triangulation_data;
int triangulate(sh_triangulation_data *td, sh_point *ps, size_t n);
int make_delaunay(sh_triangulation_data *td);
int delaunay(sh_triangulation_data *td, sh_point *ps, size_t n);