-
Notifications
You must be signed in to change notification settings - Fork 34
/
delaunay.h
97 lines (75 loc) · 2.4 KB
/
delaunay.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef DELAUNAY_H
#define DELAUNAY_H
/*
** delaunay.c : compute 2D delaunay triangulation in the plane.
** Copyright (C) 2005 Wael El Oraiby <[email protected]>
**
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef __cplusplus
extern "C" {
#endif
typedef double real;
typedef struct {
real x, y;
} del_point2d_t;
typedef struct {
/** input points count */
unsigned int num_points;
/** the input points */
del_point2d_t* points;
/** number of returned faces */
unsigned int num_faces;
/** the faces are given as a sequence: num verts, verts indices, num verts, verts indices...
* the first face is the external face */
unsigned int* faces;
} delaunay2d_t;
/*
* build the 2D Delaunay triangulation given a set of points of at least 3 points
*
* @points: point set given as a sequence of tuple x0, y0, x1, y1, ....
* @num_points: number of given point
* @preds: the incircle predicate
* @faces: the triangles given as a sequence: num verts, verts indices, num verts, verts indices.
* Note that the first face is the external face
* @return: the created topology
*/
delaunay2d_t* delaunay2d_from(del_point2d_t *points, unsigned int num_points);
/*
* release a delaunay2d object
*/
void delaunay2d_release(delaunay2d_t* del);
typedef struct {
/** input points count */
unsigned int num_points;
/** input points */
del_point2d_t* points;
/** number of triangles */
unsigned int num_triangles;
/** the triangles indices v0,v1,v2, v0,v1,v2 .... */
unsigned int* tris;
} tri_delaunay2d_t;
/**
* build a tri_delaunay2d_t out of a delaunay2d_t object
*/
tri_delaunay2d_t* tri_delaunay2d_from(delaunay2d_t* del);
/**
* release a tri_delaunay2d_t object
*/
void tri_delaunay2d_release(tri_delaunay2d_t* tdel);
#ifdef __cplusplus
}
#endif
#endif // DELAUNAY_H