Classes | Defines | Typedefs | Enumerations | Functions | Variables
gpc.c File Reference
#include "gpc/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  bbox_shape
struct  edge_shape
struct  it_shape
struct  lmt_shape
struct  p_shape
struct  sbt_t_shape
struct  st_shape
struct  v_shape

Defines

#define ABOVE   0
#define BELOW   1
#define CLIP   0
#define EQ(a, b)   (fabs((a) - (b)) <= GPC_EPSILON)
#define FALSE   0
#define FREE(p)   {if (p) {free(p); (p)= NULL;}}
#define FWD_MIN(v, i, n)
#define INVERT_TRISTRIPS   FALSE
#define LEFT   0
#define MALLOC(p, b, s, t)
#define N_EDGE(d, e, p, i, j)
#define NEXT_INDEX(i, n)   ((i + 1 ) % n)
#define NOT_FMAX(v, i, n)   (v[NEXT_INDEX(i, n)].vertex.y > v[i].vertex.y)
#define NOT_RMAX(v, i, n)   (v[PREV_INDEX(i, n)].vertex.y > v[i].vertex.y)
#define OPTIMAL(v, i, n)
#define P_EDGE(d, e, p, i, j)
#define PREV_INDEX(i, n)   ((i - 1 + n) % n)
#define REV_MIN(v, i, n)
#define RIGHT   1
#define SUBJ   1
#define TRUE   1
#define VERTEX(e, p, s, x, y)

Typedefs

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

Enumerations

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

Functions

static void add_edge_to_aet (edge_node **aet, edge_node *edge, edge_node *prev)
static void add_intersection (it_node **it, edge_node *edge0, edge_node *edge1, double x, double y)
static void add_left (polygon_node *p, double x, double y)
static void add_local_min (polygon_node **p, edge_node *edge, double x, double y)
static void add_right (polygon_node *p, double x, double y)
static void add_st_edge (st_node **st, it_node **it, edge_node *edge, double dy)
static void add_to_sbtree (int *entries, sb_tree **sbtree, double y)
static void add_vertex (vertex_node **t, double x, double y)
static edge_node ** bound_list (lmt_node **lmt, double y)
static void build_intersection_table (it_node **it, edge_node *aet, double dy)
static edge_nodebuild_lmt (lmt_node **lmt, sb_tree **sbtree, int *sbt_entries, gpc_polygon *p, int type, gpc_op op)
static void build_sbt (int *entries, double *sbt, sb_tree *sbtree)
static int count_contours (polygon_node *polygon)
static int count_optimal_vertices (gpc_vertex_list c)
static int count_tristrips (polygon_node *tn)
static bboxcreate_contour_bboxes (gpc_polygon *p)
static void free_sbtree (sb_tree **sbtree)
void gpc_add_contour (gpc_polygon *p, gpc_vertex_list *new_contour, int hole)
void gpc_free_polygon (gpc_polygon *p)
void gpc_free_tristrip (gpc_tristrip *t)
void gpc_polygon_clip (gpc_op op, gpc_polygon *subj, gpc_polygon *clip, gpc_polygon *result)
void gpc_polygon_to_tristrip (gpc_polygon *s, gpc_tristrip *t)
void gpc_read_polygon (FILE *fp, int read_hole_flags, gpc_polygon *p)
void gpc_tristrip_clip (gpc_op op, gpc_polygon *subj, gpc_polygon *clip, gpc_tristrip *result)
void gpc_write_polygon (FILE *fp, int write_hole_flags, gpc_polygon *p)
static void insert_bound (edge_node **b, edge_node *e)
static void merge_left (polygon_node *p, polygon_node *q, polygon_node *list)
static void merge_right (polygon_node *p, polygon_node *q, polygon_node *list)
static void minimax_test (gpc_polygon *subj, gpc_polygon *clip, gpc_op op)
static void new_tristrip (polygon_node **tn, edge_node *edge, double x, double y)
static void reset_it (it_node **it)
static void reset_lmt (lmt_node **lmt)

Variables

const h_state next_h_state [3][6]

Define Documentation

#define ABOVE   0

Definition at line 60 of file gpc.c.

#define BELOW   1

Definition at line 61 of file gpc.c.

#define CLIP   0

Definition at line 63 of file gpc.c.

#define EQ (   a,
 
)    (fabs((a) - (b)) <= GPC_EPSILON)

Definition at line 75 of file gpc.c.

#define FALSE   0

Definition at line 53 of file gpc.c.

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

Definition at line 109 of file gpc.c.

#define FWD_MIN (   v,
  i,
 
)
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 83 of file gpc.c.

#define INVERT_TRISTRIPS   FALSE

Definition at line 66 of file gpc.c.

#define LEFT   0

Definition at line 57 of file gpc.c.

#define MALLOC (   p,
  b,
  s,
 
)
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.

#define N_EDGE (   d,
  e,
  p,
  i,
 
)
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.

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

Definition at line 78 of file gpc.c.

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

Definition at line 86 of file gpc.c.

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

Definition at line 91 of file gpc.c.

#define OPTIMAL (   v,
  i,
 
)
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.

#define P_EDGE (   d,
  e,
  p,
  i,
 
)
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.

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

Definition at line 77 of file gpc.c.

#define REV_MIN (   v,
  i,
 
)
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.

#define RIGHT   1

Definition at line 58 of file gpc.c.

#define SUBJ   1

Definition at line 64 of file gpc.c.

#define TRUE   1

Definition at line 54 of file gpc.c.

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

Definition at line 93 of file gpc.c.


Typedef Documentation

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

Enumeration Type Documentation

Enumerator:
UNBUNDLED 
BUNDLE_HEAD 
BUNDLE_TAIL 

Definition at line 145 of file gpc.c.

enum h_state
Enumerator:
NH 
BH 
TH 

Definition at line 138 of file gpc.c.

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

static void add_edge_to_aet ( edge_node **  aet,
edge_node edge,
edge_node prev 
) [static]

Definition at line 569 of file gpc.c.

static void add_intersection ( it_node **  it,
edge_node edge0,
edge_node edge1,
double  x,
double  y 
) [static]

Definition at line 618 of file gpc.c.

static void add_left ( polygon_node p,
double  x,
double  y 
) [static]

Definition at line 763 of file gpc.c.

static void add_local_min ( polygon_node **  p,
edge_node edge,
double  x,
double  y 
) [static]

Definition at line 851 of file gpc.c.

static void add_right ( polygon_node p,
double  x,
double  y 
) [static]

Definition at line 807 of file gpc.c.

static void add_st_edge ( st_node **  st,
it_node **  it,
edge_node edge,
double  dy 
) [static]

Definition at line 653 of file gpc.c.

static void add_to_sbtree ( int *  entries,
sb_tree **  sbtree,
double  y 
) [static]

Definition at line 357 of file gpc.c.

static void add_vertex ( vertex_node **  t,
double  x,
double  y 
) [static]

Definition at line 892 of file gpc.c.

static edge_node** bound_list ( lmt_node **  lmt,
double  y 
) [static]

Definition at line 323 of file gpc.c.

static void build_intersection_table ( it_node **  it,
edge_node aet,
double  dy 
) [static]

Definition at line 703 of file gpc.c.

static edge_node* build_lmt ( lmt_node **  lmt,
sb_tree **  sbtree,
int *  sbt_entries,
gpc_polygon p,
int  type,
gpc_op  op 
) [static]

Definition at line 425 of file gpc.c.

static void build_sbt ( int *  entries,
double *  sbt,
sb_tree sbtree 
) [static]

Definition at line 387 of file gpc.c.

static int count_contours ( polygon_node polygon) [static]

Definition at line 729 of file gpc.c.

static int count_optimal_vertices ( gpc_vertex_list  c) [static]

Definition at line 409 of file gpc.c.

static int count_tristrips ( polygon_node tn) [static]

Definition at line 881 of file gpc.c.

static bbox* create_contour_bboxes ( gpc_polygon p) [static]

Definition at line 926 of file gpc.c.

static void free_sbtree ( sb_tree **  sbtree) [static]

Definition at line 398 of file gpc.c.

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

Definition at line 1077 of file gpc.c.

Definition at line 1018 of file gpc.c.

Definition at line 1755 of file gpc.c.

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

Definition at line 1117 of file gpc.c.

Definition at line 1766 of file gpc.c.

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

Definition at line 1030 of file gpc.c.

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

Definition at line 1777 of file gpc.c.

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

Definition at line 1057 of file gpc.c.

static void insert_bound ( edge_node **  b,
edge_node e 
) [static]

Definition at line 276 of file gpc.c.

static void merge_left ( polygon_node p,
polygon_node q,
polygon_node list 
) [static]

Definition at line 780 of file gpc.c.

static void merge_right ( polygon_node p,
polygon_node q,
polygon_node list 
) [static]

Definition at line 825 of file gpc.c.

static void minimax_test ( gpc_polygon subj,
gpc_polygon clip,
gpc_op  op 
) [static]

Definition at line 959 of file gpc.c.

static void new_tristrip ( polygon_node **  tn,
edge_node edge,
double  x,
double  y 
) [static]

Definition at line 907 of file gpc.c.

static void reset_it ( it_node **  it) [static]

Definition at line 250 of file gpc.c.

static void reset_lmt ( lmt_node **  lmt) [static]

Definition at line 263 of file gpc.c.


Variable Documentation

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}
}

Definition at line 234 of file gpc.c.



libgpc
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:02:04