Seamly2D
Code documentation
delaunay.h
Go to the documentation of this file.
1 #ifndef DELAUNAY_H
2 #define DELAUNAY_H
3 
4 /*
5 ** delaunay.c : compute 2D delaunay triangulation in the plane.
6 ** Copyright (C) 2005 Wael El Oraiby <wael.eloraiby@gmail.com>
7 **
8 **
9 ** This program is free software: you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation, either version 3 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** You should have received a copy of the GNU General Public License
20 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #define DEL_CIRCLE
24 
25 
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /* define the floating point type, comment to use float - Be careful "float" type will assert more often */
32 #define USE_DOUBLE
33 
34 #define FAST_PREDICATE 1 /* fast but floating point errors are more likely to occur */
35 #define LOOSE_PREDICATE 2 /* loose with epsilon defined in the delaunay file - errors will happen but less frequently */
36 #define EXACT_PREDICATE 3 /* use exact arithmetic - slower, but shouldn't produce any floating point error */
37 
38 #define PREDICATE EXACT_PREDICATE
39 
40 #if PREDICATE == EXACT_PREDICATE && !defined(USE_DOUBLE)
41 # define USE_DOUBLE
42 #endif
43 
44 #ifdef USE_DOUBLE
45 typedef double real;
46 #else
47 typedef float real;
48 #endif
49 
50 typedef struct {
51  real x, y;
53 
54 typedef struct {
55  /** input points count */
56  quint32 num_points;
57 
58  /** the input points */
60 
61  /** number of returned faces */
62  quint32 num_faces;
63 
64  /** the triangles given as a sequence: num verts, verts indices, num verts, verts indices first face is the external face */
65  quint32* faces;
66 } delaunay2d_t;
67 
69 
70 /*
71  * build the 2D Delaunay triangulation given a set of points of at least 3 points
72  *
73  * @param points point set given as a sequence of tuple x0, y0, x1, y1, ....
74  * @param num_points number of given point
75  * @return: the number of created faces
76  */
77 delaunay2d_t* delaunay2d_from(del_point2d_t *points, quint32 num_points);
78 
79 /*
80  * release a delaunay2d object
81  */
83 
84 #ifdef __cplusplus
85 }
86 #endif
87 
88 #endif // DELAUNAY_H
double real
Definition: delaunay.h:45
void delaunay2d_release(delaunay2d_t *del)
Definition: delaunay.cpp:1082
int(* incircle_predicate_t)(del_point2d_t *p0, del_point2d_t *p1, del_point2d_t *p2, del_point2d_t *p3)
Definition: delaunay.h:68
delaunay2d_t * delaunay2d_from(del_point2d_t *points, quint32 num_points)
Definition: delaunay.cpp:1008
quint32 * faces
Definition: delaunay.h:65
quint32 num_points
Definition: delaunay.h:56
quint32 num_faces
Definition: delaunay.h:62
del_point2d_t * points
Definition: delaunay.h:59