Muvicado HD
Loading...
Searching...
No Matches
gpc.c File Reference
#include "gpc.h"
#include <stdlib.h>
#include <float.h>
#include <math.h>
Include dependency graph for gpc.c:

Go to the source code of this file.

Classes

struct  v_shape
struct  p_shape
struct  edge_shape
struct  lmt_shape
struct  sbt_t_shape
struct  it_shape
struct  st_shape
struct  bbox_shape

Macros

#define FALSE   0
#define TRUE   1
#define LEFT   0
#define RIGHT   1
#define ABOVE   0
#define BELOW   1
#define CLIP   0
#define SUBJ   1
#define INVERT_TRISTRIPS   FALSE
#define EQ(a, b)
#define PREV_INDEX(i, n)
#define NEXT_INDEX(i, n)
#define OPTIMAL(v, i, n)
#define FWD_MIN(v, i, n)
#define NOT_FMAX(v, i, n)
#define REV_MIN(v, i, n)
#define NOT_RMAX(v, i, n)
#define VERTEX(e, p, s, x, y)
#define P_EDGE(d, e, p, i, j)
#define N_EDGE(d, e, p, i, j)
#define MALLOC(p, b, s, t)
#define FREE(p)

Typedefs

typedef struct v_shape vertex_node
typedef struct p_shape polygon_node
typedef struct edge_shape edge_node
typedef struct lmt_shape lmt_node
typedef struct sbt_t_shape sb_tree
typedef struct it_shape it_node
typedef struct st_shape st_node
typedef struct bbox_shape bbox

Enumerations

enum  vertex_type {
  NUL , EMX , ELI , TED ,
  ERI , RED , IMM , IMN ,
  EMN , EMM , LED , ILI ,
  BED , IRI , IMX , FUL
}
enum  h_state { NH , BH , TH }
enum  bundle_state { UNBUNDLED , BUNDLE_HEAD , BUNDLE_TAIL }

Functions

void gpc_free_polygon (gpc_polygon *p)
void gpc_read_polygon (FILE *fp, int read_hole_flags, gpc_polygon *p)
void gpc_write_polygon (FILE *fp, int write_hole_flags, gpc_polygon *p)
void gpc_add_contour (gpc_polygon *p, gpc_vertex_list *new_contour, int hole)
void gpc_polygon_clip (gpc_op op, gpc_polygon *subj, gpc_polygon *clip, gpc_polygon *result)
void gpc_free_tristrip (gpc_tristrip *t)
void gpc_polygon_to_tristrip (gpc_polygon *s, gpc_tristrip *t)
void gpc_tristrip_clip (gpc_op op, gpc_polygon *subj, gpc_polygon *clip, gpc_tristrip *result)

Variables

const h_state next_h_state [3][6]

Macro Definition Documentation

◆ ABOVE

#define ABOVE   0

Definition at line 60 of file gpc.c.

◆ BELOW

#define BELOW   1

Definition at line 61 of file gpc.c.

◆ CLIP

#define CLIP   0

Definition at line 63 of file gpc.c.

◆ EQ

#define EQ ( a,
b )
Value:
(fabs((a) - (b)) <= GPC_EPSILON)
#define GPC_EPSILON
Definition gpc.h:47

Definition at line 75 of file gpc.c.

◆ FALSE

#define FALSE   0

Definition at line 53 of file gpc.c.

◆ FREE

#define FREE ( p)
Value:
{if (p) {free(p); (p)= NULL;}}

Definition at line 109 of file gpc.c.

◆ FWD_MIN

#define FWD_MIN ( v,
i,
n )
Value:
((v[PREV_INDEX(i, n)].vertex.y >= v[i].vertex.y) \
&& (v[NEXT_INDEX(i, n)].vertex.y > v[i].vertex.y))
#define NEXT_INDEX(i, n)
Definition gpc.c:78
#define PREV_INDEX(i, n)
Definition gpc.c:77

Definition at line 83 of file gpc.c.

◆ INVERT_TRISTRIPS

#define INVERT_TRISTRIPS   FALSE

Definition at line 66 of file gpc.c.

◆ LEFT

#define LEFT   0

Definition at line 57 of file gpc.c.

◆ MALLOC

#define MALLOC ( p,
b,
s,
t )
Value:
{if ((b) > 0) { \
p= (t*)malloc(b); if (!(p)) { \
fprintf(stderr, "gpc malloc failure: %s\n", s); \
exit(0);}} else p= NULL;}

Definition at line 104 of file gpc.c.

◆ N_EDGE

#define N_EDGE ( d,
e,
p,
i,
j )
Value:
{(d)= (e); \
do {(d)= (d)->next;} while (!(d)->outp[(p)]); \
(i)= (d)->bot.x + (d)->dx * ((j)-(d)->bot.y);}

Definition at line 100 of file gpc.c.

◆ NEXT_INDEX

#define NEXT_INDEX ( i,
n )
Value:
((i + 1 ) % n)

Definition at line 78 of file gpc.c.

◆ NOT_FMAX

#define NOT_FMAX ( v,
i,
n )
Value:
(v[NEXT_INDEX(i, n)].vertex.y > v[i].vertex.y)

Definition at line 86 of file gpc.c.

◆ NOT_RMAX

#define NOT_RMAX ( v,
i,
n )
Value:
(v[PREV_INDEX(i, n)].vertex.y > v[i].vertex.y)

Definition at line 91 of file gpc.c.

◆ OPTIMAL

#define OPTIMAL ( v,
i,
n )
Value:
((v[PREV_INDEX(i, n)].y != v[i].y) || \
(v[NEXT_INDEX(i, n)].y != v[i].y))

Definition at line 80 of file gpc.c.

◆ P_EDGE

#define P_EDGE ( d,
e,
p,
i,
j )
Value:
{(d)= (e); \
do {(d)= (d)->prev;} while (!(d)->outp[(p)]); \
(i)= (d)->bot.x + (d)->dx * ((j)-(d)->bot.y);}

Definition at line 96 of file gpc.c.

◆ PREV_INDEX

#define PREV_INDEX ( i,
n )
Value:
((i - 1 + n) % n)

Definition at line 77 of file gpc.c.

◆ REV_MIN

#define REV_MIN ( v,
i,
n )
Value:
((v[PREV_INDEX(i, n)].vertex.y > v[i].vertex.y) \
&& (v[NEXT_INDEX(i, n)].vertex.y >= v[i].vertex.y))

Definition at line 88 of file gpc.c.

◆ RIGHT

#define RIGHT   1

Definition at line 58 of file gpc.c.

◆ SUBJ

#define SUBJ   1

Definition at line 64 of file gpc.c.

◆ TRUE

#define TRUE   1

Definition at line 54 of file gpc.c.

◆ VERTEX

#define VERTEX ( e,
p,
s,
x,
y )
Value:
{add_vertex(&((e)->outp[(p)]->v[(s)]), x, y); \
(e)->outp[(p)]->active++;}

Definition at line 93 of file gpc.c.

Typedef Documentation

◆ bbox

typedef struct bbox_shape bbox

◆ edge_node

typedef struct edge_shape edge_node

◆ it_node

typedef struct it_shape it_node

◆ lmt_node

typedef struct lmt_shape lmt_node

◆ polygon_node

typedef struct p_shape polygon_node

◆ sb_tree

typedef struct sbt_t_shape sb_tree

◆ st_node

typedef struct st_shape st_node

◆ vertex_node

typedef struct v_shape vertex_node

Enumeration Type Documentation

◆ bundle_state

Enumerator
UNBUNDLED 
BUNDLE_HEAD 
BUNDLE_TAIL 

Definition at line 145 of file gpc.c.

◆ h_state

enum h_state
Enumerator
NH 
BH 
TH 

Definition at line 138 of file gpc.c.

◆ vertex_type

Enumerator
NUL 
EMX 
ELI 
TED 
ERI 
RED 
IMM 
IMN 
EMN 
EMM 
LED 
ILI 
BED 
IRI 
IMX 
FUL 

Definition at line 118 of file gpc.c.

Function Documentation

◆ gpc_add_contour()

void gpc_add_contour ( gpc_polygon * p,
gpc_vertex_list * new_contour,
int hole )

Definition at line 1077 of file gpc.c.

◆ gpc_free_polygon()

void gpc_free_polygon ( gpc_polygon * p)

Definition at line 1018 of file gpc.c.

Here is the caller graph for this function:

◆ gpc_free_tristrip()

void gpc_free_tristrip ( gpc_tristrip * t)

Definition at line 1755 of file gpc.c.

◆ gpc_polygon_clip()

void gpc_polygon_clip ( gpc_op op,
gpc_polygon * subj,
gpc_polygon * clip,
gpc_polygon * result )

Definition at line 1117 of file gpc.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gpc_polygon_to_tristrip()

void gpc_polygon_to_tristrip ( gpc_polygon * s,
gpc_tristrip * t )

Definition at line 1766 of file gpc.c.

Here is the call graph for this function:

◆ gpc_read_polygon()

void gpc_read_polygon ( FILE * fp,
int read_hole_flags,
gpc_polygon * p )

Definition at line 1030 of file gpc.c.

◆ gpc_tristrip_clip()

void gpc_tristrip_clip ( gpc_op op,
gpc_polygon * subj,
gpc_polygon * clip,
gpc_tristrip * result )

Definition at line 1777 of file gpc.c.

Here is the caller graph for this function:

◆ gpc_write_polygon()

void gpc_write_polygon ( FILE * fp,
int write_hole_flags,
gpc_polygon * p )

Definition at line 1057 of file gpc.c.

Variable Documentation

◆ next_h_state

const h_state next_h_state[3][6]
Initial value:
=
{
{BH, TH, TH, BH, NH, NH},
{NH, NH, NH, NH, TH, TH},
{NH, NH, NH, NH, BH, BH}
}
@ NH
Definition gpc.c:140
@ TH
Definition gpc.c:142
@ BH
Definition gpc.c:141

Definition at line 234 of file gpc.c.