gpc.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Project: Generic Polygon Clipper
5 
6  A new algorithm for calculating the difference, intersection,
7  exclusive-or or union of arbitrary polygon sets.
8 
9 File: gpc.h
10 Author: Alan Murta (email: gpc@cs.man.ac.uk)
11 Version: 2.32
12 Date: 17th December 2004
13 
14 Copyright: (C) 1997-2004, Advanced Interfaces Group,
15  University of Manchester.
16 
17  This software is free for non-commercial use. It may be copied,
18  modified, and redistributed provided that this copyright notice
19  is preserved on all copies. The intellectual property rights of
20  the algorithms used reside with the University of Manchester
21  Advanced Interfaces Group.
22 
23  You may not use this software, in whole or in part, in support
24  of any commercial product without the express consent of the
25  author.
26 
27  There is no warranty or other guarantee of fitness of this
28  software for any purpose. It is provided solely "as is".
29 
30 ===========================================================================
31 */
32 
33 #ifndef gpc_h_
34 #define gpc_h_
35 
36 #include <cstdio>
37 
38 
39 /*
40 ===========================================================================
41  Constants
42 ===========================================================================
43 */
44 
45 /* Increase GPC_EPSILON to encourage merging of near coincident edges */
46 /* */
47 /* For example: #define GPC_EPSILON (DBL_EPSILON*1000000000) */
48 #define GPC_EPSILON (DBL_EPSILON)
49 
50 #define GPC_VERSION "2.32"
51 
52 
53 /*
54 ===========================================================================
55  Public Data Types
56 ===========================================================================
57 */
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 typedef enum /* Set operation type */
63 {
64  GPC_DIFF, /* Difference */
65  GPC_INT, /* Intersection */
66  GPC_XOR, /* Exclusive or */
67  GPC_UNION /* Union */
68 } gpc_op;
69 
70 typedef struct /* Polygon vertex structure */
71 {
72  double x; /* Vertex x component */
73  double y; /* vertex y component */
74 } gpc_vertex;
75 
76 typedef struct /* Vertex list structure */
77 {
78  int num_vertices; /* Number of vertices in list */
79  gpc_vertex *vertex; /* Vertex array pointer */
81 
82 typedef struct /* Polygon set structure */
83 {
84  int num_contours; /* Number of contours in polygon */
85  int *hole; /* Hole / external contour flags */
86  gpc_vertex_list *contour; /* Contour array pointer */
87 } gpc_polygon;
88 
89 typedef struct /* Tristrip set structure */
90 {
91  int num_strips; /* Number of tristrips */
92  gpc_vertex_list *strip; /* Tristrip array pointer */
93 } gpc_tristrip;
94 
95 
96 /*
97 ===========================================================================
98  Public Function Prototypes
99 ===========================================================================
100 */
101 
102 int gpc_polygon_clip (gpc_op set_operation,
103  gpc_polygon *subject_polygon,
104  gpc_polygon *clip_polygon,
105  gpc_polygon *result_polygon);
106 
107 void gpc_free_polygon (gpc_polygon *polygon);
108 
109 #if 0 /* These functions are not used in vgl_clip */
110 
111 void gpc_read_polygon (FILE *infile_ptr,
112  int read_hole_flags,
113  gpc_polygon *polygon);
114 
115 void gpc_write_polygon (FILE *outfile_ptr,
116  int write_hole_flags,
117  gpc_polygon *polygon);
118 
119 void gpc_add_contour (gpc_polygon *polygon,
120  gpc_vertex_list *contour,
121  int hole);
122 
123 void gpc_tristrip_clip (gpc_op set_operation,
124  gpc_polygon *subject_polygon,
125  gpc_polygon *clip_polygon,
126  gpc_tristrip *result_tristrip);
127 
128 void gpc_polygon_to_tristrip (gpc_polygon *polygon,
129  gpc_tristrip *tristrip);
130 
131 void gpc_free_tristrip (gpc_tristrip *tristrip);
132 
133 #endif /* 0 */
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 
139 #endif /* gpc_h_ */
140 
141 /*
142 ===========================================================================
143  End of file: gpc.h
144 ===========================================================================
145 */
double y
Definition: gpc.h:73
gpc_op
Definition: gpc.h:62
Definition: gpc.h:64
gpc_vertex_list * contour
Definition: gpc.h:86
Definition: gpc.h:65
Definition: gpc.h:66
gpc_vertex * vertex
Definition: gpc.h:79
int num_contours
Definition: gpc.h:84
int * hole
Definition: gpc.h:85
Definition: gpc.h:70
int num_vertices
Definition: gpc.h:78
int num_strips
Definition: gpc.h:91
Definition: gpc.h:67
void gpc_free_polygon(gpc_polygon *polygon)
int gpc_polygon_clip(gpc_op set_operation, gpc_polygon *subject_polygon, gpc_polygon *clip_polygon, gpc_polygon *result_polygon)
double x
Definition: gpc.h:72
gpc_vertex_list * strip
Definition: gpc.h:92