| 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.c
|
| 10 |
|
| Author: Alan Murta (email: gpc@cs.man.ac.uk)
|
| 11 |
|
| Version: 2.32
|
| 12 |
|
| Date: 17th December 2004
|
| 13 |
|
|
|
| 14 |
|
| Copyright: (C) 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 |
|
|
|
| 34 |
|
| /*
|
| 35 |
|
| ===========================================================================
|
| 36 |
|
| Includes
|
| 37 |
|
| ===========================================================================
|
| 38 |
|
| */
|
| 39 |
|
|
|
| 40 |
|
| #include "gpc.h"
|
| 41 |
|
| #include <stdlib.h>
|
| 42 |
|
| #include <float.h>
|
| 43 |
|
| #include <math.h>
|
| 44 |
|
|
|
| 45 |
|
|
|
| 46 |
|
| /*
|
| 47 |
|
| ===========================================================================
|
| 48 |
|
| Constants
|
| 49 |
|
| ===========================================================================
|
| 50 |
|
| */
|
| 51 |
|
|
|
| 52 |
|
| #ifndef TRUE
|
| 53 |
|
| #define FALSE 0
|
| 54 |
|
| #define TRUE 1
|
| 55 |
|
| #endif
|
| 56 |
|
|
|
| 57 |
|
| #define LEFT 0
|
| 58 |
|
| #define RIGHT 1
|
| 59 |
|
|
|
| 60 |
|
| #define ABOVE 0
|
| 61 |
|
| #define BELOW 1
|
| 62 |
|
|
|
| 63 |
|
| #define CLIP 0
|
| 64 |
|
| #define SUBJ 1
|
| 65 |
|
|
|
| 66 |
|
| #define INVERT_TRISTRIPS FALSE
|
| 67 |
|
|
|
| 68 |
|
|
|
| 69 |
|
| /*
|
| 70 |
|
| ===========================================================================
|
| 71 |
|
| Macros
|
| 72 |
|
| ===========================================================================
|
| 73 |
|
| */
|
| 74 |
|
|
|
| 75 |
|
| #define EQ(a, b) (fabs((a) - (b)) <= GPC_EPSILON)
|
| 76 |
|
|
|
| 77 |
|
| #define PREV_INDEX(i, n) ((i - 1 + n) % n)
|
| 78 |
|
| #define NEXT_INDEX(i, n) ((i + 1 ) % n)
|
| 79 |
|
|
|
| 80 |
|
| #define OPTIMAL(v, i, n) ((v[PREV_INDEX(i, n)].y != v[i].y) || \
|
| 81 |
|
| (v[NEXT_INDEX(i, n)].y != v[i].y))
|
| 82 |
|
|
|
| 83 |
|
| #define FWD_MIN(v, i, n) ((v[PREV_INDEX(i, n)].vertex.y >= v[i].vertex.y) \
|
| 84 |
|
| && (v[NEXT_INDEX(i, n)].vertex.y > v[i].vertex.y))
|
| 85 |
|
|
|
| 86 |
|
| #define NOT_FMAX(v, i, n) (v[NEXT_INDEX(i, n)].vertex.y > v[i].vertex.y)
|
| 87 |
|
|
|
| 88 |
|
| #define REV_MIN(v, i, n) ((v[PREV_INDEX(i, n)].vertex.y > v[i].vertex.y) \
|
| 89 |
|
| && (v[NEXT_INDEX(i, n)].vertex.y >= v[i].vertex.y))
|
| 90 |
|
|
|
| 91 |
|
| #define NOT_RMAX(v, i, n) (v[PREV_INDEX(i, n)].vertex.y > v[i].vertex.y)
|
| 92 |
|
|
|
| 93 |
|
| #define VERTEX(e,p,s,x,y) {add_vertex(&((e)->outp[(p)]->v[(s)]), x, y); \
|
| 94 |
|
| (e)->outp[(p)]->active++;}
|
| 95 |
|
|
|
| 96 |
|
| #define P_EDGE(d,e,p,i,j) {(d)= (e); \
|
| 97 |
|
| do {(d)= (d)->prev;} while (!(d)->outp[(p)]); \
|
| 98 |
|
| (i)= (d)->bot.x + (d)->dx * ((j)-(d)->bot.y);}
|
| 99 |
|
|
|
| 100 |
|
| #define N_EDGE(d,e,p,i,j) {(d)= (e); \
|
| 101 |
|
| do {(d)= (d)->next;} while (!(d)->outp[(p)]); \
|
| 102 |
|
| (i)= (d)->bot.x + (d)->dx * ((j)-(d)->bot.y);}
|
| 103 |
|
|
|
| 104 |
|
| #define MALLOC(p, b, s, t) {if ((b) > 0) { \
|
| 105 |
|
| p= (t*)malloc(b); if (!(p)) { \
|
| 106 |
|
| fprintf(stderr, "gpc malloc failure: %s\n", s); \
|
| 107 |
|
| exit(0);}} else p= NULL;}
|
| 108 |
|
|
|
| 109 |
|
| //#define FREE(p) {if (p) {free(p); (p)= NULL;}}
|
| 110 |
|
| #define FREE(p) { Safefree(p); (p)=NULL; }
|
| 111 |
|
|
|
| 112 |
|
|
|
| 113 |
|
| /*
|
| 114 |
|
| ===========================================================================
|
| 115 |
|
| Private Data Types
|
| 116 |
|
| ===========================================================================
|
| 117 |
|
| */
|
| 118 |
|
|
|
| 119 |
|
| typedef enum /* Edge intersection classes */
|
| 120 |
|
| {
|
| 121 |
|
| NUL, /* Empty non-intersection */
|
| 122 |
|
| EMX, /* External maximum */
|
| 123 |
|
| ELI, /* External left intermediate */
|
| 124 |
|
| TED, /* Top edge */
|
| 125 |
|
| ERI, /* External right intermediate */
|
| 126 |
|
| RED, /* Right edge */
|
| 127 |
|
| IMM, /* Internal maximum and minimum */
|
| 128 |
|
| IMN, /* Internal minimum */
|
| 129 |
|
| EMN, /* External minimum */
|
| 130 |
|
| EMM, /* External maximum and minimum */
|
| 131 |
|
| LED, /* Left edge */
|
| 132 |
|
| ILI, /* Internal left intermediate */
|
| 133 |
|
| BED, /* Bottom edge */
|
| 134 |
|
| IRI, /* Internal right intermediate */
|
| 135 |
|
| IMX, /* Internal maximum */
|
| 136 |
|
| FUL /* Full non-intersection */
|
| 137 |
|
| } vertex_type;
|
| 138 |
|
|
|
| 139 |
|
| typedef enum /* Horizontal edge states */
|
| 140 |
|
| {
|
| 141 |
|
| NH, /* No horizontal edge */
|
| 142 |
|
| BH, /* Bottom horizontal edge */
|
| 143 |
|
| TH /* Top horizontal edge */
|
| 144 |
|
| } h_state;
|
| 145 |
|
|
|
| 146 |
|
| typedef enum /* Edge bundle state */
|
| 147 |
|
| {
|
| 148 |
|
| UNBUNDLED, /* Isolated edge not within a bundle */
|
| 149 |
|
| BUNDLE_HEAD, /* Bundle head node */
|
| 150 |
|
| BUNDLE_TAIL /* Passive bundle tail node */
|
| 151 |
|
| } bundle_state;
|
| 152 |
|
|
|
| 153 |
|
| typedef struct v_shape /* Internal vertex list datatype */
|
| 154 |
|
| {
|
| 155 |
|
| double x; /* X coordinate component */
|
| 156 |
|
| double y; /* Y coordinate component */
|
| 157 |
|
| struct v_shape *next; /* Pointer to next vertex in list */
|
| 158 |
|
| } vertex_node;
|
| 159 |
|
|
|
| 160 |
|
| typedef struct p_shape /* Internal contour / tristrip type */
|
| 161 |
|
| {
|
| 162 |
|
| int active; /* Active flag / vertex count */
|
| 163 |
|
| int hole; /* Hole / external contour flag */
|
| 164 |
|
| vertex_node *v[2]; /* Left and right vertex list ptrs */
|
| 165 |
|
| struct p_shape *next; /* Pointer to next polygon contour */
|
| 166 |
|
| struct p_shape *proxy; /* Pointer to actual structure used */
|
| 167 |
|
| } polygon_node;
|
| 168 |
|
|
|
| 169 |
|
| typedef struct edge_shape
|
| 170 |
|
| {
|
| 171 |
|
| gpc_vertex vertex; /* Piggy-backed contour vertex data */
|
| 172 |
|
| gpc_vertex bot; /* Edge lower (x, y) coordinate */
|
| 173 |
|
| gpc_vertex top; /* Edge upper (x, y) coordinate */
|
| 174 |
|
| double xb; /* Scanbeam bottom x coordinate */
|
| 175 |
|
| double xt; /* Scanbeam top x coordinate */
|
| 176 |
|
| double dx; /* Change in x for a unit y increase */
|
| 177 |
|
| int type; /* Clip / subject edge flag */
|
| 178 |
|
| int bundle[2][2]; /* Bundle edge flags */
|
| 179 |
|
| int bside[2]; /* Bundle left / right indicators */
|
| 180 |
|
| bundle_state bstate[2]; /* Edge bundle state */
|
| 181 |
|
| polygon_node *outp[2]; /* Output polygon / tristrip pointer */
|
| 182 |
|
| struct edge_shape *prev; /* Previous edge in the AET */
|
| 183 |
|
| struct edge_shape *next; /* Next edge in the AET */
|
| 184 |
|
| struct edge_shape *pred; /* Edge connected at the lower end */
|
| 185 |
|
| struct edge_shape *succ; /* Edge connected at the upper end */
|
| 186 |
|
| struct edge_shape *next_bound; /* Pointer to next bound in LMT */
|
| 187 |
|
| } edge_node;
|
| 188 |
|
|
|
| 189 |
|
| typedef struct lmt_shape /* Local minima table */
|
| 190 |
|
| {
|
| 191 |
|
| double y; /* Y coordinate at local minimum */
|
| 192 |
|
| edge_node *first_bound; /* Pointer to bound list */
|
| 193 |
|
| struct lmt_shape *next; /* Pointer to next local minimum */
|
| 194 |
|
| } lmt_node;
|
| 195 |
|
|
|
| 196 |
|
| typedef struct sbt_t_shape /* Scanbeam tree */
|
| 197 |
|
| {
|
| 198 |
|
| double y; /* Scanbeam node y value */
|
| 199 |
|
| struct sbt_t_shape *less; /* Pointer to nodes with lower y */
|
| 200 |
|
| struct sbt_t_shape *more; /* Pointer to nodes with higher y */
|
| 201 |
|
| } sb_tree;
|
| 202 |
|
|
|
| 203 |
|
| typedef struct it_shape /* Intersection table */
|
| 204 |
|
| {
|
| 205 |
|
| edge_node *ie[2]; /* Intersecting edge (bundle) pair */
|
| 206 |
|
| gpc_vertex point; /* Point of intersection */
|
| 207 |
|
| struct it_shape *next; /* The next intersection table node */
|
| 208 |
|
| } it_node;
|
| 209 |
|
|
|
| 210 |
|
| typedef struct st_shape /* Sorted edge table */
|
| 211 |
|
| {
|
| 212 |
|
| edge_node *edge; /* Pointer to AET edge */
|
| 213 |
|
| double xb; /* Scanbeam bottom x coordinate */
|
| 214 |
|
| double xt; /* Scanbeam top x coordinate */
|
| 215 |
|
| double dx; /* Change in x for a unit y increase */
|
| 216 |
|
| struct st_shape *prev; /* Previous edge in sorted list */
|
| 217 |
|
| } st_node;
|
| 218 |
|
|
|
| 219 |
|
| typedef struct bbox_shape /* Contour axis-aligned bounding box */
|
| 220 |
|
| {
|
| 221 |
|
| double xmin; /* Minimum x coordinate */
|
| 222 |
|
| double ymin; /* Minimum y coordinate */
|
| 223 |
|
| double xmax; /* Maximum x coordinate */
|
| 224 |
|
| double ymax; /* Maximum y coordinate */
|
| 225 |
|
| } bbox;
|
| 226 |
|
|
|
| 227 |
|
|
|
| 228 |
|
| /*
|
| 229 |
|
| ===========================================================================
|
| 230 |
|
| Global Data
|
| 231 |
|
| ===========================================================================
|
| 232 |
|
| */
|
| 233 |
|
|
|
| 234 |
|
| /* Horizontal edge state transitions within scanbeam boundary */
|
| 235 |
|
| const h_state next_h_state[3][6]=
|
| 236 |
|
| {
|
| 237 |
|
| /* ABOVE BELOW CROSS */
|
| 238 |
|
| /* L R L R L R */
|
| 239 |
|
| /* NH */ {BH, TH, TH, BH, NH, NH},
|
| 240 |
|
| /* BH */ {NH, NH, NH, NH, TH, TH},
|
| 241 |
|
| /* TH */ {NH, NH, NH, NH, BH, BH}
|
| 242 |
|
| };
|
| 243 |
|
|
|
| 244 |
|
|
|
| 245 |
|
| /*
|
| 246 |
|
| ===========================================================================
|
| 247 |
|
| Private Functions
|
| 248 |
|
| ===========================================================================
|
| 249 |
|
| */
|
| 250 |
|
|
|
| 251 |
76 |
| static void reset_it(it_node **it)
|
| 252 |
|
| {
|
| 253 |
|
| it_node *itn;
|
| 254 |
|
|
|
| 255 |
80 |
▶ | while (*it)
|
Branch: 1 branch
| Branch | True | False | Total |
| while (*it)
|
4 |
76 |
80 |
|
| 256 |
|
| {
|
| 257 |
4 |
| itn= (*it)->next;
|
| 258 |
4 |
| FREE(*it);
|
| 259 |
4 |
| *it= itn;
|
| 260 |
|
| }
|
| 261 |
76 |
| }
|
| 262 |
|
|
|
| 263 |
|
|
|
| 264 |
4 |
| static void reset_lmt(lmt_node **lmt)
|
| 265 |
|
| {
|
| 266 |
|
| lmt_node *lmtn;
|
| 267 |
|
|
|
| 268 |
20 |
▶ | while (*lmt)
|
Branch: 1 branch
| Branch | True | False | Total |
| while (*lmt)
|
16 |
4 |
20 |
|
| 269 |
|
| {
|
| 270 |
16 |
| lmtn= (*lmt)->next;
|
| 271 |
16 |
| FREE(*lmt);
|
| 272 |
16 |
| *lmt= lmtn;
|
| 273 |
|
| }
|
| 274 |
4 |
| }
|
| 275 |
|
|
|
| 276 |
|
|
|
| 277 |
40 |
| static void insert_bound(edge_node **b, edge_node *e)
|
| 278 |
|
| {
|
| 279 |
|
| edge_node *existing_bound;
|
| 280 |
|
|
|
| 281 |
40 |
▶ | if (!*b)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!*b)
|
24 |
16 |
40 |
|
| 282 |
|
| {
|
| 283 |
|
| /* Link node e to the tail of the list */
|
| 284 |
24 |
| *b= e;
|
| 285 |
|
| }
|
| 286 |
|
| else
|
| 287 |
|
| {
|
| 288 |
|
| /* Do primary sort on the x field */
|
| 289 |
16 |
▶ | if (e[0].bot.x < (*b)[0].bot.x)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e[0].bot.x < (*b)[0].bot.x)
|
0 |
16 |
16 |
|
| 290 |
|
| {
|
| 291 |
|
| /* Insert a new node mid-list */
|
| 292 |
0 |
| existing_bound= *b;
|
| 293 |
0 |
| *b= e;
|
| 294 |
0 |
| (*b)->next_bound= existing_bound;
|
| 295 |
|
| }
|
| 296 |
|
| else
|
| 297 |
|
| {
|
| 298 |
16 |
▶ | if (e[0].bot.x == (*b)[0].bot.x)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e[0].bot.x == (*b)[0].bot.x)
|
14 |
2 |
16 |
|
| 299 |
|
| {
|
| 300 |
|
| /* Do secondary sort on the dx field */
|
| 301 |
14 |
▶ | if (e[0].dx < (*b)[0].dx)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e[0].dx < (*b)[0].dx)
|
8 |
6 |
14 |
|
| 302 |
|
| {
|
| 303 |
|
| /* Insert a new node mid-list */
|
| 304 |
8 |
| existing_bound= *b;
|
| 305 |
8 |
| *b= e;
|
| 306 |
8 |
| (*b)->next_bound= existing_bound;
|
| 307 |
|
| }
|
| 308 |
|
| else
|
| 309 |
|
| {
|
| 310 |
|
| /* Head further down the list */
|
| 311 |
6 |
| insert_bound(&((*b)->next_bound), e);
|
| 312 |
|
| }
|
| 313 |
|
| }
|
| 314 |
|
| else
|
| 315 |
|
| {
|
| 316 |
|
| /* Head further down the list */
|
| 317 |
2 |
| insert_bound(&((*b)->next_bound), e);
|
| 318 |
|
| }
|
| 319 |
|
| }
|
| 320 |
|
| }
|
| 321 |
40 |
| }
|
| 322 |
|
|
|
| 323 |
|
|
|
| 324 |
72 |
| static edge_node **bound_list(lmt_node **lmt, double y)
|
| 325 |
|
| {
|
| 326 |
|
| lmt_node *existing_node;
|
| 327 |
|
|
|
| 328 |
72 |
▶ | if (!*lmt)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!*lmt)
|
12 |
60 |
72 |
|
| 329 |
|
| {
|
| 330 |
|
| /* Add node onto the tail end of the LMT */
|
| 331 |
12 |
▶ | MALLOC(*lmt, sizeof(lmt_node), "LMT insertion", lmt_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*lmt, sizeof(lmt_node), "LMT insertion", lmt_node);
|
0 |
12 |
12 |
|
| 332 |
12 |
| (*lmt)->y= y;
|
| 333 |
12 |
| (*lmt)->first_bound= NULL;
|
| 334 |
12 |
| (*lmt)->next= NULL;
|
| 335 |
12 |
| return &((*lmt)->first_bound);
|
| 336 |
|
| }
|
| 337 |
|
| else
|
| 338 |
60 |
▶ | if (y < (*lmt)->y)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (y < (*lmt)->y)
|
4 |
56 |
60 |
|
| 339 |
|
| {
|
| 340 |
|
| /* Insert a new LMT node before the current node */
|
| 341 |
4 |
| existing_node= *lmt;
|
| 342 |
4 |
▶ | MALLOC(*lmt, sizeof(lmt_node), "LMT insertion", lmt_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*lmt, sizeof(lmt_node), "LMT insertion", lmt_node);
|
0 |
4 |
4 |
|
| 343 |
4 |
| (*lmt)->y= y;
|
| 344 |
4 |
| (*lmt)->first_bound= NULL;
|
| 345 |
4 |
| (*lmt)->next= existing_node;
|
| 346 |
4 |
| return &((*lmt)->first_bound);
|
| 347 |
|
| }
|
| 348 |
|
| else
|
| 349 |
56 |
▶ | if (y > (*lmt)->y)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (y > (*lmt)->y)
|
40 |
16 |
56 |
|
| 350 |
|
| /* Head further up the LMT */
|
| 351 |
40 |
| return bound_list(&((*lmt)->next), y);
|
| 352 |
|
| else
|
| 353 |
|
| /* Use this existing LMT node */
|
| 354 |
16 |
| return &((*lmt)->first_bound);
|
| 355 |
|
| }
|
| 356 |
|
|
|
| 357 |
|
|
|
| 358 |
472 |
| static void add_to_sbtree(int *entries, sb_tree **sbtree, double y)
|
| 359 |
|
| {
|
| 360 |
472 |
▶ | if (!*sbtree)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!*sbtree)
|
76 |
396 |
472 |
|
| 361 |
|
| {
|
| 362 |
|
| /* Add a new tree node here */
|
| 363 |
76 |
▶ | MALLOC(*sbtree, sizeof(sb_tree), "scanbeam tree insertion", sb_tree);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*sbtree, sizeof(sb_tree), "scanbeam tree insertion", sb_tree);
|
0 |
76 |
76 |
|
| 364 |
76 |
| (*sbtree)->y= y;
|
| 365 |
76 |
| (*sbtree)->less= NULL;
|
| 366 |
76 |
| (*sbtree)->more= NULL;
|
| 367 |
76 |
| (*entries)++;
|
| 368 |
|
| }
|
| 369 |
|
| else
|
| 370 |
|
| {
|
| 371 |
396 |
▶ | if ((*sbtree)->y > y)
|
Branch: 1 branch
| Branch | True | False | Total |
| if ((*sbtree)->y > y)
|
88 |
308 |
396 |
|
| 372 |
|
| {
|
| 373 |
|
| /* Head into the 'less' sub-tree */
|
| 374 |
88 |
| add_to_sbtree(entries, &((*sbtree)->less), y);
|
| 375 |
|
| }
|
| 376 |
|
| else
|
| 377 |
|
| {
|
| 378 |
308 |
▶ | if ((*sbtree)->y < y)
|
Branch: 1 branch
| Branch | True | False | Total |
| if ((*sbtree)->y < y)
|
300 |
8 |
308 |
|
| 379 |
|
| {
|
| 380 |
|
| /* Head into the 'more' sub-tree */
|
| 381 |
300 |
| add_to_sbtree(entries, &((*sbtree)->more), y);
|
| 382 |
|
| }
|
| 383 |
|
| }
|
| 384 |
|
| }
|
| 385 |
472 |
| }
|
| 386 |
|
|
|
| 387 |
|
|
|
| 388 |
76 |
| static void build_sbt(int *entries, double *sbt, sb_tree *sbtree)
|
| 389 |
|
| {
|
| 390 |
76 |
▶ | if (sbtree->less)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (sbtree->less)
|
40 |
36 |
76 |
|
| 391 |
40 |
| build_sbt(entries, sbt, sbtree->less);
|
| 392 |
76 |
| sbt[*entries]= sbtree->y;
|
| 393 |
76 |
| (*entries)++;
|
| 394 |
76 |
▶ | if (sbtree->more)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (sbtree->more)
|
32 |
44 |
76 |
|
| 395 |
32 |
| build_sbt(entries, sbt, sbtree->more);
|
| 396 |
76 |
| }
|
| 397 |
|
|
|
| 398 |
|
|
|
| 399 |
156 |
| static void free_sbtree(sb_tree **sbtree)
|
| 400 |
|
| {
|
| 401 |
156 |
▶ | if (*sbtree)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (*sbtree)
|
76 |
80 |
156 |
|
| 402 |
|
| {
|
| 403 |
76 |
| free_sbtree(&((*sbtree)->less));
|
| 404 |
76 |
| free_sbtree(&((*sbtree)->more));
|
| 405 |
76 |
| FREE(*sbtree);
|
| 406 |
|
| }
|
| 407 |
156 |
| }
|
| 408 |
|
|
|
| 409 |
|
|
|
| 410 |
21 |
| static int count_optimal_vertices(gpc_vertex_list c)
|
| 411 |
|
| {
|
| 412 |
21 |
| int result= 0, i;
|
| 413 |
|
|
|
| 414 |
|
| /* Ignore non-contributing contours */
|
| 415 |
21 |
▶ | if (c.num_vertices > 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (c.num_vertices > 0)
|
16 |
5 |
21 |
|
| 416 |
|
| {
|
| 417 |
100 |
▶ | for (i= 0; i < c.num_vertices; i++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (i= 0; i < c.num_vertices; i++)
|
84 |
16 |
100 |
|
| 418 |
|
| /* Ignore superfluous vertices embedded in horizontal edges */
|
| 419 |
84 |
▶ | if (OPTIMAL(c.vertex, i, c.num_vertices))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (OPTIMAL(c.vertex, i, c.num_vertices))
|
8 |
76 |
84 |
| if (OPTIMAL(c.vertex, i, c.num_vertices))
|
8 |
0 |
8 |
|
| 420 |
84 |
| result++;
|
| 421 |
|
| }
|
| 422 |
21 |
| return result;
|
| 423 |
|
| }
|
| 424 |
|
|
|
| 425 |
|
|
|
| 426 |
8 |
| static edge_node *build_lmt(lmt_node **lmt, sb_tree **sbtree,
|
| 427 |
|
| int *sbt_entries, gpc_polygon *p, int type,
|
| 428 |
|
| gpc_op op)
|
| 429 |
|
| {
|
| 430 |
|
| int c, i, min, max, num_edges, v, num_vertices;
|
| 431 |
8 |
| int total_vertices= 0, e_index=0;
|
| 432 |
|
| edge_node *e, *edge_table;
|
| 433 |
|
|
|
| 434 |
29 |
▶ | for (c= 0; c < p->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < p->num_contours; c++)
|
21 |
8 |
29 |
|
| 435 |
21 |
| total_vertices+= count_optimal_vertices(p->contour[c]);
|
| 436 |
|
|
|
| 437 |
|
| /* Create the entire input polygon edge table in one go */
|
| 438 |
8 |
▶ | MALLOC(edge_table, total_vertices * sizeof(edge_node),
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(edge_table, total_vertices * sizeof(edge_node),
|
8 |
0 |
8 |
| MALLOC(edge_table, total_vertices * sizeof(edge_node),
|
0 |
8 |
8 |
|
| 439 |
|
| "edge table creation", edge_node);
|
| 440 |
|
|
|
| 441 |
29 |
▶ | for (c= 0; c < p->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < p->num_contours; c++)
|
21 |
8 |
29 |
|
| 442 |
|
| {
|
| 443 |
21 |
▶ | if (p->contour[c].num_vertices < 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p->contour[c].num_vertices < 0)
|
4 |
17 |
21 |
|
| 444 |
|
| {
|
| 445 |
|
| /* Ignore the non-contributing contour and repair the vertex count */
|
| 446 |
4 |
| p->contour[c].num_vertices= -p->contour[c].num_vertices;
|
| 447 |
|
| }
|
| 448 |
|
| else
|
| 449 |
|
| {
|
| 450 |
|
| /* Perform contour optimisation */
|
| 451 |
17 |
| num_vertices= 0;
|
| 452 |
101 |
▶ | for (i= 0; i < p->contour[c].num_vertices; i++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (i= 0; i < p->contour[c].num_vertices; i++)
|
84 |
17 |
101 |
|
| 453 |
84 |
▶ | if (OPTIMAL(p->contour[c].vertex, i, p->contour[c].num_vertices))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (OPTIMAL(p->contour[c].vertex, i, p->contour[c].num_vertices))
|
8 |
76 |
84 |
| if (OPTIMAL(p->contour[c].vertex, i, p->contour[c].num_vertices))
|
8 |
0 |
8 |
|
| 454 |
|
| {
|
| 455 |
84 |
| edge_table[num_vertices].vertex.x= p->contour[c].vertex[i].x;
|
| 456 |
84 |
| edge_table[num_vertices].vertex.y= p->contour[c].vertex[i].y;
|
| 457 |
|
|
|
| 458 |
|
| /* Record vertex in the scanbeam table */
|
| 459 |
84 |
| add_to_sbtree(sbt_entries, sbtree,
|
| 460 |
84 |
| edge_table[num_vertices].vertex.y);
|
| 461 |
|
|
|
| 462 |
84 |
| num_vertices++;
|
| 463 |
|
| }
|
| 464 |
|
|
|
| 465 |
|
| /* Do the contour forward pass */
|
| 466 |
101 |
▶ | for (min= 0; min < num_vertices; min++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (min= 0; min < num_vertices; min++)
|
84 |
17 |
101 |
|
| 467 |
|
| {
|
| 468 |
|
| /* If a forward local minimum... */
|
| 469 |
84 |
▶ | if (FWD_MIN(edge_table, min, num_vertices))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (FWD_MIN(edge_table, min, num_vertices))
|
46 |
38 |
84 |
| if (FWD_MIN(edge_table, min, num_vertices))
|
16 |
30 |
46 |
|
| 470 |
|
| {
|
| 471 |
|
| /* Search for the next local maximum... */
|
| 472 |
16 |
| num_edges= 1;
|
| 473 |
16 |
| max= NEXT_INDEX(min, num_vertices);
|
| 474 |
38 |
▶ | while (NOT_FMAX(edge_table, max, num_vertices))
|
Branch: 1 branch
| Branch | True | False | Total |
| while (NOT_FMAX(edge_table, max, num_vertices))
|
22 |
16 |
38 |
|
| 475 |
|
| {
|
| 476 |
22 |
| num_edges++;
|
| 477 |
22 |
| max= NEXT_INDEX(max, num_vertices);
|
| 478 |
|
| }
|
| 479 |
|
|
|
| 480 |
|
| /* Build the next edge list */
|
| 481 |
16 |
| e= &edge_table[e_index];
|
| 482 |
16 |
| e_index+= num_edges;
|
| 483 |
16 |
| v= min;
|
| 484 |
16 |
| e[0].bstate[BELOW]= UNBUNDLED;
|
| 485 |
16 |
| e[0].bundle[BELOW][CLIP]= FALSE;
|
| 486 |
16 |
| e[0].bundle[BELOW][SUBJ]= FALSE;
|
| 487 |
54 |
▶ | for (i= 0; i < num_edges; i++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (i= 0; i < num_edges; i++)
|
38 |
16 |
54 |
|
| 488 |
|
| {
|
| 489 |
38 |
| e[i].xb= edge_table[v].vertex.x;
|
| 490 |
38 |
| e[i].bot.x= edge_table[v].vertex.x;
|
| 491 |
38 |
| e[i].bot.y= edge_table[v].vertex.y;
|
| 492 |
|
|
|
| 493 |
38 |
| v= NEXT_INDEX(v, num_vertices);
|
| 494 |
|
|
|
| 495 |
38 |
| e[i].top.x= edge_table[v].vertex.x;
|
| 496 |
38 |
| e[i].top.y= edge_table[v].vertex.y;
|
| 497 |
38 |
| e[i].dx= (edge_table[v].vertex.x - e[i].bot.x) /
|
| 498 |
38 |
| (e[i].top.y - e[i].bot.y);
|
| 499 |
38 |
| e[i].type= type;
|
| 500 |
38 |
| e[i].outp[ABOVE]= NULL;
|
| 501 |
38 |
| e[i].outp[BELOW]= NULL;
|
| 502 |
38 |
| e[i].next= NULL;
|
| 503 |
38 |
| e[i].prev= NULL;
|
| 504 |
32 |
▶ | e[i].succ= ((num_edges > 1) && (i < (num_edges - 1))) ?
|
Branch: 1 branch
| Branch | True | False | Total |
| e[i].succ= ((num_edges > 1) && (i < (num_edges - 1))) ?
|
22 |
10 |
32 |
|
| 505 |
70 |
▶ | &(e[i + 1]) : NULL;
|
Branch: 1 branch
| Branch | True | False | Total |
| &(e[i + 1]) : NULL;
|
32 |
6 |
38 |
|
| 506 |
38 |
▶ | e[i].pred= ((num_edges > 1) && (i > 0)) ? &(e[i - 1]) : NULL;
|
Branch: 2 branches
| Branch | True | False | Total |
| e[i].pred= ((num_edges > 1) && (i > 0)) ? &(e[i - 1]) : NULL;
|
32 |
6 |
38 |
| e[i].pred= ((num_edges > 1) && (i > 0)) ? &(e[i - 1]) : NULL;
|
22 |
10 |
32 |
|
| 507 |
38 |
| e[i].next_bound= NULL;
|
| 508 |
38 |
| e[i].bside[CLIP]= (op == GPC_DIFF) ? RIGHT : LEFT;
|
| 509 |
38 |
| e[i].bside[SUBJ]= LEFT;
|
| 510 |
|
| }
|
| 511 |
16 |
| insert_bound(bound_list(lmt, edge_table[min].vertex.y), e);
|
| 512 |
|
| }
|
| 513 |
|
| }
|
| 514 |
|
|
|
| 515 |
|
| /* Do the contour reverse pass */
|
| 516 |
101 |
▶ | for (min= 0; min < num_vertices; min++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (min= 0; min < num_vertices; min++)
|
84 |
17 |
101 |
|
| 517 |
|
| {
|
| 518 |
|
| /* If a reverse local minimum... */
|
| 519 |
84 |
▶ | if (REV_MIN(edge_table, min, num_vertices))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (REV_MIN(edge_table, min, num_vertices))
|
38 |
46 |
84 |
| if (REV_MIN(edge_table, min, num_vertices))
|
16 |
22 |
38 |
|
| 520 |
|
| {
|
| 521 |
|
| /* Search for the previous local maximum... */
|
| 522 |
16 |
| num_edges= 1;
|
| 523 |
16 |
| max= PREV_INDEX(min, num_vertices);
|
| 524 |
38 |
▶ | while (NOT_RMAX(edge_table, max, num_vertices))
|
Branch: 1 branch
| Branch | True | False | Total |
| while (NOT_RMAX(edge_table, max, num_vertices))
|
22 |
16 |
38 |
|
| 525 |
|
| {
|
| 526 |
22 |
| num_edges++;
|
| 527 |
22 |
| max= PREV_INDEX(max, num_vertices);
|
| 528 |
|
| }
|
| 529 |
|
|
|
| 530 |
|
| /* Build the previous edge list */
|
| 531 |
16 |
| e= &edge_table[e_index];
|
| 532 |
16 |
| e_index+= num_edges;
|
| 533 |
16 |
| v= min;
|
| 534 |
16 |
| e[0].bstate[BELOW]= UNBUNDLED;
|
| 535 |
16 |
| e[0].bundle[BELOW][CLIP]= FALSE;
|
| 536 |
16 |
| e[0].bundle[BELOW][SUBJ]= FALSE;
|
| 537 |
54 |
▶ | for (i= 0; i < num_edges; i++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (i= 0; i < num_edges; i++)
|
38 |
16 |
54 |
|
| 538 |
|
| {
|
| 539 |
38 |
| e[i].xb= edge_table[v].vertex.x;
|
| 540 |
38 |
| e[i].bot.x= edge_table[v].vertex.x;
|
| 541 |
38 |
| e[i].bot.y= edge_table[v].vertex.y;
|
| 542 |
|
|
|
| 543 |
38 |
| v= PREV_INDEX(v, num_vertices);
|
| 544 |
|
|
|
| 545 |
38 |
| e[i].top.x= edge_table[v].vertex.x;
|
| 546 |
38 |
| e[i].top.y= edge_table[v].vertex.y;
|
| 547 |
38 |
| e[i].dx= (edge_table[v].vertex.x - e[i].bot.x) /
|
| 548 |
38 |
| (e[i].top.y - e[i].bot.y);
|
| 549 |
38 |
| e[i].type= type;
|
| 550 |
38 |
| e[i].outp[ABOVE]= NULL;
|
| 551 |
38 |
| e[i].outp[BELOW]= NULL;
|
| 552 |
38 |
| e[i].next= NULL;
|
| 553 |
38 |
| e[i].prev= NULL;
|
| 554 |
36 |
▶ | e[i].succ= ((num_edges > 1) && (i < (num_edges - 1))) ?
|
Branch: 1 branch
| Branch | True | False | Total |
| e[i].succ= ((num_edges > 1) && (i < (num_edges - 1))) ?
|
22 |
14 |
36 |
|
| 555 |
74 |
▶ | &(e[i + 1]) : NULL;
|
Branch: 1 branch
| Branch | True | False | Total |
| &(e[i + 1]) : NULL;
|
36 |
2 |
38 |
|
| 556 |
38 |
▶ | e[i].pred= ((num_edges > 1) && (i > 0)) ? &(e[i - 1]) : NULL;
|
Branch: 2 branches
| Branch | True | False | Total |
| e[i].pred= ((num_edges > 1) && (i > 0)) ? &(e[i - 1]) : NULL;
|
36 |
2 |
38 |
| e[i].pred= ((num_edges > 1) && (i > 0)) ? &(e[i - 1]) : NULL;
|
22 |
14 |
36 |
|
| 557 |
38 |
| e[i].next_bound= NULL;
|
| 558 |
38 |
| e[i].bside[CLIP]= (op == GPC_DIFF) ? RIGHT : LEFT;
|
| 559 |
38 |
| e[i].bside[SUBJ]= LEFT;
|
| 560 |
|
| }
|
| 561 |
16 |
| insert_bound(bound_list(lmt, edge_table[min].vertex.y), e);
|
| 562 |
|
| }
|
| 563 |
|
| }
|
| 564 |
|
| }
|
| 565 |
|
| }
|
| 566 |
8 |
| return edge_table;
|
| 567 |
|
| }
|
| 568 |
|
|
|
| 569 |
|
|
|
| 570 |
96 |
| static void add_edge_to_aet(edge_node **aet, edge_node *edge, edge_node *prev)
|
| 571 |
|
| {
|
| 572 |
96 |
▶ | if (!*aet)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!*aet)
|
8 |
88 |
96 |
|
| 573 |
|
| {
|
| 574 |
|
| /* Append edge onto the tail end of the AET */
|
| 575 |
8 |
| *aet= edge;
|
| 576 |
8 |
| edge->prev= prev;
|
| 577 |
8 |
| edge->next= NULL;
|
| 578 |
|
| }
|
| 579 |
|
| else
|
| 580 |
|
| {
|
| 581 |
|
| /* Do primary sort on the xb field */
|
| 582 |
88 |
▶ | if (edge->xb < (*aet)->xb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->xb < (*aet)->xb)
|
24 |
64 |
88 |
|
| 583 |
|
| {
|
| 584 |
|
| /* Insert edge here (before the AET edge) */
|
| 585 |
24 |
| edge->prev= prev;
|
| 586 |
24 |
| edge->next= *aet;
|
| 587 |
24 |
| (*aet)->prev= edge;
|
| 588 |
24 |
| *aet= edge;
|
| 589 |
|
| }
|
| 590 |
|
| else
|
| 591 |
|
| {
|
| 592 |
64 |
▶ | if (edge->xb == (*aet)->xb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->xb == (*aet)->xb)
|
14 |
50 |
64 |
|
| 593 |
|
| {
|
| 594 |
|
| /* Do secondary sort on the dx field */
|
| 595 |
14 |
▶ | if (edge->dx < (*aet)->dx)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->dx < (*aet)->dx)
|
0 |
14 |
14 |
|
| 596 |
|
| {
|
| 597 |
|
| /* Insert edge here (before the AET edge) */
|
| 598 |
0 |
| edge->prev= prev;
|
| 599 |
0 |
| edge->next= *aet;
|
| 600 |
0 |
| (*aet)->prev= edge;
|
| 601 |
0 |
| *aet= edge;
|
| 602 |
|
| }
|
| 603 |
|
| else
|
| 604 |
|
| {
|
| 605 |
|
| /* Head further into the AET */
|
| 606 |
14 |
| add_edge_to_aet(&((*aet)->next), edge, *aet);
|
| 607 |
|
| }
|
| 608 |
|
| }
|
| 609 |
|
| else
|
| 610 |
|
| {
|
| 611 |
|
| /* Head further into the AET */
|
| 612 |
50 |
| add_edge_to_aet(&((*aet)->next), edge, *aet);
|
| 613 |
|
| }
|
| 614 |
|
| }
|
| 615 |
|
| }
|
| 616 |
96 |
| }
|
| 617 |
|
|
|
| 618 |
|
|
|
| 619 |
4 |
| static void add_intersection(it_node **it, edge_node *edge0, edge_node *edge1,
|
| 620 |
|
| double x, double y)
|
| 621 |
|
| {
|
| 622 |
|
| it_node *existing_node;
|
| 623 |
|
|
|
| 624 |
4 |
▶ | if (!*it)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!*it)
|
4 |
0 |
4 |
|
| 625 |
|
| {
|
| 626 |
|
| /* Append a new node to the tail of the list */
|
| 627 |
4 |
▶ | MALLOC(*it, sizeof(it_node), "IT insertion", it_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*it, sizeof(it_node), "IT insertion", it_node);
|
0 |
4 |
4 |
|
| 628 |
4 |
| (*it)->ie[0]= edge0;
|
| 629 |
4 |
| (*it)->ie[1]= edge1;
|
| 630 |
4 |
| (*it)->point.x= x;
|
| 631 |
4 |
| (*it)->point.y= y;
|
| 632 |
4 |
| (*it)->next= NULL;
|
| 633 |
|
| }
|
| 634 |
|
| else
|
| 635 |
|
| {
|
| 636 |
0 |
▶ | if ((*it)->point.y > y)
|
Branch: 1 branch
| Branch | True | False | Total |
| if ((*it)->point.y > y)
|
0 |
0 |
0 |
|
| 637 |
|
| {
|
| 638 |
|
| /* Insert a new node mid-list */
|
| 639 |
0 |
| existing_node= *it;
|
| 640 |
0 |
▶ | MALLOC(*it, sizeof(it_node), "IT insertion", it_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*it, sizeof(it_node), "IT insertion", it_node);
|
0 |
0 |
0 |
|
| 641 |
0 |
| (*it)->ie[0]= edge0;
|
| 642 |
0 |
| (*it)->ie[1]= edge1;
|
| 643 |
0 |
| (*it)->point.x= x;
|
| 644 |
0 |
| (*it)->point.y= y;
|
| 645 |
0 |
| (*it)->next= existing_node;
|
| 646 |
|
| }
|
| 647 |
|
| else
|
| 648 |
|
| /* Head further down the list */
|
| 649 |
0 |
| add_intersection(&((*it)->next), edge0, edge1, x, y);
|
| 650 |
|
| }
|
| 651 |
4 |
| }
|
| 652 |
|
|
|
| 653 |
|
|
|
| 654 |
272 |
| static void add_st_edge(st_node **st, it_node **it, edge_node *edge,
|
| 655 |
|
| double dy)
|
| 656 |
|
| {
|
| 657 |
|
| st_node *existing_node;
|
| 658 |
|
| double den, r, x, y;
|
| 659 |
|
|
|
| 660 |
272 |
▶ | if (!*st)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!*st)
|
72 |
200 |
272 |
|
| 661 |
|
| {
|
| 662 |
|
| /* Append edge onto the tail end of the ST */
|
| 663 |
72 |
▶ | MALLOC(*st, sizeof(st_node), "ST insertion", st_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*st, sizeof(st_node), "ST insertion", st_node);
|
0 |
72 |
72 |
|
| 664 |
72 |
| (*st)->edge= edge;
|
| 665 |
72 |
| (*st)->xb= edge->xb;
|
| 666 |
72 |
| (*st)->xt= edge->xt;
|
| 667 |
72 |
| (*st)->dx= edge->dx;
|
| 668 |
72 |
| (*st)->prev= NULL;
|
| 669 |
|
| }
|
| 670 |
|
| else
|
| 671 |
|
| {
|
| 672 |
200 |
| den= ((*st)->xt - (*st)->xb) - (edge->xt - edge->xb);
|
| 673 |
|
|
|
| 674 |
|
| /* If new edge and ST edge don't cross */
|
| 675 |
200 |
▶ | if ((edge->xt >= (*st)->xt) || (edge->dx == (*st)->dx) ||
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((edge->xt >= (*st)->xt) || (edge->dx == (*st)->dx) ||
|
4 |
196 |
200 |
| if ((edge->xt >= (*st)->xt) || (edge->dx == (*st)->dx) ||
|
4 |
0 |
4 |
|
| 676 |
4 |
▶ | (fabs(den) <= DBL_EPSILON))
|
Branch: 1 branch
| Branch | True | False | Total |
| (fabs(den) <= DBL_EPSILON))
|
0 |
4 |
4 |
|
| 677 |
|
| {
|
| 678 |
|
| /* No intersection - insert edge here (before the ST edge) */
|
| 679 |
196 |
| existing_node= *st;
|
| 680 |
196 |
▶ | MALLOC(*st, sizeof(st_node), "ST insertion", st_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*st, sizeof(st_node), "ST insertion", st_node);
|
0 |
196 |
196 |
|
| 681 |
196 |
| (*st)->edge= edge;
|
| 682 |
196 |
| (*st)->xb= edge->xb;
|
| 683 |
196 |
| (*st)->xt= edge->xt;
|
| 684 |
196 |
| (*st)->dx= edge->dx;
|
| 685 |
196 |
| (*st)->prev= existing_node;
|
| 686 |
|
| }
|
| 687 |
|
| else
|
| 688 |
|
| {
|
| 689 |
|
| /* Compute intersection between new edge and ST edge */
|
| 690 |
4 |
| r= (edge->xb - (*st)->xb) / den;
|
| 691 |
4 |
| x= (*st)->xb + r * ((*st)->xt - (*st)->xb);
|
| 692 |
4 |
| y= r * dy;
|
| 693 |
|
|
|
| 694 |
|
| /* Insert the edge pointers and the intersection point in the IT */
|
| 695 |
4 |
| add_intersection(it, (*st)->edge, edge, x, y);
|
| 696 |
|
|
|
| 697 |
|
| /* Head further into the ST */
|
| 698 |
4 |
| add_st_edge(&((*st)->prev), it, edge, dy);
|
| 699 |
|
| }
|
| 700 |
|
| }
|
| 701 |
272 |
| }
|
| 702 |
|
|
|
| 703 |
|
|
|
| 704 |
72 |
| static void build_intersection_table(it_node **it, edge_node *aet, double dy)
|
| 705 |
|
| {
|
| 706 |
|
| st_node *st, *stp;
|
| 707 |
|
| edge_node *edge;
|
| 708 |
|
|
|
| 709 |
|
| /* Build intersection table for the current scanbeam */
|
| 710 |
72 |
| reset_it(it);
|
| 711 |
72 |
| st= NULL;
|
| 712 |
|
|
|
| 713 |
|
| /* Process each AET edge */
|
| 714 |
340 |
▶ | for (edge= aet; edge; edge= edge->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= aet; edge; edge= edge->next)
|
268 |
72 |
340 |
|
| 715 |
|
| {
|
| 716 |
268 |
▶ | if ((edge->bstate[ABOVE] == BUNDLE_HEAD) ||
|
Branch: 1 branch
| Branch | True | False | Total |
| if ((edge->bstate[ABOVE] == BUNDLE_HEAD) ||
|
268 |
0 |
268 |
|
| 717 |
268 |
▶ | edge->bundle[ABOVE][CLIP] || edge->bundle[ABOVE][SUBJ])
|
Branch: 2 branches
| Branch | True | False | Total |
| edge->bundle[ABOVE][CLIP] || edge->bundle[ABOVE][SUBJ])
|
244 |
24 |
268 |
| edge->bundle[ABOVE][CLIP] || edge->bundle[ABOVE][SUBJ])
|
244 |
0 |
244 |
|
| 718 |
268 |
| add_st_edge(&st, it, edge, dy);
|
| 719 |
|
| }
|
| 720 |
|
|
|
| 721 |
|
| /* Free the sorted edge table */
|
| 722 |
340 |
▶ | while (st)
|
Branch: 1 branch
| Branch | True | False | Total |
| while (st)
|
268 |
72 |
340 |
|
| 723 |
|
| {
|
| 724 |
268 |
| stp= st->prev;
|
| 725 |
268 |
| FREE(st);
|
| 726 |
268 |
| st= stp;
|
| 727 |
|
| }
|
| 728 |
72 |
| }
|
| 729 |
|
|
|
| 730 |
4 |
| static int count_contours(polygon_node *polygon)
|
| 731 |
|
| {
|
| 732 |
|
| int nc, nv;
|
| 733 |
|
| vertex_node *v, *nextv;
|
| 734 |
|
|
|
| 735 |
16 |
▶ | for (nc= 0; polygon; polygon= polygon->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (nc= 0; polygon; polygon= polygon->next)
|
12 |
4 |
16 |
|
| 736 |
12 |
▶ | if (polygon->active)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (polygon->active)
|
10 |
2 |
12 |
|
| 737 |
|
| {
|
| 738 |
|
| /* Count the vertices in the current contour */
|
| 739 |
10 |
| nv= 0;
|
| 740 |
68 |
▶ | for (v= polygon->proxy->v[LEFT]; v; v= v->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (v= polygon->proxy->v[LEFT]; v; v= v->next)
|
58 |
10 |
68 |
|
| 741 |
58 |
| nv++;
|
| 742 |
|
|
|
| 743 |
|
| /* Record valid vertex counts in the active field */
|
| 744 |
10 |
▶ | if (nv > 2)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (nv > 2)
|
10 |
0 |
10 |
|
| 745 |
|
| {
|
| 746 |
10 |
| polygon->active= nv;
|
| 747 |
10 |
| nc++;
|
| 748 |
|
| }
|
| 749 |
|
| else
|
| 750 |
|
| {
|
| 751 |
|
| /* Invalid contour: just free the heap */
|
| 752 |
0 |
▶ | for (v= polygon->proxy->v[LEFT]; v; v= nextv)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (v= polygon->proxy->v[LEFT]; v; v= nextv)
|
0 |
0 |
0 |
|
| 753 |
|
| {
|
| 754 |
0 |
| nextv= v->next;
|
| 755 |
0 |
| FREE(v);
|
| 756 |
|
| }
|
| 757 |
0 |
| polygon->active= 0;
|
| 758 |
|
| }
|
| 759 |
|
| }
|
| 760 |
4 |
| return nc;
|
| 761 |
|
| }
|
| 762 |
|
|
|
| 763 |
|
|
|
| 764 |
25 |
| static void add_left(polygon_node *p, double x, double y)
|
| 765 |
|
| {
|
| 766 |
|
| vertex_node *nv;
|
| 767 |
|
|
|
| 768 |
|
| /* Create a new vertex node and set its fields */
|
| 769 |
25 |
▶ | MALLOC(nv, sizeof(vertex_node), "vertex node creation", vertex_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(nv, sizeof(vertex_node), "vertex node creation", vertex_node);
|
0 |
25 |
25 |
|
| 770 |
25 |
| nv->x= x;
|
| 771 |
25 |
| nv->y= y;
|
| 772 |
|
|
|
| 773 |
|
| /* Add vertex nv to the left end of the polygon's vertex list */
|
| 774 |
25 |
| nv->next= p->proxy->v[LEFT];
|
| 775 |
|
|
|
| 776 |
|
| /* Update proxy->[LEFT] to point to nv */
|
| 777 |
25 |
| p->proxy->v[LEFT]= nv;
|
| 778 |
25 |
| }
|
| 779 |
|
|
|
| 780 |
|
|
|
| 781 |
7 |
| static void merge_left(polygon_node *p, polygon_node *q, polygon_node *list)
|
| 782 |
|
| {
|
| 783 |
|
| polygon_node *target;
|
| 784 |
|
|
|
| 785 |
|
| /* Label contour as a hole */
|
| 786 |
7 |
| q->proxy->hole= TRUE;
|
| 787 |
|
|
|
| 788 |
7 |
▶ | if (p->proxy != q->proxy)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p->proxy != q->proxy)
|
1 |
6 |
7 |
|
| 789 |
|
| {
|
| 790 |
|
| /* Assign p's vertex list to the left end of q's list */
|
| 791 |
1 |
| p->proxy->v[RIGHT]->next= q->proxy->v[LEFT];
|
| 792 |
1 |
| q->proxy->v[LEFT]= p->proxy->v[LEFT];
|
| 793 |
|
|
|
| 794 |
|
| /* Redirect any p->proxy references to q->proxy */
|
| 795 |
|
|
|
| 796 |
7 |
▶ | for (target= p->proxy; list; list= list->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (target= p->proxy; list; list= list->next)
|
6 |
1 |
7 |
|
| 797 |
|
| {
|
| 798 |
6 |
▶ | if (list->proxy == target)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (list->proxy == target)
|
1 |
5 |
6 |
|
| 799 |
|
| {
|
| 800 |
1 |
| list->active= FALSE;
|
| 801 |
1 |
| list->proxy= q->proxy;
|
| 802 |
|
| }
|
| 803 |
|
| }
|
| 804 |
|
| }
|
| 805 |
7 |
| }
|
| 806 |
|
|
|
| 807 |
|
|
|
| 808 |
21 |
| static void add_right(polygon_node *p, double x, double y)
|
| 809 |
|
| {
|
| 810 |
|
| vertex_node *nv;
|
| 811 |
|
|
|
| 812 |
|
| /* Create a new vertex node and set its fields */
|
| 813 |
21 |
▶ | MALLOC(nv, sizeof(vertex_node), "vertex node creation", vertex_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(nv, sizeof(vertex_node), "vertex node creation", vertex_node);
|
0 |
21 |
21 |
|
| 814 |
21 |
| nv->x= x;
|
| 815 |
21 |
| nv->y= y;
|
| 816 |
21 |
| nv->next= NULL;
|
| 817 |
|
|
|
| 818 |
|
| /* Add vertex nv to the right end of the polygon's vertex list */
|
| 819 |
21 |
| p->proxy->v[RIGHT]->next= nv;
|
| 820 |
|
|
|
| 821 |
|
| /* Update proxy->v[RIGHT] to point to nv */
|
| 822 |
21 |
| p->proxy->v[RIGHT]= nv;
|
| 823 |
21 |
| }
|
| 824 |
|
|
|
| 825 |
|
|
|
| 826 |
5 |
| static void merge_right(polygon_node *p, polygon_node *q, polygon_node *list)
|
| 827 |
|
| {
|
| 828 |
|
| polygon_node *target;
|
| 829 |
|
|
|
| 830 |
|
| /* Label contour as external */
|
| 831 |
5 |
| q->proxy->hole= FALSE;
|
| 832 |
|
|
|
| 833 |
5 |
▶ | if (p->proxy != q->proxy)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p->proxy != q->proxy)
|
1 |
4 |
5 |
|
| 834 |
|
| {
|
| 835 |
|
| /* Assign p's vertex list to the right end of q's list */
|
| 836 |
1 |
| q->proxy->v[RIGHT]->next= p->proxy->v[LEFT];
|
| 837 |
1 |
| q->proxy->v[RIGHT]= p->proxy->v[RIGHT];
|
| 838 |
|
|
|
| 839 |
|
| /* Redirect any p->proxy references to q->proxy */
|
| 840 |
6 |
▶ | for (target= p->proxy; list; list= list->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (target= p->proxy; list; list= list->next)
|
5 |
1 |
6 |
|
| 841 |
|
| {
|
| 842 |
5 |
▶ | if (list->proxy == target)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (list->proxy == target)
|
1 |
4 |
5 |
|
| 843 |
|
| {
|
| 844 |
1 |
| list->active= FALSE;
|
| 845 |
1 |
| list->proxy= q->proxy;
|
| 846 |
|
| }
|
| 847 |
|
| }
|
| 848 |
|
| }
|
| 849 |
5 |
| }
|
| 850 |
|
|
|
| 851 |
|
|
|
| 852 |
12 |
| static void add_local_min(polygon_node **p, edge_node *edge,
|
| 853 |
|
| double x, double y)
|
| 854 |
|
| {
|
| 855 |
|
| polygon_node *existing_min;
|
| 856 |
|
| vertex_node *nv;
|
| 857 |
|
|
|
| 858 |
12 |
| existing_min= *p;
|
| 859 |
|
|
|
| 860 |
12 |
▶ | MALLOC(*p, sizeof(polygon_node), "polygon node creation", polygon_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*p, sizeof(polygon_node), "polygon node creation", polygon_node);
|
0 |
12 |
12 |
|
| 861 |
|
|
|
| 862 |
|
| /* Create a new vertex node and set its fields */
|
| 863 |
12 |
▶ | MALLOC(nv, sizeof(vertex_node), "vertex node creation", vertex_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(nv, sizeof(vertex_node), "vertex node creation", vertex_node);
|
0 |
12 |
12 |
|
| 864 |
12 |
| nv->x= x;
|
| 865 |
12 |
| nv->y= y;
|
| 866 |
12 |
| nv->next= NULL;
|
| 867 |
|
|
|
| 868 |
|
| /* Initialise proxy to point to p itself */
|
| 869 |
12 |
| (*p)->proxy= (*p);
|
| 870 |
12 |
| (*p)->active= TRUE;
|
| 871 |
12 |
| (*p)->next= existing_min;
|
| 872 |
|
|
|
| 873 |
|
| /* Make v[LEFT] and v[RIGHT] point to new vertex nv */
|
| 874 |
12 |
| (*p)->v[LEFT]= nv;
|
| 875 |
12 |
| (*p)->v[RIGHT]= nv;
|
| 876 |
|
|
|
| 877 |
|
| /* Assign polygon p to the edge */
|
| 878 |
12 |
| edge->outp[ABOVE]= *p;
|
| 879 |
12 |
| }
|
| 880 |
|
|
|
| 881 |
|
|
|
| 882 |
0 |
| static int count_tristrips(polygon_node *tn)
|
| 883 |
|
| {
|
| 884 |
|
| int total;
|
| 885 |
|
|
|
| 886 |
0 |
▶ | for (total= 0; tn; tn= tn->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (total= 0; tn; tn= tn->next)
|
0 |
0 |
0 |
|
| 887 |
0 |
▶ | if (tn->active > 2)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tn->active > 2)
|
0 |
0 |
0 |
|
| 888 |
0 |
| total++;
|
| 889 |
0 |
| return total;
|
| 890 |
|
| }
|
| 891 |
|
|
|
| 892 |
|
|
|
| 893 |
0 |
| static void add_vertex(vertex_node **t, double x, double y)
|
| 894 |
|
| {
|
| 895 |
0 |
▶ | if (!(*t))
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!(*t))
|
0 |
0 |
0 |
|
| 896 |
|
| {
|
| 897 |
0 |
▶ | MALLOC(*t, sizeof(vertex_node), "tristrip vertex creation", vertex_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*t, sizeof(vertex_node), "tristrip vertex creation", vertex_node);
|
0 |
0 |
0 |
|
| 898 |
0 |
| (*t)->x= x;
|
| 899 |
0 |
| (*t)->y= y;
|
| 900 |
0 |
| (*t)->next= NULL;
|
| 901 |
|
| }
|
| 902 |
|
| else
|
| 903 |
|
| /* Head further down the list */
|
| 904 |
0 |
| add_vertex(&((*t)->next), x, y);
|
| 905 |
0 |
| }
|
| 906 |
|
|
|
| 907 |
|
|
|
| 908 |
0 |
| static void new_tristrip(polygon_node **tn, edge_node *edge,
|
| 909 |
|
| double x, double y)
|
| 910 |
|
| {
|
| 911 |
0 |
▶ | if (!(*tn))
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!(*tn))
|
0 |
0 |
0 |
|
| 912 |
|
| {
|
| 913 |
0 |
▶ | MALLOC(*tn, sizeof(polygon_node), "tristrip node creation", polygon_node);
|
Branch: 1 branch
| Branch | True | False | Total |
| MALLOC(*tn, sizeof(polygon_node), "tristrip node creation", polygon_node);
|
0 |
0 |
0 |
|
| 914 |
0 |
| (*tn)->next= NULL;
|
| 915 |
0 |
| (*tn)->v[LEFT]= NULL;
|
| 916 |
0 |
| (*tn)->v[RIGHT]= NULL;
|
| 917 |
0 |
| (*tn)->active= 1;
|
| 918 |
0 |
| add_vertex(&((*tn)->v[LEFT]), x, y);
|
| 919 |
0 |
| edge->outp[ABOVE]= *tn;
|
| 920 |
|
| }
|
| 921 |
|
| else
|
| 922 |
|
| /* Head further down the list */
|
| 923 |
0 |
| new_tristrip(&((*tn)->next), edge, x, y);
|
| 924 |
0 |
| }
|
| 925 |
|
|
|
| 926 |
|
|
|
| 927 |
6 |
| static bbox *create_contour_bboxes(gpc_polygon *p)
|
| 928 |
|
| {
|
| 929 |
|
| bbox *box;
|
| 930 |
|
| int c, v;
|
| 931 |
|
|
|
| 932 |
6 |
▶ | MALLOC(box, p->num_contours * sizeof(bbox), "Bounding box creation", bbox);
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(box, p->num_contours * sizeof(bbox), "Bounding box creation", bbox);
|
6 |
0 |
6 |
| MALLOC(box, p->num_contours * sizeof(bbox), "Bounding box creation", bbox);
|
0 |
6 |
6 |
|
| 933 |
|
|
|
| 934 |
|
| /* Construct contour bounding boxes */
|
| 935 |
22 |
▶ | for (c= 0; c < p->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < p->num_contours; c++)
|
16 |
6 |
22 |
|
| 936 |
|
| {
|
| 937 |
|
| /* Initialise bounding box extent */
|
| 938 |
16 |
| box[c].xmin= DBL_MAX;
|
| 939 |
16 |
| box[c].ymin= DBL_MAX;
|
| 940 |
16 |
| box[c].xmax= -DBL_MAX;
|
| 941 |
16 |
| box[c].ymax= -DBL_MAX;
|
| 942 |
|
|
|
| 943 |
91 |
▶ | for (v= 0; v < p->contour[c].num_vertices; v++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (v= 0; v < p->contour[c].num_vertices; v++)
|
75 |
16 |
91 |
|
| 944 |
|
| {
|
| 945 |
|
| /* Adjust bounding box */
|
| 946 |
75 |
▶ | if (p->contour[c].vertex[v].x < box[c].xmin)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p->contour[c].vertex[v].x < box[c].xmin)
|
30 |
45 |
75 |
|
| 947 |
30 |
| box[c].xmin= p->contour[c].vertex[v].x;
|
| 948 |
75 |
▶ | if (p->contour[c].vertex[v].y < box[c].ymin)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p->contour[c].vertex[v].y < box[c].ymin)
|
36 |
39 |
75 |
|
| 949 |
36 |
| box[c].ymin= p->contour[c].vertex[v].y;
|
| 950 |
75 |
▶ | if (p->contour[c].vertex[v].x > box[c].xmax)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p->contour[c].vertex[v].x > box[c].xmax)
|
33 |
42 |
75 |
|
| 951 |
33 |
| box[c].xmax= p->contour[c].vertex[v].x;
|
| 952 |
75 |
▶ | if (p->contour[c].vertex[v].y > box[c].ymax)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p->contour[c].vertex[v].y > box[c].ymax)
|
33 |
42 |
75 |
|
| 953 |
33 |
| box[c].ymax= p->contour[c].vertex[v].y;
|
| 954 |
|
| }
|
| 955 |
|
| }
|
| 956 |
6 |
| return box;
|
| 957 |
|
| }
|
| 958 |
|
|
|
| 959 |
|
|
|
| 960 |
3 |
| static void minimax_test(gpc_polygon *subj, gpc_polygon *clip, gpc_op op)
|
| 961 |
|
| {
|
| 962 |
|
| bbox *s_bbox, *c_bbox;
|
| 963 |
|
| int s, c, *o_table, overlap;
|
| 964 |
|
|
|
| 965 |
3 |
| s_bbox= create_contour_bboxes(subj);
|
| 966 |
3 |
| c_bbox= create_contour_bboxes(clip);
|
| 967 |
|
|
|
| 968 |
3 |
▶ | MALLOC(o_table, subj->num_contours * clip->num_contours * sizeof(int),
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(o_table, subj->num_contours * clip->num_contours * sizeof(int),
|
3 |
0 |
3 |
| MALLOC(o_table, subj->num_contours * clip->num_contours * sizeof(int),
|
0 |
3 |
3 |
|
| 969 |
|
| "overlap table creation", int);
|
| 970 |
|
|
|
| 971 |
|
| /* Check all subject contour bounding boxes against clip boxes */
|
| 972 |
15 |
▶ | for (s= 0; s < subj->num_contours; s++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (s= 0; s < subj->num_contours; s++)
|
12 |
3 |
15 |
|
| 973 |
28 |
▶ | for (c= 0; c < clip->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < clip->num_contours; c++)
|
16 |
12 |
28 |
|
| 974 |
16 |
| o_table[c * subj->num_contours + s]=
|
| 975 |
25 |
| (!((s_bbox[s].xmax < c_bbox[c].xmin) ||
|
| 976 |
25 |
▶ | (s_bbox[s].xmin > c_bbox[c].xmax))) &&
|
Branch: 2 branches
| Branch | True | False | Total |
| (s_bbox[s].xmin > c_bbox[c].xmax))) &&
|
9 |
7 |
16 |
| (s_bbox[s].xmin > c_bbox[c].xmax))) &&
|
9 |
0 |
9 |
|
| 977 |
9 |
▶ | (!((s_bbox[s].ymax < c_bbox[c].ymin) ||
|
Branch: 1 branch
| Branch | True | False | Total |
| (!((s_bbox[s].ymax < c_bbox[c].ymin) ||
|
6 |
3 |
9 |
|
| 978 |
6 |
▶ | (s_bbox[s].ymin > c_bbox[c].ymax)));
|
Branch: 1 branch
| Branch | True | False | Total |
| (s_bbox[s].ymin > c_bbox[c].ymax)));
|
6 |
0 |
6 |
|
| 979 |
|
|
|
| 980 |
|
| /* For each clip contour, search for any subject contour overlaps */
|
| 981 |
7 |
▶ | for (c= 0; c < clip->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < clip->num_contours; c++)
|
4 |
3 |
7 |
|
| 982 |
|
| {
|
| 983 |
4 |
| overlap= 0;
|
| 984 |
11 |
▶ | for (s= 0; (!overlap) && (s < subj->num_contours); s++)
|
Branch: 2 branches
| Branch | True | False | Total |
| for (s= 0; (!overlap) && (s < subj->num_contours); s++)
|
8 |
3 |
11 |
| for (s= 0; (!overlap) && (s < subj->num_contours); s++)
|
7 |
1 |
8 |
|
| 985 |
7 |
| overlap= o_table[c * subj->num_contours + s];
|
| 986 |
|
|
|
| 987 |
4 |
▶ | if (!overlap)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!overlap)
|
1 |
3 |
4 |
|
| 988 |
|
| /* Flag non contributing status by negating vertex count */
|
| 989 |
1 |
| clip->contour[c].num_vertices = -clip->contour[c].num_vertices;
|
| 990 |
|
| }
|
| 991 |
|
|
|
| 992 |
3 |
▶ | if (op == GPC_INT)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (op == GPC_INT)
|
2 |
1 |
3 |
|
| 993 |
|
| {
|
| 994 |
|
| /* For each subject contour, search for any clip contour overlaps */
|
| 995 |
10 |
▶ | for (s= 0; s < subj->num_contours; s++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (s= 0; s < subj->num_contours; s++)
|
8 |
2 |
10 |
|
| 996 |
|
| {
|
| 997 |
8 |
| overlap= 0;
|
| 998 |
18 |
▶ | for (c= 0; (!overlap) && (c < clip->num_contours); c++)
|
Branch: 2 branches
| Branch | True | False | Total |
| for (c= 0; (!overlap) && (c < clip->num_contours); c++)
|
14 |
4 |
18 |
| for (c= 0; (!overlap) && (c < clip->num_contours); c++)
|
10 |
4 |
14 |
|
| 999 |
10 |
| overlap= o_table[c * subj->num_contours + s];
|
| 1000 |
|
|
|
| 1001 |
8 |
▶ | if (!overlap)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!overlap)
|
4 |
4 |
8 |
|
| 1002 |
|
| /* Flag non contributing status by negating vertex count */
|
| 1003 |
4 |
| subj->contour[s].num_vertices = -subj->contour[s].num_vertices;
|
| 1004 |
|
| }
|
| 1005 |
|
| }
|
| 1006 |
|
|
|
| 1007 |
3 |
| FREE(s_bbox);
|
| 1008 |
3 |
| FREE(c_bbox);
|
| 1009 |
3 |
| FREE(o_table);
|
| 1010 |
3 |
| }
|
| 1011 |
|
|
|
| 1012 |
|
|
|
| 1013 |
|
| /*
|
| 1014 |
|
| ===========================================================================
|
| 1015 |
|
| Public Functions
|
| 1016 |
|
| ===========================================================================
|
| 1017 |
|
| */
|
| 1018 |
|
|
|
| 1019 |
0 |
| void gpc_free_polygon(gpc_polygon *p)
|
| 1020 |
|
| {
|
| 1021 |
|
| int c;
|
| 1022 |
|
|
|
| 1023 |
0 |
▶ | for (c= 0; c < p->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < p->num_contours; c++)
|
0 |
0 |
0 |
|
| 1024 |
0 |
| FREE(p->contour[c].vertex);
|
| 1025 |
0 |
| FREE(p->hole);
|
| 1026 |
0 |
| FREE(p->contour);
|
| 1027 |
0 |
| p->num_contours= 0;
|
| 1028 |
0 |
| }
|
| 1029 |
|
|
|
| 1030 |
|
|
|
| 1031 |
6 |
| void gpc_read_polygon(FILE *fp, int read_hole_flags, gpc_polygon *p)
|
| 1032 |
|
| {
|
| 1033 |
|
| int c, v;
|
| 1034 |
|
|
|
| 1035 |
6 |
| fscanf(fp, "%d", &(p->num_contours));
|
| 1036 |
6 |
▶ | MALLOC(p->hole, p->num_contours * sizeof(int),
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(p->hole, p->num_contours * sizeof(int),
|
6 |
0 |
6 |
| MALLOC(p->hole, p->num_contours * sizeof(int),
|
0 |
6 |
6 |
|
| 1037 |
|
| "hole flag array creation", int);
|
| 1038 |
6 |
▶ | MALLOC(p->contour, p->num_contours
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(p->contour, p->num_contours
|
6 |
0 |
6 |
| MALLOC(p->contour, p->num_contours
|
0 |
6 |
6 |
|
| 1039 |
|
| * sizeof(gpc_vertex_list), "contour creation", gpc_vertex_list);
|
| 1040 |
21 |
▶ | for (c= 0; c < p->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < p->num_contours; c++)
|
15 |
6 |
21 |
|
| 1041 |
|
| {
|
| 1042 |
15 |
| fscanf(fp, "%d", &(p->contour[c].num_vertices));
|
| 1043 |
|
|
|
| 1044 |
15 |
▶ | if (read_hole_flags)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (read_hole_flags)
|
15 |
0 |
15 |
|
| 1045 |
15 |
| fscanf(fp, "%d", &(p->hole[c]));
|
| 1046 |
|
| else
|
| 1047 |
0 |
| p->hole[c]= FALSE; /* Assume all contours to be external */
|
| 1048 |
|
|
|
| 1049 |
15 |
▶ | MALLOC(p->contour[c].vertex, p->contour[c].num_vertices
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(p->contour[c].vertex, p->contour[c].num_vertices
|
15 |
0 |
15 |
| MALLOC(p->contour[c].vertex, p->contour[c].num_vertices
|
0 |
15 |
15 |
|
| 1050 |
|
| * sizeof(gpc_vertex), "vertex creation", gpc_vertex);
|
| 1051 |
90 |
▶ | for (v= 0; v < p->contour[c].num_vertices; v++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (v= 0; v < p->contour[c].num_vertices; v++)
|
75 |
15 |
90 |
|
| 1052 |
75 |
| fscanf(fp, "%lf %lf", &(p->contour[c].vertex[v].x),
|
| 1053 |
75 |
| &(p->contour[c].vertex[v].y));
|
| 1054 |
|
| }
|
| 1055 |
6 |
| }
|
| 1056 |
|
|
|
| 1057 |
|
|
|
| 1058 |
0 |
| void gpc_write_polygon(FILE *fp, int write_hole_flags, gpc_polygon *p)
|
| 1059 |
|
| {
|
| 1060 |
|
| int c, v;
|
| 1061 |
|
|
|
| 1062 |
0 |
| fprintf(fp, "%d\n", p->num_contours);
|
| 1063 |
0 |
▶ | for (c= 0; c < p->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < p->num_contours; c++)
|
0 |
0 |
0 |
|
| 1064 |
|
| {
|
| 1065 |
0 |
| fprintf(fp, "%d\n", p->contour[c].num_vertices);
|
| 1066 |
|
|
|
| 1067 |
0 |
▶ | if (write_hole_flags)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (write_hole_flags)
|
0 |
0 |
0 |
|
| 1068 |
0 |
| fprintf(fp, "%d\n", p->hole[c]);
|
| 1069 |
|
|
|
| 1070 |
0 |
▶ | for (v= 0; v < p->contour[c].num_vertices; v++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (v= 0; v < p->contour[c].num_vertices; v++)
|
0 |
0 |
0 |
|
| 1071 |
0 |
| fprintf(fp, "% .*lf % .*lf\n",
|
| 1072 |
0 |
| DBL_DIG, p->contour[c].vertex[v].x,
|
| 1073 |
0 |
| DBL_DIG, p->contour[c].vertex[v].y);
|
| 1074 |
|
| }
|
| 1075 |
0 |
| }
|
| 1076 |
|
|
|
| 1077 |
|
|
|
| 1078 |
4 |
| void gpc_add_contour(gpc_polygon *p, gpc_vertex_list *new_contour, int hole)
|
| 1079 |
|
| {
|
| 1080 |
|
| int *extended_hole, c, v;
|
| 1081 |
|
| gpc_vertex_list *extended_contour;
|
| 1082 |
|
| /* Create an extended hole array */
|
| 1083 |
4 |
▶ | MALLOC(extended_hole, (p->num_contours + 1)
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(extended_hole, (p->num_contours + 1)
|
4 |
0 |
4 |
| MALLOC(extended_hole, (p->num_contours + 1)
|
0 |
4 |
4 |
|
| 1084 |
|
| * sizeof(int), "contour hole addition", int);
|
| 1085 |
|
|
|
| 1086 |
|
| /* Create an extended contour array */
|
| 1087 |
4 |
▶ | MALLOC(extended_contour, (p->num_contours + 1)
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(extended_contour, (p->num_contours + 1)
|
4 |
0 |
4 |
| MALLOC(extended_contour, (p->num_contours + 1)
|
0 |
4 |
4 |
|
| 1088 |
|
| * sizeof(gpc_vertex_list), "contour addition", gpc_vertex_list);
|
| 1089 |
|
|
|
| 1090 |
|
| /* Copy the old contour and hole data into the extended arrays */
|
| 1091 |
11 |
▶ | for (c= 0; c < p->num_contours; c++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (c= 0; c < p->num_contours; c++)
|
7 |
4 |
11 |
|
| 1092 |
|
| {
|
| 1093 |
7 |
| extended_hole[c]= p->hole[c];
|
| 1094 |
7 |
| extended_contour[c]= p->contour[c];
|
| 1095 |
|
| }
|
| 1096 |
|
|
|
| 1097 |
|
| /* Copy the new contour and hole onto the end of the extended arrays */
|
| 1098 |
4 |
| c= p->num_contours;
|
| 1099 |
4 |
| extended_hole[c]= hole;
|
| 1100 |
4 |
| extended_contour[c].num_vertices= new_contour->num_vertices;
|
| 1101 |
4 |
▶ | MALLOC(extended_contour[c].vertex, new_contour->num_vertices
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(extended_contour[c].vertex, new_contour->num_vertices
|
3 |
1 |
4 |
| MALLOC(extended_contour[c].vertex, new_contour->num_vertices
|
0 |
3 |
3 |
|
| 1102 |
|
| * sizeof(gpc_vertex), "contour addition", gpc_vertex);
|
| 1103 |
16 |
▶ | for (v= 0; v < new_contour->num_vertices; v++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (v= 0; v < new_contour->num_vertices; v++)
|
12 |
4 |
16 |
|
| 1104 |
12 |
| extended_contour[c].vertex[v]= new_contour->vertex[v];
|
| 1105 |
|
|
|
| 1106 |
4 |
| FREE(p->hole);
|
| 1107 |
4 |
| FREE(p->contour);
|
| 1108 |
|
|
|
| 1109 |
|
| /* Update the polygon information */
|
| 1110 |
4 |
| p->num_contours++;
|
| 1111 |
4 |
| p->hole= extended_hole;
|
| 1112 |
4 |
| p->contour= extended_contour;
|
| 1113 |
4 |
| }
|
| 1114 |
|
|
|
| 1115 |
|
|
|
| 1116 |
4 |
| void gpc_polygon_clip(gpc_op op, gpc_polygon *subj, gpc_polygon *clip,
|
| 1117 |
|
| gpc_polygon *result)
|
| 1118 |
|
| {
|
| 1119 |
4 |
| sb_tree *sbtree= NULL;
|
| 1120 |
4 |
| it_node *it= NULL, *intersect;
|
| 1121 |
|
| edge_node *edge, *prev_edge, *next_edge, *succ_edge, *e0, *e1;
|
| 1122 |
4 |
| edge_node *aet= NULL, *c_heap= NULL, *s_heap= NULL;
|
| 1123 |
4 |
| lmt_node *lmt= NULL, *local_min;
|
| 1124 |
4 |
| polygon_node *out_poly= NULL, *p, *q, *poly, *npoly, *cf= NULL;
|
| 1125 |
|
| vertex_node *vtx, *nv;
|
| 1126 |
|
| h_state horiz[2];
|
| 1127 |
4 |
| int in[2], exists[2], parity[2]= {LEFT, LEFT};
|
| 1128 |
4 |
| int c, v, contributing, search, scanbeam= 0, sbt_entries= 0;
|
| 1129 |
|
| int vclass, bl, br, tl, tr;
|
| 1130 |
4 |
| double *sbt= NULL, xb, px, yb, yt, dy, ix, iy;
|
| 1131 |
|
|
|
| 1132 |
|
| /* Test for trivial NULL result cases */
|
| 1133 |
4 |
▶ | if (((subj->num_contours == 0) && (clip->num_contours == 0))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (((subj->num_contours == 0) && (clip->num_contours == 0))
|
0 |
4 |
4 |
| if (((subj->num_contours == 0) && (clip->num_contours == 0))
|
0 |
0 |
0 |
|
| 1134 |
4 |
▶ | || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
Branch: 3 branches
| Branch | True | False | Total |
| || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
0 |
4 |
4 |
| || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
0 |
0 |
0 |
| || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
0 |
0 |
0 |
|
| 1135 |
4 |
▶ | || ((clip->num_contours == 0) && (op == GPC_INT)))
|
Branch: 2 branches
| Branch | True | False | Total |
| || ((clip->num_contours == 0) && (op == GPC_INT)))
|
0 |
4 |
4 |
| || ((clip->num_contours == 0) && (op == GPC_INT)))
|
0 |
0 |
0 |
|
| 1136 |
|
| {
|
| 1137 |
0 |
| result->num_contours= 0;
|
| 1138 |
0 |
| result->hole= NULL;
|
| 1139 |
0 |
| result->contour= NULL;
|
| 1140 |
0 |
| return;
|
| 1141 |
|
| }
|
| 1142 |
|
|
|
| 1143 |
|
| /* Identify potentialy contributing contours */
|
| 1144 |
4 |
▶ | if (((op == GPC_INT) || (op == GPC_DIFF))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (((op == GPC_INT) || (op == GPC_DIFF))
|
2 |
2 |
4 |
| if (((op == GPC_INT) || (op == GPC_DIFF))
|
1 |
1 |
2 |
|
| 1145 |
3 |
▶ | && (subj->num_contours > 0) && (clip->num_contours > 0))
|
Branch: 2 branches
| Branch | True | False | Total |
| && (subj->num_contours > 0) && (clip->num_contours > 0))
|
3 |
0 |
3 |
| && (subj->num_contours > 0) && (clip->num_contours > 0))
|
3 |
0 |
3 |
|
| 1146 |
3 |
| minimax_test(subj, clip, op);
|
| 1147 |
|
|
|
| 1148 |
|
| /* Build LMT */
|
| 1149 |
4 |
▶ | if (subj->num_contours > 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (subj->num_contours > 0)
|
4 |
0 |
4 |
|
| 1150 |
4 |
| s_heap= build_lmt(&lmt, &sbtree, &sbt_entries, subj, SUBJ, op);
|
| 1151 |
4 |
▶ | if (clip->num_contours > 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (clip->num_contours > 0)
|
4 |
0 |
4 |
|
| 1152 |
4 |
| c_heap= build_lmt(&lmt, &sbtree, &sbt_entries, clip, CLIP, op);
|
| 1153 |
|
|
|
| 1154 |
|
| /* Return a NULL result if no contours contribute */
|
| 1155 |
4 |
▶ | if (lmt == NULL)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (lmt == NULL)
|
0 |
4 |
4 |
|
| 1156 |
|
| {
|
| 1157 |
0 |
| result->num_contours= 0;
|
| 1158 |
0 |
| result->hole= NULL;
|
| 1159 |
0 |
| result->contour= NULL;
|
| 1160 |
0 |
| reset_lmt(&lmt);
|
| 1161 |
0 |
| FREE(s_heap);
|
| 1162 |
0 |
| FREE(c_heap);
|
| 1163 |
0 |
| return;
|
| 1164 |
|
| }
|
| 1165 |
|
|
|
| 1166 |
|
| /* Build scanbeam table from scanbeam tree */
|
| 1167 |
4 |
▶ | MALLOC(sbt, sbt_entries * sizeof(double), "sbt creation", double);
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(sbt, sbt_entries * sizeof(double), "sbt creation", double);
|
4 |
0 |
4 |
| MALLOC(sbt, sbt_entries * sizeof(double), "sbt creation", double);
|
0 |
4 |
4 |
|
| 1168 |
4 |
| build_sbt(&scanbeam, sbt, sbtree);
|
| 1169 |
4 |
| scanbeam= 0;
|
| 1170 |
4 |
| free_sbtree(&sbtree);
|
| 1171 |
|
|
|
| 1172 |
|
| /* Allow pointer re-use without causing memory leak */
|
| 1173 |
4 |
▶ | if (subj == result)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (subj == result)
|
0 |
4 |
4 |
|
| 1174 |
0 |
| gpc_free_polygon(subj);
|
| 1175 |
4 |
▶ | if (clip == result)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (clip == result)
|
0 |
4 |
4 |
|
| 1176 |
0 |
| gpc_free_polygon(clip);
|
| 1177 |
|
|
|
| 1178 |
|
| /* Invert clip polygon for difference operation */
|
| 1179 |
4 |
▶ | if (op == GPC_DIFF)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (op == GPC_DIFF)
|
1 |
3 |
4 |
|
| 1180 |
1 |
| parity[CLIP]= RIGHT;
|
| 1181 |
|
|
|
| 1182 |
4 |
| local_min= lmt;
|
| 1183 |
|
|
|
| 1184 |
|
| /* Process each scanbeam */
|
| 1185 |
80 |
▶ | while (scanbeam < sbt_entries)
|
Branch: 1 branch
| Branch | True | False | Total |
| while (scanbeam < sbt_entries)
|
76 |
4 |
80 |
|
| 1186 |
|
| {
|
| 1187 |
|
| /* Set yb and yt to the bottom and top of the scanbeam */
|
| 1188 |
76 |
| yb= sbt[scanbeam++];
|
| 1189 |
76 |
▶ | if (scanbeam < sbt_entries)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (scanbeam < sbt_entries)
|
72 |
4 |
76 |
|
| 1190 |
|
| {
|
| 1191 |
72 |
| yt= sbt[scanbeam];
|
| 1192 |
72 |
| dy= yt - yb;
|
| 1193 |
|
| }
|
| 1194 |
|
|
|
| 1195 |
|
| /* === SCANBEAM BOUNDARY PROCESSING ================================ */
|
| 1196 |
|
|
|
| 1197 |
|
| /* If LMT node corresponding to yb exists */
|
| 1198 |
76 |
▶ | if (local_min)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (local_min)
|
44 |
32 |
76 |
|
| 1199 |
|
| {
|
| 1200 |
44 |
▶ | if (local_min->y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (local_min->y == yb)
|
16 |
28 |
44 |
|
| 1201 |
|
| {
|
| 1202 |
|
| /* Add edges starting at this local minimum to the AET */
|
| 1203 |
48 |
▶ | for (edge= local_min->first_bound; edge; edge= edge->next_bound)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= local_min->first_bound; edge; edge= edge->next_bound)
|
32 |
16 |
48 |
|
| 1204 |
32 |
| add_edge_to_aet(&aet, edge, NULL);
|
| 1205 |
|
|
|
| 1206 |
16 |
| local_min= local_min->next;
|
| 1207 |
|
| }
|
| 1208 |
|
| }
|
| 1209 |
|
|
|
| 1210 |
|
| /* Set dummy previous x value */
|
| 1211 |
76 |
| px= -DBL_MAX;
|
| 1212 |
|
|
|
| 1213 |
|
| /* Create bundles within AET */
|
| 1214 |
76 |
| e0= aet;
|
| 1215 |
76 |
| e1= aet;
|
| 1216 |
|
|
|
| 1217 |
|
| /* Set up bundle fields of first edge */
|
| 1218 |
76 |
| aet->bundle[ABOVE][ aet->type]= (aet->top.y != yb);
|
| 1219 |
76 |
| aet->bundle[ABOVE][!aet->type]= FALSE;
|
| 1220 |
76 |
| aet->bstate[ABOVE]= UNBUNDLED;
|
| 1221 |
|
|
|
| 1222 |
300 |
▶ | for (next_edge= aet->next; next_edge; next_edge= next_edge->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (next_edge= aet->next; next_edge; next_edge= next_edge->next)
|
224 |
76 |
300 |
|
| 1223 |
|
| {
|
| 1224 |
|
| /* Set up bundle fields of next edge */
|
| 1225 |
224 |
| next_edge->bundle[ABOVE][ next_edge->type]= (next_edge->top.y != yb);
|
| 1226 |
224 |
| next_edge->bundle[ABOVE][!next_edge->type]= FALSE;
|
| 1227 |
224 |
| next_edge->bstate[ABOVE]= UNBUNDLED;
|
| 1228 |
|
|
|
| 1229 |
|
| /* Bundle edges above the scanbeam boundary if they coincide */
|
| 1230 |
224 |
▶ | if (next_edge->bundle[ABOVE][next_edge->type])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (next_edge->bundle[ABOVE][next_edge->type])
|
196 |
28 |
224 |
|
| 1231 |
|
| {
|
| 1232 |
196 |
▶ | if (EQ(e0->xb, next_edge->xb) && EQ(e0->dx, next_edge->dx)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (EQ(e0->xb, next_edge->xb) && EQ(e0->dx, next_edge->dx)
|
14 |
182 |
196 |
| if (EQ(e0->xb, next_edge->xb) && EQ(e0->dx, next_edge->dx)
|
0 |
14 |
14 |
|
| 1233 |
0 |
▶ | && (e0->top.y != yb))
|
Branch: 1 branch
| Branch | True | False | Total |
| && (e0->top.y != yb))
|
0 |
0 |
0 |
|
| 1234 |
|
| {
|
| 1235 |
0 |
| next_edge->bundle[ABOVE][ next_edge->type]^=
|
| 1236 |
0 |
| e0->bundle[ABOVE][ next_edge->type];
|
| 1237 |
0 |
| next_edge->bundle[ABOVE][!next_edge->type]=
|
| 1238 |
0 |
| e0->bundle[ABOVE][!next_edge->type];
|
| 1239 |
0 |
| next_edge->bstate[ABOVE]= BUNDLE_HEAD;
|
| 1240 |
0 |
| e0->bundle[ABOVE][CLIP]= FALSE;
|
| 1241 |
0 |
| e0->bundle[ABOVE][SUBJ]= FALSE;
|
| 1242 |
0 |
| e0->bstate[ABOVE]= BUNDLE_TAIL;
|
| 1243 |
|
| }
|
| 1244 |
196 |
| e0= next_edge;
|
| 1245 |
|
| }
|
| 1246 |
|
| }
|
| 1247 |
|
|
|
| 1248 |
76 |
| horiz[CLIP]= NH;
|
| 1249 |
76 |
| horiz[SUBJ]= NH;
|
| 1250 |
|
|
|
| 1251 |
|
| /* Process each edge at this scanbeam boundary */
|
| 1252 |
376 |
▶ | for (edge= aet; edge; edge= edge->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= aet; edge; edge= edge->next)
|
300 |
76 |
376 |
|
| 1253 |
|
| {
|
| 1254 |
300 |
| exists[CLIP]= edge->bundle[ABOVE][CLIP] +
|
| 1255 |
300 |
| (edge->bundle[BELOW][CLIP] << 1);
|
| 1256 |
300 |
| exists[SUBJ]= edge->bundle[ABOVE][SUBJ] +
|
| 1257 |
300 |
| (edge->bundle[BELOW][SUBJ] << 1);
|
| 1258 |
|
|
|
| 1259 |
300 |
▶ | if (exists[CLIP] || exists[SUBJ])
|
Branch: 2 branches
| Branch | True | False | Total |
| if (exists[CLIP] || exists[SUBJ])
|
268 |
32 |
300 |
| if (exists[CLIP] || exists[SUBJ])
|
268 |
0 |
268 |
|
| 1260 |
|
| {
|
| 1261 |
|
| /* Set bundle side */
|
| 1262 |
300 |
| edge->bside[CLIP]= parity[CLIP];
|
| 1263 |
300 |
| edge->bside[SUBJ]= parity[SUBJ];
|
| 1264 |
|
|
|
| 1265 |
|
| /* Determine contributing status and quadrant occupancies */
|
| 1266 |
300 |
| switch (op)
|
| 1267 |
|
| {
|
| 1268 |
208 |
| case GPC_DIFF:
|
| 1269 |
|
| case GPC_INT:
|
| 1270 |
24 |
▶ | contributing= (exists[CLIP] && (parity[SUBJ] || horiz[SUBJ]))
|
Branch: 2 branches
| Branch | True | False | Total |
| contributing= (exists[CLIP] && (parity[SUBJ] || horiz[SUBJ]))
|
6 |
18 |
24 |
| contributing= (exists[CLIP] && (parity[SUBJ] || horiz[SUBJ]))
|
6 |
0 |
6 |
|
| 1271 |
190 |
▶ | || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
184 |
6 |
190 |
| || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
99 |
85 |
184 |
| || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
97 |
2 |
99 |
|
| 1272 |
416 |
▶ | || (exists[CLIP] && exists[SUBJ]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[CLIP] && exists[SUBJ]
|
24 |
184 |
208 |
| || (exists[CLIP] && exists[SUBJ]
|
6 |
97 |
103 |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
6 |
6 |
|
| 1273 |
0 |
▶ | && (parity[CLIP] == parity[SUBJ]));
|
Branch: 1 branch
| Branch | True | False | Total |
| && (parity[CLIP] == parity[SUBJ]));
|
0 |
0 |
0 |
|
| 1274 |
416 |
| br= (parity[CLIP])
|
| 1275 |
208 |
▶ | && (parity[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ]);
|
96 |
112 |
208 |
| && (parity[SUBJ]);
|
53 |
43 |
96 |
|
| 1276 |
416 |
| bl= (parity[CLIP] ^ edge->bundle[ABOVE][CLIP])
|
| 1277 |
208 |
▶ | && (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
96 |
112 |
208 |
| && (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
53 |
43 |
96 |
|
| 1278 |
416 |
| tr= (parity[CLIP] ^ (horiz[CLIP]!=NH))
|
| 1279 |
208 |
▶ | && (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
97 |
111 |
208 |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
53 |
44 |
97 |
|
| 1280 |
416 |
| tl= (parity[CLIP] ^ (horiz[CLIP]!=NH) ^ edge->bundle[BELOW][CLIP])
|
| 1281 |
208 |
▶ | && (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
97 |
111 |
208 |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
53 |
44 |
97 |
|
| 1282 |
208 |
| break;
|
| 1283 |
0 |
| case GPC_XOR:
|
| 1284 |
0 |
▶ | contributing= exists[CLIP] || exists[SUBJ];
|
Branch: 2 branches
| Branch | True | False | Total |
| contributing= exists[CLIP] || exists[SUBJ];
|
0 |
0 |
0 |
| contributing= exists[CLIP] || exists[SUBJ];
|
0 |
0 |
0 |
|
| 1285 |
0 |
| br= (parity[CLIP])
|
| 1286 |
0 |
| ^ (parity[SUBJ]);
|
| 1287 |
0 |
| bl= (parity[CLIP] ^ edge->bundle[ABOVE][CLIP])
|
| 1288 |
0 |
| ^ (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
| 1289 |
0 |
| tr= (parity[CLIP] ^ (horiz[CLIP]!=NH))
|
| 1290 |
0 |
| ^ (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
| 1291 |
0 |
| tl= (parity[CLIP] ^ (horiz[CLIP]!=NH) ^ edge->bundle[BELOW][CLIP])
|
| 1292 |
0 |
| ^ (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
| 1293 |
0 |
| break;
|
| 1294 |
92 |
| case GPC_UNION:
|
| 1295 |
8 |
▶ | contributing= (exists[CLIP] && (!parity[SUBJ] || horiz[SUBJ]))
|
Branch: 2 branches
| Branch | True | False | Total |
| contributing= (exists[CLIP] && (!parity[SUBJ] || horiz[SUBJ]))
|
6 |
2 |
8 |
| contributing= (exists[CLIP] && (!parity[SUBJ] || horiz[SUBJ]))
|
6 |
0 |
6 |
|
| 1296 |
90 |
▶ | || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
84 |
6 |
90 |
| || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
1 |
83 |
84 |
| || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
1 |
0 |
1 |
|
| 1297 |
184 |
▶ | || (exists[CLIP] && exists[SUBJ]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[CLIP] && exists[SUBJ]
|
8 |
84 |
92 |
| || (exists[CLIP] && exists[SUBJ]
|
6 |
1 |
7 |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
6 |
6 |
|
| 1298 |
0 |
▶ | && (parity[CLIP] == parity[SUBJ]));
|
Branch: 1 branch
| Branch | True | False | Total |
| && (parity[CLIP] == parity[SUBJ]));
|
0 |
0 |
0 |
|
| 1299 |
184 |
| br= (parity[CLIP])
|
| 1300 |
92 |
▶ | || (parity[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ]);
|
88 |
4 |
92 |
| || (parity[SUBJ]);
|
47 |
41 |
88 |
|
| 1301 |
184 |
| bl= (parity[CLIP] ^ edge->bundle[ABOVE][CLIP])
|
| 1302 |
92 |
▶ | || (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
88 |
4 |
92 |
| || (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
47 |
41 |
88 |
|
| 1303 |
184 |
| tr= (parity[CLIP] ^ (horiz[CLIP]!=NH))
|
| 1304 |
92 |
▶ | || (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
87 |
5 |
92 |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
47 |
40 |
87 |
|
| 1305 |
184 |
| tl= (parity[CLIP] ^ (horiz[CLIP]!=NH) ^ edge->bundle[BELOW][CLIP])
|
| 1306 |
92 |
▶ | || (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
87 |
5 |
92 |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
47 |
40 |
87 |
|
| 1307 |
92 |
| break;
|
| 1308 |
|
| }
|
| 1309 |
|
|
|
| 1310 |
|
| /* Update parity */
|
| 1311 |
300 |
| parity[CLIP]^= edge->bundle[ABOVE][CLIP];
|
| 1312 |
300 |
| parity[SUBJ]^= edge->bundle[ABOVE][SUBJ];
|
| 1313 |
|
|
|
| 1314 |
|
| /* Update horizontal state */
|
| 1315 |
300 |
▶ | if (exists[CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (exists[CLIP])
|
32 |
268 |
300 |
|
| 1316 |
32 |
| horiz[CLIP]=
|
| 1317 |
32 |
| next_h_state[horiz[CLIP]]
|
| 1318 |
32 |
| [((exists[CLIP] - 1) << 1) + parity[CLIP]];
|
| 1319 |
300 |
▶ | if (exists[SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (exists[SUBJ])
|
268 |
32 |
300 |
|
| 1320 |
268 |
| horiz[SUBJ]=
|
| 1321 |
268 |
| next_h_state[horiz[SUBJ]]
|
| 1322 |
268 |
| [((exists[SUBJ] - 1) << 1) + parity[SUBJ]];
|
| 1323 |
|
|
|
| 1324 |
300 |
| vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
|
| 1325 |
|
|
|
| 1326 |
300 |
▶ | if (contributing)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (contributing)
|
190 |
110 |
300 |
|
| 1327 |
|
| {
|
| 1328 |
190 |
| xb= edge->xb;
|
| 1329 |
|
|
|
| 1330 |
190 |
| switch (vclass)
|
| 1331 |
|
| {
|
| 1332 |
12 |
| case EMN:
|
| 1333 |
|
| case IMN:
|
| 1334 |
12 |
| add_local_min(&out_poly, edge, xb, yb);
|
| 1335 |
12 |
| px= xb;
|
| 1336 |
12 |
| cf= edge->outp[ABOVE];
|
| 1337 |
12 |
| break;
|
| 1338 |
4 |
| case ERI:
|
| 1339 |
4 |
▶ | if (xb != px)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != px)
|
0 |
4 |
4 |
|
| 1340 |
|
| {
|
| 1341 |
0 |
| add_right(cf, xb, yb);
|
| 1342 |
0 |
| px= xb;
|
| 1343 |
|
| }
|
| 1344 |
4 |
| edge->outp[ABOVE]= cf;
|
| 1345 |
4 |
| cf= NULL;
|
| 1346 |
4 |
| break;
|
| 1347 |
5 |
| case ELI:
|
| 1348 |
5 |
| add_left(edge->outp[BELOW], xb, yb);
|
| 1349 |
5 |
| px= xb;
|
| 1350 |
5 |
| cf= edge->outp[BELOW];
|
| 1351 |
5 |
| break;
|
| 1352 |
4 |
| case EMX:
|
| 1353 |
4 |
▶ | if (xb != px)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != px)
|
2 |
2 |
4 |
|
| 1354 |
|
| {
|
| 1355 |
2 |
| add_left(cf, xb, yb);
|
| 1356 |
2 |
| px= xb;
|
| 1357 |
|
| }
|
| 1358 |
4 |
| merge_right(cf, edge->outp[BELOW], out_poly);
|
| 1359 |
4 |
| cf= NULL;
|
| 1360 |
4 |
| break;
|
| 1361 |
8 |
| case ILI:
|
| 1362 |
8 |
▶ | if (xb != px)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != px)
|
3 |
5 |
8 |
|
| 1363 |
|
| {
|
| 1364 |
3 |
| add_left(cf, xb, yb);
|
| 1365 |
3 |
| px= xb;
|
| 1366 |
|
| }
|
| 1367 |
8 |
| edge->outp[ABOVE]= cf;
|
| 1368 |
8 |
| cf= NULL;
|
| 1369 |
8 |
| break;
|
| 1370 |
6 |
| case IRI:
|
| 1371 |
6 |
| add_right(edge->outp[BELOW], xb, yb);
|
| 1372 |
6 |
| px= xb;
|
| 1373 |
6 |
| cf= edge->outp[BELOW];
|
| 1374 |
6 |
| edge->outp[BELOW]= NULL;
|
| 1375 |
6 |
| break;
|
| 1376 |
7 |
| case IMX:
|
| 1377 |
7 |
▶ | if (xb != px)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != px)
|
3 |
4 |
7 |
|
| 1378 |
|
| {
|
| 1379 |
3 |
| add_right(cf, xb, yb);
|
| 1380 |
3 |
| px= xb;
|
| 1381 |
|
| }
|
| 1382 |
7 |
| merge_left(cf, edge->outp[BELOW], out_poly);
|
| 1383 |
7 |
| cf= NULL;
|
| 1384 |
7 |
| edge->outp[BELOW]= NULL;
|
| 1385 |
7 |
| break;
|
| 1386 |
0 |
| case IMM:
|
| 1387 |
0 |
▶ | if (xb != px)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != px)
|
0 |
0 |
0 |
|
| 1388 |
|
| {
|
| 1389 |
0 |
| add_right(cf, xb, yb);
|
| 1390 |
0 |
| px= xb;
|
| 1391 |
|
| }
|
| 1392 |
0 |
| merge_left(cf, edge->outp[BELOW], out_poly);
|
| 1393 |
0 |
| edge->outp[BELOW]= NULL;
|
| 1394 |
0 |
| add_local_min(&out_poly, edge, xb, yb);
|
| 1395 |
0 |
| cf= edge->outp[ABOVE];
|
| 1396 |
0 |
| break;
|
| 1397 |
0 |
| case EMM:
|
| 1398 |
0 |
▶ | if (xb != px)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != px)
|
0 |
0 |
0 |
|
| 1399 |
|
| {
|
| 1400 |
0 |
| add_left(cf, xb, yb);
|
| 1401 |
0 |
| px= xb;
|
| 1402 |
|
| }
|
| 1403 |
0 |
| merge_right(cf, edge->outp[BELOW], out_poly);
|
| 1404 |
0 |
| edge->outp[BELOW]= NULL;
|
| 1405 |
0 |
| add_local_min(&out_poly, edge, xb, yb);
|
| 1406 |
0 |
| cf= edge->outp[ABOVE];
|
| 1407 |
0 |
| break;
|
| 1408 |
71 |
| case LED:
|
| 1409 |
71 |
▶ | if (edge->bot.y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->bot.y == yb)
|
11 |
60 |
71 |
|
| 1410 |
11 |
| add_left(edge->outp[BELOW], xb, yb);
|
| 1411 |
71 |
| edge->outp[ABOVE]= edge->outp[BELOW];
|
| 1412 |
71 |
| px= xb;
|
| 1413 |
71 |
| break;
|
| 1414 |
73 |
| case RED:
|
| 1415 |
73 |
▶ | if (edge->bot.y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->bot.y == yb)
|
12 |
61 |
73 |
|
| 1416 |
12 |
| add_right(edge->outp[BELOW], xb, yb);
|
| 1417 |
73 |
| edge->outp[ABOVE]= edge->outp[BELOW];
|
| 1418 |
73 |
| px= xb;
|
| 1419 |
73 |
| break;
|
| 1420 |
0 |
| default:
|
| 1421 |
0 |
| break;
|
| 1422 |
|
| } /* End of switch */
|
| 1423 |
|
| } /* End of contributing conditional */
|
| 1424 |
|
| } /* End of edge exists conditional */
|
| 1425 |
|
| } /* End of AET loop */
|
| 1426 |
|
|
|
| 1427 |
|
| /* Delete terminating edges from the AET, otherwise compute xt */
|
| 1428 |
376 |
▶ | for (edge= aet; edge; edge= edge->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= aet; edge; edge= edge->next)
|
300 |
76 |
376 |
|
| 1429 |
|
| {
|
| 1430 |
300 |
▶ | if (edge->top.y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->top.y == yb)
|
32 |
268 |
300 |
|
| 1431 |
|
| {
|
| 1432 |
32 |
| prev_edge= edge->prev;
|
| 1433 |
32 |
| next_edge= edge->next;
|
| 1434 |
32 |
▶ | if (prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge)
|
24 |
8 |
32 |
|
| 1435 |
24 |
| prev_edge->next= next_edge;
|
| 1436 |
|
| else
|
| 1437 |
8 |
| aet= next_edge;
|
| 1438 |
32 |
▶ | if (next_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (next_edge)
|
28 |
4 |
32 |
|
| 1439 |
28 |
| next_edge->prev= prev_edge;
|
| 1440 |
|
|
|
| 1441 |
|
| /* Copy bundle head state to the adjacent tail edge if required */
|
| 1442 |
32 |
▶ | if ((edge->bstate[BELOW] == BUNDLE_HEAD) && prev_edge)
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((edge->bstate[BELOW] == BUNDLE_HEAD) && prev_edge)
|
0 |
32 |
32 |
| if ((edge->bstate[BELOW] == BUNDLE_HEAD) && prev_edge)
|
0 |
0 |
0 |
|
| 1443 |
|
| {
|
| 1444 |
0 |
▶ | if (prev_edge->bstate[BELOW] == BUNDLE_TAIL)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->bstate[BELOW] == BUNDLE_TAIL)
|
0 |
0 |
0 |
|
| 1445 |
|
| {
|
| 1446 |
0 |
| prev_edge->outp[BELOW]= edge->outp[BELOW];
|
| 1447 |
0 |
| prev_edge->bstate[BELOW]= UNBUNDLED;
|
| 1448 |
0 |
▶ | if (prev_edge->prev)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->prev)
|
0 |
0 |
0 |
|
| 1449 |
0 |
▶ | if (prev_edge->prev->bstate[BELOW] == BUNDLE_TAIL)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->prev->bstate[BELOW] == BUNDLE_TAIL)
|
0 |
0 |
0 |
|
| 1450 |
0 |
| prev_edge->bstate[BELOW]= BUNDLE_HEAD;
|
| 1451 |
|
| }
|
| 1452 |
|
| }
|
| 1453 |
|
| }
|
| 1454 |
|
| else
|
| 1455 |
|
| {
|
| 1456 |
268 |
▶ | if (edge->top.y == yt)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->top.y == yt)
|
76 |
192 |
268 |
|
| 1457 |
76 |
| edge->xt= edge->top.x;
|
| 1458 |
|
| else
|
| 1459 |
192 |
| edge->xt= edge->bot.x + edge->dx * (yt - edge->bot.y);
|
| 1460 |
|
| }
|
| 1461 |
|
| }
|
| 1462 |
|
|
|
| 1463 |
76 |
▶ | if (scanbeam < sbt_entries)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (scanbeam < sbt_entries)
|
72 |
4 |
76 |
|
| 1464 |
|
| {
|
| 1465 |
|
| /* === SCANBEAM INTERIOR PROCESSING ============================== */
|
| 1466 |
|
|
|
| 1467 |
72 |
| build_intersection_table(&it, aet, dy);
|
| 1468 |
|
|
|
| 1469 |
|
| /* Process each node in the intersection table */
|
| 1470 |
76 |
▶ | for (intersect= it; intersect; intersect= intersect->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (intersect= it; intersect; intersect= intersect->next)
|
4 |
72 |
76 |
|
| 1471 |
|
| {
|
| 1472 |
4 |
| e0= intersect->ie[0];
|
| 1473 |
4 |
| e1= intersect->ie[1];
|
| 1474 |
|
|
|
| 1475 |
|
| /* Only generate output for contributing intersections */
|
| 1476 |
4 |
▶ | if ((e0->bundle[ABOVE][CLIP] || e0->bundle[ABOVE][SUBJ])
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((e0->bundle[ABOVE][CLIP] || e0->bundle[ABOVE][SUBJ])
|
4 |
0 |
4 |
| if ((e0->bundle[ABOVE][CLIP] || e0->bundle[ABOVE][SUBJ])
|
4 |
0 |
4 |
|
| 1477 |
4 |
▶ | && (e1->bundle[ABOVE][CLIP] || e1->bundle[ABOVE][SUBJ]))
|
Branch: 2 branches
| Branch | True | False | Total |
| && (e1->bundle[ABOVE][CLIP] || e1->bundle[ABOVE][SUBJ]))
|
0 |
4 |
4 |
| && (e1->bundle[ABOVE][CLIP] || e1->bundle[ABOVE][SUBJ]))
|
0 |
0 |
0 |
|
| 1478 |
|
| {
|
| 1479 |
4 |
| p= e0->outp[ABOVE];
|
| 1480 |
4 |
| q= e1->outp[ABOVE];
|
| 1481 |
4 |
| ix= intersect->point.x;
|
| 1482 |
4 |
| iy= intersect->point.y + yb;
|
| 1483 |
|
|
|
| 1484 |
0 |
▶ | in[CLIP]= ( e0->bundle[ABOVE][CLIP] && !e0->bside[CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| in[CLIP]= ( e0->bundle[ABOVE][CLIP] && !e0->bside[CLIP])
|
0 |
0 |
0 |
|
| 1485 |
4 |
▶ | || ( e1->bundle[ABOVE][CLIP] && e1->bside[CLIP])
|
Branch: 2 branches
| Branch | True | False | Total |
| || ( e1->bundle[ABOVE][CLIP] && e1->bside[CLIP])
|
4 |
0 |
4 |
| || ( e1->bundle[ABOVE][CLIP] && e1->bside[CLIP])
|
3 |
1 |
4 |
|
| 1486 |
8 |
▶ | || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
0 |
4 |
4 |
| || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
3 |
0 |
3 |
| || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
0 |
3 |
3 |
|
| 1487 |
0 |
▶ | && e0->bside[CLIP] && e1->bside[CLIP]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && e0->bside[CLIP] && e1->bside[CLIP]);
|
0 |
0 |
0 |
| && e0->bside[CLIP] && e1->bside[CLIP]);
|
0 |
0 |
0 |
|
| 1488 |
4 |
▶ | in[SUBJ]= ( e0->bundle[ABOVE][SUBJ] && !e0->bside[SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| in[SUBJ]= ( e0->bundle[ABOVE][SUBJ] && !e0->bside[SUBJ])
|
0 |
4 |
4 |
|
| 1489 |
0 |
▶ | || ( e1->bundle[ABOVE][SUBJ] && e1->bside[SUBJ])
|
Branch: 2 branches
| Branch | True | False | Total |
| || ( e1->bundle[ABOVE][SUBJ] && e1->bside[SUBJ])
|
0 |
0 |
0 |
| || ( e1->bundle[ABOVE][SUBJ] && e1->bside[SUBJ])
|
0 |
0 |
0 |
|
| 1490 |
8 |
▶ | || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
4 |
0 |
4 |
| || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
0 |
0 |
0 |
| || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
0 |
0 |
0 |
|
| 1491 |
0 |
▶ | && e0->bside[SUBJ] && e1->bside[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && e0->bside[SUBJ] && e1->bside[SUBJ]);
|
0 |
0 |
0 |
| && e0->bside[SUBJ] && e1->bside[SUBJ]);
|
0 |
0 |
0 |
|
| 1492 |
|
|
|
| 1493 |
|
| /* Determine quadrant occupancies */
|
| 1494 |
4 |
| switch (op)
|
| 1495 |
|
| {
|
| 1496 |
3 |
| case GPC_DIFF:
|
| 1497 |
|
| case GPC_INT:
|
| 1498 |
6 |
| tr= (in[CLIP])
|
| 1499 |
3 |
▶ | && (in[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ]);
|
1 |
2 |
3 |
| && (in[SUBJ]);
|
1 |
0 |
1 |
|
| 1500 |
6 |
| tl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP])
|
| 1501 |
3 |
▶ | && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
2 |
1 |
3 |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
2 |
0 |
2 |
|
| 1502 |
6 |
| br= (in[CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 1503 |
3 |
▶ | && (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
1 |
2 |
3 |
| && (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
1 |
1 |
|
| 1504 |
6 |
| bl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 1505 |
3 |
▶ | && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
2 |
1 |
3 |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
2 |
2 |
|
| 1506 |
3 |
| break;
|
| 1507 |
0 |
| case GPC_XOR:
|
| 1508 |
0 |
| tr= (in[CLIP])
|
| 1509 |
0 |
| ^ (in[SUBJ]);
|
| 1510 |
0 |
| tl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP])
|
| 1511 |
0 |
| ^ (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
| 1512 |
0 |
| br= (in[CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 1513 |
0 |
| ^ (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
| 1514 |
0 |
| bl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 1515 |
0 |
| ^ (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
| 1516 |
0 |
| break;
|
| 1517 |
1 |
| case GPC_UNION:
|
| 1518 |
2 |
| tr= (in[CLIP])
|
| 1519 |
1 |
▶ | || (in[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ]);
|
1 |
0 |
1 |
| || (in[SUBJ]);
|
1 |
0 |
1 |
|
| 1520 |
2 |
| tl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP])
|
| 1521 |
1 |
▶ | || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
0 |
1 |
1 |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 1522 |
2 |
| br= (in[CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 1523 |
1 |
▶ | || (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
1 |
0 |
1 |
| || (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
1 |
1 |
|
| 1524 |
2 |
| bl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 1525 |
1 |
▶ | || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
1 |
1 |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 1526 |
1 |
| break;
|
| 1527 |
|
| }
|
| 1528 |
|
|
|
| 1529 |
4 |
| vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
|
| 1530 |
|
|
|
| 1531 |
4 |
| switch (vclass)
|
| 1532 |
|
| {
|
| 1533 |
0 |
| case EMN:
|
| 1534 |
0 |
| add_local_min(&out_poly, e0, ix, iy);
|
| 1535 |
0 |
| e1->outp[ABOVE]= e0->outp[ABOVE];
|
| 1536 |
0 |
| break;
|
| 1537 |
0 |
| case ERI:
|
| 1538 |
0 |
▶ | if (p)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p)
|
0 |
0 |
0 |
|
| 1539 |
|
| {
|
| 1540 |
0 |
| add_right(p, ix, iy);
|
| 1541 |
0 |
| e1->outp[ABOVE]= p;
|
| 1542 |
0 |
| e0->outp[ABOVE]= NULL;
|
| 1543 |
|
| }
|
| 1544 |
0 |
| break;
|
| 1545 |
2 |
| case ELI:
|
| 1546 |
2 |
▶ | if (q)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (q)
|
2 |
0 |
2 |
|
| 1547 |
|
| {
|
| 1548 |
2 |
| add_left(q, ix, iy);
|
| 1549 |
2 |
| e0->outp[ABOVE]= q;
|
| 1550 |
2 |
| e1->outp[ABOVE]= NULL;
|
| 1551 |
|
| }
|
| 1552 |
2 |
| break;
|
| 1553 |
1 |
| case EMX:
|
| 1554 |
1 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
1 |
0 |
1 |
| if (p && q)
|
1 |
0 |
1 |
|
| 1555 |
|
| {
|
| 1556 |
1 |
| add_left(p, ix, iy);
|
| 1557 |
1 |
| merge_right(p, q, out_poly);
|
| 1558 |
1 |
| e0->outp[ABOVE]= NULL;
|
| 1559 |
1 |
| e1->outp[ABOVE]= NULL;
|
| 1560 |
|
| }
|
| 1561 |
1 |
| break;
|
| 1562 |
0 |
| case IMN:
|
| 1563 |
0 |
| add_local_min(&out_poly, e0, ix, iy);
|
| 1564 |
0 |
| e1->outp[ABOVE]= e0->outp[ABOVE];
|
| 1565 |
0 |
| break;
|
| 1566 |
1 |
| case ILI:
|
| 1567 |
1 |
▶ | if (p)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p)
|
1 |
0 |
1 |
|
| 1568 |
|
| {
|
| 1569 |
1 |
| add_left(p, ix, iy);
|
| 1570 |
1 |
| e1->outp[ABOVE]= p;
|
| 1571 |
1 |
| e0->outp[ABOVE]= NULL;
|
| 1572 |
|
| }
|
| 1573 |
1 |
| break;
|
| 1574 |
0 |
| case IRI:
|
| 1575 |
0 |
▶ | if (q)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (q)
|
0 |
0 |
0 |
|
| 1576 |
|
| {
|
| 1577 |
0 |
| add_right(q, ix, iy);
|
| 1578 |
0 |
| e0->outp[ABOVE]= q;
|
| 1579 |
0 |
| e1->outp[ABOVE]= NULL;
|
| 1580 |
|
| }
|
| 1581 |
0 |
| break;
|
| 1582 |
0 |
| case IMX:
|
| 1583 |
0 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
0 |
0 |
0 |
| if (p && q)
|
0 |
0 |
0 |
|
| 1584 |
|
| {
|
| 1585 |
0 |
| add_right(p, ix, iy);
|
| 1586 |
0 |
| merge_left(p, q, out_poly);
|
| 1587 |
0 |
| e0->outp[ABOVE]= NULL;
|
| 1588 |
0 |
| e1->outp[ABOVE]= NULL;
|
| 1589 |
|
| }
|
| 1590 |
0 |
| break;
|
| 1591 |
0 |
| case IMM:
|
| 1592 |
0 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
0 |
0 |
0 |
| if (p && q)
|
0 |
0 |
0 |
|
| 1593 |
|
| {
|
| 1594 |
0 |
| add_right(p, ix, iy);
|
| 1595 |
0 |
| merge_left(p, q, out_poly);
|
| 1596 |
0 |
| add_local_min(&out_poly, e0, ix, iy);
|
| 1597 |
0 |
| e1->outp[ABOVE]= e0->outp[ABOVE];
|
| 1598 |
|
| }
|
| 1599 |
0 |
| break;
|
| 1600 |
0 |
| case EMM:
|
| 1601 |
0 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
0 |
0 |
0 |
| if (p && q)
|
0 |
0 |
0 |
|
| 1602 |
|
| {
|
| 1603 |
0 |
| add_left(p, ix, iy);
|
| 1604 |
0 |
| merge_right(p, q, out_poly);
|
| 1605 |
0 |
| add_local_min(&out_poly, e0, ix, iy);
|
| 1606 |
0 |
| e1->outp[ABOVE]= e0->outp[ABOVE];
|
| 1607 |
|
| }
|
| 1608 |
0 |
| break;
|
| 1609 |
0 |
| default:
|
| 1610 |
0 |
| break;
|
| 1611 |
|
| } /* End of switch */
|
| 1612 |
|
| } /* End of contributing intersection conditional */
|
| 1613 |
|
|
|
| 1614 |
|
| /* Swap bundle sides in response to edge crossing */
|
| 1615 |
4 |
▶ | if (e0->bundle[ABOVE][CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e0->bundle[ABOVE][CLIP])
|
0 |
4 |
4 |
|
| 1616 |
0 |
| e1->bside[CLIP]= !e1->bside[CLIP];
|
| 1617 |
4 |
▶ | if (e1->bundle[ABOVE][CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e1->bundle[ABOVE][CLIP])
|
4 |
0 |
4 |
|
| 1618 |
4 |
| e0->bside[CLIP]= !e0->bside[CLIP];
|
| 1619 |
4 |
▶ | if (e0->bundle[ABOVE][SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e0->bundle[ABOVE][SUBJ])
|
4 |
0 |
4 |
|
| 1620 |
4 |
| e1->bside[SUBJ]= !e1->bside[SUBJ];
|
| 1621 |
4 |
▶ | if (e1->bundle[ABOVE][SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e1->bundle[ABOVE][SUBJ])
|
0 |
4 |
4 |
|
| 1622 |
0 |
| e0->bside[SUBJ]= !e0->bside[SUBJ];
|
| 1623 |
|
|
|
| 1624 |
|
| /* Swap e0 and e1 bundles in the AET */
|
| 1625 |
4 |
| prev_edge= e0->prev;
|
| 1626 |
4 |
| next_edge= e1->next;
|
| 1627 |
4 |
▶ | if (next_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (next_edge)
|
4 |
0 |
4 |
|
| 1628 |
4 |
| next_edge->prev= e0;
|
| 1629 |
|
|
|
| 1630 |
4 |
▶ | if (e0->bstate[ABOVE] == BUNDLE_HEAD)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e0->bstate[ABOVE] == BUNDLE_HEAD)
|
0 |
4 |
4 |
|
| 1631 |
|
| {
|
| 1632 |
0 |
| search= TRUE;
|
| 1633 |
0 |
▶ | while (search)
|
Branch: 1 branch
| Branch | True | False | Total |
| while (search)
|
0 |
0 |
0 |
|
| 1634 |
|
| {
|
| 1635 |
0 |
| prev_edge= prev_edge->prev;
|
| 1636 |
0 |
▶ | if (prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge)
|
0 |
0 |
0 |
|
| 1637 |
|
| {
|
| 1638 |
0 |
▶ | if (prev_edge->bstate[ABOVE] != BUNDLE_TAIL)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->bstate[ABOVE] != BUNDLE_TAIL)
|
0 |
0 |
0 |
|
| 1639 |
0 |
| search= FALSE;
|
| 1640 |
|
| }
|
| 1641 |
|
| else
|
| 1642 |
0 |
| search= FALSE;
|
| 1643 |
|
| }
|
| 1644 |
|
| }
|
| 1645 |
4 |
▶ | if (!prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!prev_edge)
|
0 |
4 |
4 |
|
| 1646 |
|
| {
|
| 1647 |
0 |
| aet->prev= e1;
|
| 1648 |
0 |
| e1->next= aet;
|
| 1649 |
0 |
| aet= e0->next;
|
| 1650 |
|
| }
|
| 1651 |
|
| else
|
| 1652 |
|
| {
|
| 1653 |
4 |
| prev_edge->next->prev= e1;
|
| 1654 |
4 |
| e1->next= prev_edge->next;
|
| 1655 |
4 |
| prev_edge->next= e0->next;
|
| 1656 |
|
| }
|
| 1657 |
4 |
| e0->next->prev= prev_edge;
|
| 1658 |
4 |
| e1->next->prev= e1;
|
| 1659 |
4 |
| e0->next= next_edge;
|
| 1660 |
|
| } /* End of IT loop*/
|
| 1661 |
|
|
|
| 1662 |
|
| /* Prepare for next scanbeam */
|
| 1663 |
340 |
▶ | for (edge= aet; edge; edge= next_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= aet; edge; edge= next_edge)
|
268 |
72 |
340 |
|
| 1664 |
|
| {
|
| 1665 |
268 |
| next_edge= edge->next;
|
| 1666 |
268 |
| succ_edge= edge->succ;
|
| 1667 |
|
|
|
| 1668 |
268 |
▶ | if ((edge->top.y == yt) && succ_edge)
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((edge->top.y == yt) && succ_edge)
|
76 |
192 |
268 |
| if ((edge->top.y == yt) && succ_edge)
|
44 |
32 |
76 |
|
| 1669 |
|
| {
|
| 1670 |
|
| /* Replace AET edge by its successor */
|
| 1671 |
44 |
| succ_edge->outp[BELOW]= edge->outp[ABOVE];
|
| 1672 |
44 |
| succ_edge->bstate[BELOW]= edge->bstate[ABOVE];
|
| 1673 |
44 |
| succ_edge->bundle[BELOW][CLIP]= edge->bundle[ABOVE][CLIP];
|
| 1674 |
44 |
| succ_edge->bundle[BELOW][SUBJ]= edge->bundle[ABOVE][SUBJ];
|
| 1675 |
44 |
| prev_edge= edge->prev;
|
| 1676 |
44 |
▶ | if (prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge)
|
32 |
12 |
44 |
|
| 1677 |
32 |
| prev_edge->next= succ_edge;
|
| 1678 |
|
| else
|
| 1679 |
12 |
| aet= succ_edge;
|
| 1680 |
44 |
▶ | if (next_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (next_edge)
|
28 |
16 |
44 |
|
| 1681 |
28 |
| next_edge->prev= succ_edge;
|
| 1682 |
44 |
| succ_edge->prev= prev_edge;
|
| 1683 |
44 |
| succ_edge->next= next_edge;
|
| 1684 |
|
| }
|
| 1685 |
|
| else
|
| 1686 |
|
| {
|
| 1687 |
|
| /* Update this edge */
|
| 1688 |
224 |
| edge->outp[BELOW]= edge->outp[ABOVE];
|
| 1689 |
224 |
| edge->bstate[BELOW]= edge->bstate[ABOVE];
|
| 1690 |
224 |
| edge->bundle[BELOW][CLIP]= edge->bundle[ABOVE][CLIP];
|
| 1691 |
224 |
| edge->bundle[BELOW][SUBJ]= edge->bundle[ABOVE][SUBJ];
|
| 1692 |
224 |
| edge->xb= edge->xt;
|
| 1693 |
|
| }
|
| 1694 |
268 |
| edge->outp[ABOVE]= NULL;
|
| 1695 |
|
| }
|
| 1696 |
|
| }
|
| 1697 |
|
| } /* === END OF SCANBEAM PROCESSING ================================== */
|
| 1698 |
|
|
|
| 1699 |
|
| /* Generate result polygon from out_poly */
|
| 1700 |
4 |
| result->contour= NULL;
|
| 1701 |
4 |
| result->hole= NULL;
|
| 1702 |
4 |
| result->num_contours= count_contours(out_poly);
|
| 1703 |
4 |
▶ | if (result->num_contours > 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (result->num_contours > 0)
|
4 |
0 |
4 |
|
| 1704 |
|
| {
|
| 1705 |
4 |
▶ | MALLOC(result->hole, result->num_contours
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(result->hole, result->num_contours
|
4 |
0 |
4 |
| MALLOC(result->hole, result->num_contours
|
0 |
4 |
4 |
|
| 1706 |
|
| * sizeof(int), "hole flag table creation", int);
|
| 1707 |
4 |
▶ | MALLOC(result->contour, result->num_contours
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(result->contour, result->num_contours
|
4 |
0 |
4 |
| MALLOC(result->contour, result->num_contours
|
0 |
4 |
4 |
|
| 1708 |
|
| * sizeof(gpc_vertex_list), "contour creation", gpc_vertex_list);
|
| 1709 |
|
|
|
| 1710 |
4 |
| c= 0;
|
| 1711 |
16 |
▶ | for (poly= out_poly; poly; poly= npoly)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (poly= out_poly; poly; poly= npoly)
|
12 |
4 |
16 |
|
| 1712 |
|
| {
|
| 1713 |
12 |
| npoly= poly->next;
|
| 1714 |
12 |
▶ | if (poly->active)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (poly->active)
|
10 |
2 |
12 |
|
| 1715 |
|
| {
|
| 1716 |
10 |
| result->hole[c]= poly->proxy->hole;
|
| 1717 |
10 |
| result->contour[c].num_vertices= poly->active;
|
| 1718 |
10 |
▶ | MALLOC(result->contour[c].vertex,
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(result->contour[c].vertex,
|
10 |
0 |
10 |
| MALLOC(result->contour[c].vertex,
|
0 |
10 |
10 |
|
| 1719 |
|
| result->contour[c].num_vertices * sizeof(gpc_vertex),
|
| 1720 |
|
| "vertex creation", gpc_vertex);
|
| 1721 |
|
|
|
| 1722 |
10 |
| v= result->contour[c].num_vertices - 1;
|
| 1723 |
68 |
▶ | for (vtx= poly->proxy->v[LEFT]; vtx; vtx= nv)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (vtx= poly->proxy->v[LEFT]; vtx; vtx= nv)
|
58 |
10 |
68 |
|
| 1724 |
|
| {
|
| 1725 |
58 |
| nv= vtx->next;
|
| 1726 |
58 |
| result->contour[c].vertex[v].x= vtx->x;
|
| 1727 |
58 |
| result->contour[c].vertex[v].y= vtx->y;
|
| 1728 |
58 |
| FREE(vtx);
|
| 1729 |
58 |
| v--;
|
| 1730 |
|
| }
|
| 1731 |
10 |
| c++;
|
| 1732 |
|
| }
|
| 1733 |
12 |
| FREE(poly);
|
| 1734 |
|
| }
|
| 1735 |
|
| }
|
| 1736 |
|
| else
|
| 1737 |
|
| {
|
| 1738 |
0 |
▶ | for (poly= out_poly; poly; poly= npoly)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (poly= out_poly; poly; poly= npoly)
|
0 |
0 |
0 |
|
| 1739 |
|
| {
|
| 1740 |
0 |
| npoly= poly->next;
|
| 1741 |
0 |
| FREE(poly);
|
| 1742 |
|
| }
|
| 1743 |
|
| }
|
| 1744 |
|
|
|
| 1745 |
|
| /* Tidy up */
|
| 1746 |
4 |
| reset_it(&it);
|
| 1747 |
4 |
| reset_lmt(&lmt);
|
| 1748 |
4 |
| FREE(c_heap);
|
| 1749 |
4 |
| FREE(s_heap);
|
| 1750 |
4 |
| FREE(sbt);
|
| 1751 |
|
| }
|
| 1752 |
|
|
|
| 1753 |
|
|
|
| 1754 |
0 |
| void gpc_free_tristrip(gpc_tristrip *t)
|
| 1755 |
|
| {
|
| 1756 |
|
| int s;
|
| 1757 |
|
|
|
| 1758 |
0 |
▶ | for (s= 0; s < t->num_strips; s++)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (s= 0; s < t->num_strips; s++)
|
0 |
0 |
0 |
|
| 1759 |
0 |
| FREE(t->strip[s].vertex);
|
| 1760 |
0 |
| FREE(t->strip);
|
| 1761 |
0 |
| t->num_strips= 0;
|
| 1762 |
0 |
| }
|
| 1763 |
|
|
|
| 1764 |
|
|
|
| 1765 |
0 |
| void gpc_polygon_to_tristrip(gpc_polygon *s, gpc_tristrip *t)
|
| 1766 |
|
| {
|
| 1767 |
|
| gpc_polygon c;
|
| 1768 |
|
|
|
| 1769 |
0 |
| c.num_contours= 0;
|
| 1770 |
0 |
| c.hole= NULL;
|
| 1771 |
0 |
| c.contour= NULL;
|
| 1772 |
0 |
| gpc_tristrip_clip(GPC_DIFF, s, &c, t);
|
| 1773 |
0 |
| }
|
| 1774 |
|
|
|
| 1775 |
|
|
|
| 1776 |
0 |
| void gpc_tristrip_clip(gpc_op op, gpc_polygon *subj, gpc_polygon *clip,
|
| 1777 |
|
| gpc_tristrip *result)
|
| 1778 |
|
| {
|
| 1779 |
0 |
| sb_tree *sbtree= NULL;
|
| 1780 |
0 |
| it_node *it= NULL, *intersect;
|
| 1781 |
|
| edge_node *edge, *prev_edge, *next_edge, *succ_edge, *e0, *e1;
|
| 1782 |
0 |
| edge_node *aet= NULL, *c_heap= NULL, *s_heap= NULL, *cf;
|
| 1783 |
0 |
| lmt_node *lmt= NULL, *local_min;
|
| 1784 |
0 |
| polygon_node *tlist= NULL, *tn, *tnn, *p, *q;
|
| 1785 |
|
| vertex_node *lt, *ltn, *rt, *rtn;
|
| 1786 |
|
| h_state horiz[2];
|
| 1787 |
|
| vertex_type cft;
|
| 1788 |
0 |
| int in[2], exists[2], parity[2]= {LEFT, LEFT};
|
| 1789 |
0 |
| int s, v, contributing, search, scanbeam= 0, sbt_entries= 0;
|
| 1790 |
|
| int vclass, bl, br, tl, tr;
|
| 1791 |
0 |
| double *sbt= NULL, xb, px, nx, yb, yt, dy, ix, iy;
|
| 1792 |
|
|
|
| 1793 |
|
| /* Test for trivial NULL result cases */
|
| 1794 |
0 |
▶ | if (((subj->num_contours == 0) && (clip->num_contours == 0))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (((subj->num_contours == 0) && (clip->num_contours == 0))
|
0 |
0 |
0 |
| if (((subj->num_contours == 0) && (clip->num_contours == 0))
|
0 |
0 |
0 |
|
| 1795 |
0 |
▶ | || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
Branch: 3 branches
| Branch | True | False | Total |
| || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
0 |
0 |
0 |
| || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
0 |
0 |
0 |
| || ((subj->num_contours == 0) && ((op == GPC_INT) || (op == GPC_DIFF)))
|
0 |
0 |
0 |
|
| 1796 |
0 |
▶ | || ((clip->num_contours == 0) && (op == GPC_INT)))
|
Branch: 2 branches
| Branch | True | False | Total |
| || ((clip->num_contours == 0) && (op == GPC_INT)))
|
0 |
0 |
0 |
| || ((clip->num_contours == 0) && (op == GPC_INT)))
|
0 |
0 |
0 |
|
| 1797 |
|
| {
|
| 1798 |
0 |
| result->num_strips= 0;
|
| 1799 |
0 |
| result->strip= NULL;
|
| 1800 |
0 |
| return;
|
| 1801 |
|
| }
|
| 1802 |
|
|
|
| 1803 |
|
| /* Identify potentialy contributing contours */
|
| 1804 |
0 |
▶ | if (((op == GPC_INT) || (op == GPC_DIFF))
|
Branch: 2 branches
| Branch | True | False | Total |
| if (((op == GPC_INT) || (op == GPC_DIFF))
|
0 |
0 |
0 |
| if (((op == GPC_INT) || (op == GPC_DIFF))
|
0 |
0 |
0 |
|
| 1805 |
0 |
▶ | && (subj->num_contours > 0) && (clip->num_contours > 0))
|
Branch: 2 branches
| Branch | True | False | Total |
| && (subj->num_contours > 0) && (clip->num_contours > 0))
|
0 |
0 |
0 |
| && (subj->num_contours > 0) && (clip->num_contours > 0))
|
0 |
0 |
0 |
|
| 1806 |
0 |
| minimax_test(subj, clip, op);
|
| 1807 |
|
|
|
| 1808 |
|
| /* Build LMT */
|
| 1809 |
0 |
▶ | if (subj->num_contours > 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (subj->num_contours > 0)
|
0 |
0 |
0 |
|
| 1810 |
0 |
| s_heap= build_lmt(&lmt, &sbtree, &sbt_entries, subj, SUBJ, op);
|
| 1811 |
0 |
▶ | if (clip->num_contours > 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (clip->num_contours > 0)
|
0 |
0 |
0 |
|
| 1812 |
0 |
| c_heap= build_lmt(&lmt, &sbtree, &sbt_entries, clip, CLIP, op);
|
| 1813 |
|
|
|
| 1814 |
|
| /* Return a NULL result if no contours contribute */
|
| 1815 |
0 |
▶ | if (lmt == NULL)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (lmt == NULL)
|
0 |
0 |
0 |
|
| 1816 |
|
| {
|
| 1817 |
0 |
| result->num_strips= 0;
|
| 1818 |
0 |
| result->strip= NULL;
|
| 1819 |
0 |
| reset_lmt(&lmt);
|
| 1820 |
0 |
| FREE(s_heap);
|
| 1821 |
0 |
| FREE(c_heap);
|
| 1822 |
0 |
| return;
|
| 1823 |
|
| }
|
| 1824 |
|
|
|
| 1825 |
|
| /* Build scanbeam table from scanbeam tree */
|
| 1826 |
0 |
▶ | MALLOC(sbt, sbt_entries * sizeof(double), "sbt creation", double);
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(sbt, sbt_entries * sizeof(double), "sbt creation", double);
|
0 |
0 |
0 |
| MALLOC(sbt, sbt_entries * sizeof(double), "sbt creation", double);
|
0 |
0 |
0 |
|
| 1827 |
0 |
| build_sbt(&scanbeam, sbt, sbtree);
|
| 1828 |
0 |
| scanbeam= 0;
|
| 1829 |
0 |
| free_sbtree(&sbtree);
|
| 1830 |
|
|
|
| 1831 |
|
| /* Invert clip polygon for difference operation */
|
| 1832 |
0 |
▶ | if (op == GPC_DIFF)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (op == GPC_DIFF)
|
0 |
0 |
0 |
|
| 1833 |
0 |
| parity[CLIP]= RIGHT;
|
| 1834 |
|
|
|
| 1835 |
0 |
| local_min= lmt;
|
| 1836 |
|
|
|
| 1837 |
|
| /* Process each scanbeam */
|
| 1838 |
0 |
▶ | while (scanbeam < sbt_entries)
|
Branch: 1 branch
| Branch | True | False | Total |
| while (scanbeam < sbt_entries)
|
0 |
0 |
0 |
|
| 1839 |
|
| {
|
| 1840 |
|
| /* Set yb and yt to the bottom and top of the scanbeam */
|
| 1841 |
0 |
| yb= sbt[scanbeam++];
|
| 1842 |
0 |
▶ | if (scanbeam < sbt_entries)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (scanbeam < sbt_entries)
|
0 |
0 |
0 |
|
| 1843 |
|
| {
|
| 1844 |
0 |
| yt= sbt[scanbeam];
|
| 1845 |
0 |
| dy= yt - yb;
|
| 1846 |
|
| }
|
| 1847 |
|
|
|
| 1848 |
|
| /* === SCANBEAM BOUNDARY PROCESSING ================================ */
|
| 1849 |
|
|
|
| 1850 |
|
| /* If LMT node corresponding to yb exists */
|
| 1851 |
0 |
▶ | if (local_min)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (local_min)
|
0 |
0 |
0 |
|
| 1852 |
|
| {
|
| 1853 |
0 |
▶ | if (local_min->y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (local_min->y == yb)
|
0 |
0 |
0 |
|
| 1854 |
|
| {
|
| 1855 |
|
| /* Add edges starting at this local minimum to the AET */
|
| 1856 |
0 |
▶ | for (edge= local_min->first_bound; edge; edge= edge->next_bound)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= local_min->first_bound; edge; edge= edge->next_bound)
|
0 |
0 |
0 |
|
| 1857 |
0 |
| add_edge_to_aet(&aet, edge, NULL);
|
| 1858 |
|
|
|
| 1859 |
0 |
| local_min= local_min->next;
|
| 1860 |
|
| }
|
| 1861 |
|
| }
|
| 1862 |
|
|
|
| 1863 |
|
| /* Set dummy previous x value */
|
| 1864 |
0 |
| px= -DBL_MAX;
|
| 1865 |
|
|
|
| 1866 |
|
| /* Create bundles within AET */
|
| 1867 |
0 |
| e0= aet;
|
| 1868 |
0 |
| e1= aet;
|
| 1869 |
|
|
|
| 1870 |
|
| /* Set up bundle fields of first edge */
|
| 1871 |
0 |
| aet->bundle[ABOVE][ aet->type]= (aet->top.y != yb);
|
| 1872 |
0 |
| aet->bundle[ABOVE][!aet->type]= FALSE;
|
| 1873 |
0 |
| aet->bstate[ABOVE]= UNBUNDLED;
|
| 1874 |
|
|
|
| 1875 |
0 |
▶ | for (next_edge= aet->next; next_edge; next_edge= next_edge->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (next_edge= aet->next; next_edge; next_edge= next_edge->next)
|
0 |
0 |
0 |
|
| 1876 |
|
| {
|
| 1877 |
|
| /* Set up bundle fields of next edge */
|
| 1878 |
0 |
| next_edge->bundle[ABOVE][ next_edge->type]= (next_edge->top.y != yb);
|
| 1879 |
0 |
| next_edge->bundle[ABOVE][!next_edge->type]= FALSE;
|
| 1880 |
0 |
| next_edge->bstate[ABOVE]= UNBUNDLED;
|
| 1881 |
|
|
|
| 1882 |
|
| /* Bundle edges above the scanbeam boundary if they coincide */
|
| 1883 |
0 |
▶ | if (next_edge->bundle[ABOVE][next_edge->type])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (next_edge->bundle[ABOVE][next_edge->type])
|
0 |
0 |
0 |
|
| 1884 |
|
| {
|
| 1885 |
0 |
▶ | if (EQ(e0->xb, next_edge->xb) && EQ(e0->dx, next_edge->dx)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (EQ(e0->xb, next_edge->xb) && EQ(e0->dx, next_edge->dx)
|
0 |
0 |
0 |
| if (EQ(e0->xb, next_edge->xb) && EQ(e0->dx, next_edge->dx)
|
0 |
0 |
0 |
|
| 1886 |
0 |
▶ | && (e0->top.y != yb))
|
Branch: 1 branch
| Branch | True | False | Total |
| && (e0->top.y != yb))
|
0 |
0 |
0 |
|
| 1887 |
|
| {
|
| 1888 |
0 |
| next_edge->bundle[ABOVE][ next_edge->type]^=
|
| 1889 |
0 |
| e0->bundle[ABOVE][ next_edge->type];
|
| 1890 |
0 |
| next_edge->bundle[ABOVE][!next_edge->type]=
|
| 1891 |
0 |
| e0->bundle[ABOVE][!next_edge->type];
|
| 1892 |
0 |
| next_edge->bstate[ABOVE]= BUNDLE_HEAD;
|
| 1893 |
0 |
| e0->bundle[ABOVE][CLIP]= FALSE;
|
| 1894 |
0 |
| e0->bundle[ABOVE][SUBJ]= FALSE;
|
| 1895 |
0 |
| e0->bstate[ABOVE]= BUNDLE_TAIL;
|
| 1896 |
|
| }
|
| 1897 |
0 |
| e0= next_edge;
|
| 1898 |
|
| }
|
| 1899 |
|
| }
|
| 1900 |
|
|
|
| 1901 |
0 |
| horiz[CLIP]= NH;
|
| 1902 |
0 |
| horiz[SUBJ]= NH;
|
| 1903 |
|
|
|
| 1904 |
|
| /* Process each edge at this scanbeam boundary */
|
| 1905 |
0 |
▶ | for (edge= aet; edge; edge= edge->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= aet; edge; edge= edge->next)
|
0 |
0 |
0 |
|
| 1906 |
|
| {
|
| 1907 |
0 |
| exists[CLIP]= edge->bundle[ABOVE][CLIP] +
|
| 1908 |
0 |
| (edge->bundle[BELOW][CLIP] << 1);
|
| 1909 |
0 |
| exists[SUBJ]= edge->bundle[ABOVE][SUBJ] +
|
| 1910 |
0 |
| (edge->bundle[BELOW][SUBJ] << 1);
|
| 1911 |
|
|
|
| 1912 |
0 |
▶ | if (exists[CLIP] || exists[SUBJ])
|
Branch: 2 branches
| Branch | True | False | Total |
| if (exists[CLIP] || exists[SUBJ])
|
0 |
0 |
0 |
| if (exists[CLIP] || exists[SUBJ])
|
0 |
0 |
0 |
|
| 1913 |
|
| {
|
| 1914 |
|
| /* Set bundle side */
|
| 1915 |
0 |
| edge->bside[CLIP]= parity[CLIP];
|
| 1916 |
0 |
| edge->bside[SUBJ]= parity[SUBJ];
|
| 1917 |
|
|
|
| 1918 |
|
| /* Determine contributing status and quadrant occupancies */
|
| 1919 |
0 |
| switch (op)
|
| 1920 |
|
| {
|
| 1921 |
0 |
| case GPC_DIFF:
|
| 1922 |
|
| case GPC_INT:
|
| 1923 |
0 |
▶ | contributing= (exists[CLIP] && (parity[SUBJ] || horiz[SUBJ]))
|
Branch: 2 branches
| Branch | True | False | Total |
| contributing= (exists[CLIP] && (parity[SUBJ] || horiz[SUBJ]))
|
0 |
0 |
0 |
| contributing= (exists[CLIP] && (parity[SUBJ] || horiz[SUBJ]))
|
0 |
0 |
0 |
|
| 1924 |
0 |
▶ | || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
0 |
0 |
0 |
| || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
0 |
0 |
0 |
| || (exists[SUBJ] && (parity[CLIP] || horiz[CLIP]))
|
0 |
0 |
0 |
|
| 1925 |
0 |
▶ | || (exists[CLIP] && exists[SUBJ]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
0 |
0 |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
0 |
0 |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
0 |
0 |
|
| 1926 |
0 |
▶ | && (parity[CLIP] == parity[SUBJ]));
|
Branch: 1 branch
| Branch | True | False | Total |
| && (parity[CLIP] == parity[SUBJ]));
|
0 |
0 |
0 |
|
| 1927 |
0 |
| br= (parity[CLIP])
|
| 1928 |
0 |
▶ | && (parity[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ]);
|
0 |
0 |
0 |
| && (parity[SUBJ]);
|
0 |
0 |
0 |
|
| 1929 |
0 |
| bl= (parity[CLIP] ^ edge->bundle[ABOVE][CLIP])
|
| 1930 |
0 |
▶ | && (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| && (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 1931 |
0 |
| tr= (parity[CLIP] ^ (horiz[CLIP]!=NH))
|
| 1932 |
0 |
▶ | && (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
0 |
0 |
0 |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
0 |
0 |
0 |
|
| 1933 |
0 |
| tl= (parity[CLIP] ^ (horiz[CLIP]!=NH) ^ edge->bundle[BELOW][CLIP])
|
| 1934 |
0 |
▶ | && (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
0 |
0 |
0 |
| && (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
0 |
0 |
0 |
|
| 1935 |
0 |
| break;
|
| 1936 |
0 |
| case GPC_XOR:
|
| 1937 |
0 |
▶ | contributing= exists[CLIP] || exists[SUBJ];
|
Branch: 2 branches
| Branch | True | False | Total |
| contributing= exists[CLIP] || exists[SUBJ];
|
0 |
0 |
0 |
| contributing= exists[CLIP] || exists[SUBJ];
|
0 |
0 |
0 |
|
| 1938 |
0 |
| br= (parity[CLIP])
|
| 1939 |
0 |
| ^ (parity[SUBJ]);
|
| 1940 |
0 |
| bl= (parity[CLIP] ^ edge->bundle[ABOVE][CLIP])
|
| 1941 |
0 |
| ^ (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
| 1942 |
0 |
| tr= (parity[CLIP] ^ (horiz[CLIP]!=NH))
|
| 1943 |
0 |
| ^ (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
| 1944 |
0 |
| tl= (parity[CLIP] ^ (horiz[CLIP]!=NH) ^ edge->bundle[BELOW][CLIP])
|
| 1945 |
0 |
| ^ (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
| 1946 |
0 |
| break;
|
| 1947 |
0 |
| case GPC_UNION:
|
| 1948 |
0 |
▶ | contributing= (exists[CLIP] && (!parity[SUBJ] || horiz[SUBJ]))
|
Branch: 2 branches
| Branch | True | False | Total |
| contributing= (exists[CLIP] && (!parity[SUBJ] || horiz[SUBJ]))
|
0 |
0 |
0 |
| contributing= (exists[CLIP] && (!parity[SUBJ] || horiz[SUBJ]))
|
0 |
0 |
0 |
|
| 1949 |
0 |
▶ | || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
0 |
0 |
0 |
| || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
0 |
0 |
0 |
| || (exists[SUBJ] && (!parity[CLIP] || horiz[CLIP]))
|
0 |
0 |
0 |
|
| 1950 |
0 |
▶ | || (exists[CLIP] && exists[SUBJ]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
0 |
0 |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
0 |
0 |
| || (exists[CLIP] && exists[SUBJ]
|
0 |
0 |
0 |
|
| 1951 |
0 |
▶ | && (parity[CLIP] == parity[SUBJ]));
|
Branch: 1 branch
| Branch | True | False | Total |
| && (parity[CLIP] == parity[SUBJ]));
|
0 |
0 |
0 |
|
| 1952 |
0 |
| br= (parity[CLIP])
|
| 1953 |
0 |
▶ | || (parity[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ]);
|
0 |
0 |
0 |
| || (parity[SUBJ]);
|
0 |
0 |
0 |
|
| 1954 |
0 |
| bl= (parity[CLIP] ^ edge->bundle[ABOVE][CLIP])
|
| 1955 |
0 |
▶ | || (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| || (parity[SUBJ] ^ edge->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 1956 |
0 |
| tr= (parity[CLIP] ^ (horiz[CLIP]!=NH))
|
| 1957 |
0 |
▶ | || (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
0 |
0 |
0 |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH));
|
0 |
0 |
0 |
|
| 1958 |
0 |
| tl= (parity[CLIP] ^ (horiz[CLIP]!=NH) ^ edge->bundle[BELOW][CLIP])
|
| 1959 |
0 |
▶ | || (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
0 |
0 |
0 |
| || (parity[SUBJ] ^ (horiz[SUBJ]!=NH) ^ edge->bundle[BELOW][SUBJ]);
|
0 |
0 |
0 |
|
| 1960 |
0 |
| break;
|
| 1961 |
|
| }
|
| 1962 |
|
|
|
| 1963 |
|
| /* Update parity */
|
| 1964 |
0 |
| parity[CLIP]^= edge->bundle[ABOVE][CLIP];
|
| 1965 |
0 |
| parity[SUBJ]^= edge->bundle[ABOVE][SUBJ];
|
| 1966 |
|
|
|
| 1967 |
|
| /* Update horizontal state */
|
| 1968 |
0 |
▶ | if (exists[CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (exists[CLIP])
|
0 |
0 |
0 |
|
| 1969 |
0 |
| horiz[CLIP]=
|
| 1970 |
0 |
| next_h_state[horiz[CLIP]]
|
| 1971 |
0 |
| [((exists[CLIP] - 1) << 1) + parity[CLIP]];
|
| 1972 |
0 |
▶ | if (exists[SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (exists[SUBJ])
|
0 |
0 |
0 |
|
| 1973 |
0 |
| horiz[SUBJ]=
|
| 1974 |
0 |
| next_h_state[horiz[SUBJ]]
|
| 1975 |
0 |
| [((exists[SUBJ] - 1) << 1) + parity[SUBJ]];
|
| 1976 |
|
|
|
| 1977 |
0 |
| vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
|
| 1978 |
|
|
|
| 1979 |
0 |
▶ | if (contributing)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (contributing)
|
0 |
0 |
0 |
|
| 1980 |
|
| {
|
| 1981 |
0 |
| xb= edge->xb;
|
| 1982 |
|
|
|
| 1983 |
0 |
| switch (vclass)
|
| 1984 |
|
| {
|
| 1985 |
0 |
| case EMN:
|
| 1986 |
0 |
| new_tristrip(&tlist, edge, xb, yb);
|
| 1987 |
0 |
| cf= edge;
|
| 1988 |
0 |
| break;
|
| 1989 |
0 |
| case ERI:
|
| 1990 |
0 |
| edge->outp[ABOVE]= cf->outp[ABOVE];
|
| 1991 |
0 |
▶ | if (xb != cf->xb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != cf->xb)
|
0 |
0 |
0 |
|
| 1992 |
0 |
| VERTEX(edge, ABOVE, RIGHT, xb, yb);
|
| 1993 |
0 |
| cf= NULL;
|
| 1994 |
0 |
| break;
|
| 1995 |
0 |
| case ELI:
|
| 1996 |
0 |
| VERTEX(edge, BELOW, LEFT, xb, yb);
|
| 1997 |
0 |
| edge->outp[ABOVE]= NULL;
|
| 1998 |
0 |
| cf= edge;
|
| 1999 |
0 |
| break;
|
| 2000 |
0 |
| case EMX:
|
| 2001 |
0 |
▶ | if (xb != cf->xb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != cf->xb)
|
0 |
0 |
0 |
|
| 2002 |
0 |
| VERTEX(edge, BELOW, RIGHT, xb, yb);
|
| 2003 |
0 |
| edge->outp[ABOVE]= NULL;
|
| 2004 |
0 |
| cf= NULL;
|
| 2005 |
0 |
| break;
|
| 2006 |
0 |
| case IMN:
|
| 2007 |
0 |
▶ | if (cft == LED)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (cft == LED)
|
0 |
0 |
0 |
|
| 2008 |
|
| {
|
| 2009 |
0 |
▶ | if (cf->bot.y != yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (cf->bot.y != yb)
|
0 |
0 |
0 |
|
| 2010 |
0 |
| VERTEX(cf, BELOW, LEFT, cf->xb, yb);
|
| 2011 |
0 |
| new_tristrip(&tlist, cf, cf->xb, yb);
|
| 2012 |
|
| }
|
| 2013 |
0 |
| edge->outp[ABOVE]= cf->outp[ABOVE];
|
| 2014 |
0 |
| VERTEX(edge, ABOVE, RIGHT, xb, yb);
|
| 2015 |
0 |
| break;
|
| 2016 |
0 |
| case ILI:
|
| 2017 |
0 |
| new_tristrip(&tlist, edge, xb, yb);
|
| 2018 |
0 |
| cf= edge;
|
| 2019 |
0 |
| cft= ILI;
|
| 2020 |
0 |
| break;
|
| 2021 |
0 |
| case IRI:
|
| 2022 |
0 |
▶ | if (cft == LED)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (cft == LED)
|
0 |
0 |
0 |
|
| 2023 |
|
| {
|
| 2024 |
0 |
▶ | if (cf->bot.y != yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (cf->bot.y != yb)
|
0 |
0 |
0 |
|
| 2025 |
0 |
| VERTEX(cf, BELOW, LEFT, cf->xb, yb);
|
| 2026 |
0 |
| new_tristrip(&tlist, cf, cf->xb, yb);
|
| 2027 |
|
| }
|
| 2028 |
0 |
| VERTEX(edge, BELOW, RIGHT, xb, yb);
|
| 2029 |
0 |
| edge->outp[ABOVE]= NULL;
|
| 2030 |
0 |
| break;
|
| 2031 |
0 |
| case IMX:
|
| 2032 |
0 |
| VERTEX(edge, BELOW, LEFT, xb, yb);
|
| 2033 |
0 |
| edge->outp[ABOVE]= NULL;
|
| 2034 |
0 |
| cft= IMX;
|
| 2035 |
0 |
| break;
|
| 2036 |
0 |
| case IMM:
|
| 2037 |
0 |
| VERTEX(edge, BELOW, LEFT, xb, yb);
|
| 2038 |
0 |
| edge->outp[ABOVE]= cf->outp[ABOVE];
|
| 2039 |
0 |
▶ | if (xb != cf->xb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (xb != cf->xb)
|
0 |
0 |
0 |
|
| 2040 |
0 |
| VERTEX(cf, ABOVE, RIGHT, xb, yb);
|
| 2041 |
0 |
| cf= edge;
|
| 2042 |
0 |
| break;
|
| 2043 |
0 |
| case EMM:
|
| 2044 |
0 |
| VERTEX(edge, BELOW, RIGHT, xb, yb);
|
| 2045 |
0 |
| edge->outp[ABOVE]= NULL;
|
| 2046 |
0 |
| new_tristrip(&tlist, edge, xb, yb);
|
| 2047 |
0 |
| cf= edge;
|
| 2048 |
0 |
| break;
|
| 2049 |
0 |
| case LED:
|
| 2050 |
0 |
▶ | if (edge->bot.y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->bot.y == yb)
|
0 |
0 |
0 |
|
| 2051 |
0 |
| VERTEX(edge, BELOW, LEFT, xb, yb);
|
| 2052 |
0 |
| edge->outp[ABOVE]= edge->outp[BELOW];
|
| 2053 |
0 |
| cf= edge;
|
| 2054 |
0 |
| cft= LED;
|
| 2055 |
0 |
| break;
|
| 2056 |
0 |
| case RED:
|
| 2057 |
0 |
| edge->outp[ABOVE]= cf->outp[ABOVE];
|
| 2058 |
0 |
▶ | if (cft == LED)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (cft == LED)
|
0 |
0 |
0 |
|
| 2059 |
|
| {
|
| 2060 |
0 |
▶ | if (cf->bot.y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (cf->bot.y == yb)
|
0 |
0 |
0 |
|
| 2061 |
|
| {
|
| 2062 |
0 |
| VERTEX(edge, BELOW, RIGHT, xb, yb);
|
| 2063 |
|
| }
|
| 2064 |
|
| else
|
| 2065 |
|
| {
|
| 2066 |
0 |
▶ | if (edge->bot.y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->bot.y == yb)
|
0 |
0 |
0 |
|
| 2067 |
|
| {
|
| 2068 |
0 |
| VERTEX(cf, BELOW, LEFT, cf->xb, yb);
|
| 2069 |
0 |
| VERTEX(edge, BELOW, RIGHT, xb, yb);
|
| 2070 |
|
| }
|
| 2071 |
|
| }
|
| 2072 |
|
| }
|
| 2073 |
|
| else
|
| 2074 |
|
| {
|
| 2075 |
0 |
| VERTEX(edge, BELOW, RIGHT, xb, yb);
|
| 2076 |
0 |
| VERTEX(edge, ABOVE, RIGHT, xb, yb);
|
| 2077 |
|
| }
|
| 2078 |
0 |
| cf= NULL;
|
| 2079 |
0 |
| break;
|
| 2080 |
0 |
| default:
|
| 2081 |
0 |
| break;
|
| 2082 |
|
| } /* End of switch */
|
| 2083 |
|
| } /* End of contributing conditional */
|
| 2084 |
|
| } /* End of edge exists conditional */
|
| 2085 |
|
| } /* End of AET loop */
|
| 2086 |
|
|
|
| 2087 |
|
| /* Delete terminating edges from the AET, otherwise compute xt */
|
| 2088 |
0 |
▶ | for (edge= aet; edge; edge= edge->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= aet; edge; edge= edge->next)
|
0 |
0 |
0 |
|
| 2089 |
|
| {
|
| 2090 |
0 |
▶ | if (edge->top.y == yb)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->top.y == yb)
|
0 |
0 |
0 |
|
| 2091 |
|
| {
|
| 2092 |
0 |
| prev_edge= edge->prev;
|
| 2093 |
0 |
| next_edge= edge->next;
|
| 2094 |
0 |
▶ | if (prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge)
|
0 |
0 |
0 |
|
| 2095 |
0 |
| prev_edge->next= next_edge;
|
| 2096 |
|
| else
|
| 2097 |
0 |
| aet= next_edge;
|
| 2098 |
0 |
▶ | if (next_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (next_edge)
|
0 |
0 |
0 |
|
| 2099 |
0 |
| next_edge->prev= prev_edge;
|
| 2100 |
|
|
|
| 2101 |
|
| /* Copy bundle head state to the adjacent tail edge if required */
|
| 2102 |
0 |
▶ | if ((edge->bstate[BELOW] == BUNDLE_HEAD) && prev_edge)
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((edge->bstate[BELOW] == BUNDLE_HEAD) && prev_edge)
|
0 |
0 |
0 |
| if ((edge->bstate[BELOW] == BUNDLE_HEAD) && prev_edge)
|
0 |
0 |
0 |
|
| 2103 |
|
| {
|
| 2104 |
0 |
▶ | if (prev_edge->bstate[BELOW] == BUNDLE_TAIL)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->bstate[BELOW] == BUNDLE_TAIL)
|
0 |
0 |
0 |
|
| 2105 |
|
| {
|
| 2106 |
0 |
| prev_edge->outp[BELOW]= edge->outp[BELOW];
|
| 2107 |
0 |
| prev_edge->bstate[BELOW]= UNBUNDLED;
|
| 2108 |
0 |
▶ | if (prev_edge->prev)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->prev)
|
0 |
0 |
0 |
|
| 2109 |
0 |
▶ | if (prev_edge->prev->bstate[BELOW] == BUNDLE_TAIL)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->prev->bstate[BELOW] == BUNDLE_TAIL)
|
0 |
0 |
0 |
|
| 2110 |
0 |
| prev_edge->bstate[BELOW]= BUNDLE_HEAD;
|
| 2111 |
|
| }
|
| 2112 |
|
| }
|
| 2113 |
|
| }
|
| 2114 |
|
| else
|
| 2115 |
|
| {
|
| 2116 |
0 |
▶ | if (edge->top.y == yt)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (edge->top.y == yt)
|
0 |
0 |
0 |
|
| 2117 |
0 |
| edge->xt= edge->top.x;
|
| 2118 |
|
| else
|
| 2119 |
0 |
| edge->xt= edge->bot.x + edge->dx * (yt - edge->bot.y);
|
| 2120 |
|
| }
|
| 2121 |
|
| }
|
| 2122 |
|
|
|
| 2123 |
0 |
▶ | if (scanbeam < sbt_entries)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (scanbeam < sbt_entries)
|
0 |
0 |
0 |
|
| 2124 |
|
| {
|
| 2125 |
|
| /* === SCANBEAM INTERIOR PROCESSING ============================== */
|
| 2126 |
|
|
|
| 2127 |
0 |
| build_intersection_table(&it, aet, dy);
|
| 2128 |
|
|
|
| 2129 |
|
| /* Process each node in the intersection table */
|
| 2130 |
0 |
▶ | for (intersect= it; intersect; intersect= intersect->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (intersect= it; intersect; intersect= intersect->next)
|
0 |
0 |
0 |
|
| 2131 |
|
| {
|
| 2132 |
0 |
| e0= intersect->ie[0];
|
| 2133 |
0 |
| e1= intersect->ie[1];
|
| 2134 |
|
|
|
| 2135 |
|
| /* Only generate output for contributing intersections */
|
| 2136 |
0 |
▶ | if ((e0->bundle[ABOVE][CLIP] || e0->bundle[ABOVE][SUBJ])
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((e0->bundle[ABOVE][CLIP] || e0->bundle[ABOVE][SUBJ])
|
0 |
0 |
0 |
| if ((e0->bundle[ABOVE][CLIP] || e0->bundle[ABOVE][SUBJ])
|
0 |
0 |
0 |
|
| 2137 |
0 |
▶ | && (e1->bundle[ABOVE][CLIP] || e1->bundle[ABOVE][SUBJ]))
|
Branch: 2 branches
| Branch | True | False | Total |
| && (e1->bundle[ABOVE][CLIP] || e1->bundle[ABOVE][SUBJ]))
|
0 |
0 |
0 |
| && (e1->bundle[ABOVE][CLIP] || e1->bundle[ABOVE][SUBJ]))
|
0 |
0 |
0 |
|
| 2138 |
|
| {
|
| 2139 |
0 |
| p= e0->outp[ABOVE];
|
| 2140 |
0 |
| q= e1->outp[ABOVE];
|
| 2141 |
0 |
| ix= intersect->point.x;
|
| 2142 |
0 |
| iy= intersect->point.y + yb;
|
| 2143 |
|
|
|
| 2144 |
0 |
▶ | in[CLIP]= ( e0->bundle[ABOVE][CLIP] && !e0->bside[CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| in[CLIP]= ( e0->bundle[ABOVE][CLIP] && !e0->bside[CLIP])
|
0 |
0 |
0 |
|
| 2145 |
0 |
▶ | || ( e1->bundle[ABOVE][CLIP] && e1->bside[CLIP])
|
Branch: 2 branches
| Branch | True | False | Total |
| || ( e1->bundle[ABOVE][CLIP] && e1->bside[CLIP])
|
0 |
0 |
0 |
| || ( e1->bundle[ABOVE][CLIP] && e1->bside[CLIP])
|
0 |
0 |
0 |
|
| 2146 |
0 |
▶ | || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
0 |
0 |
0 |
| || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
0 |
0 |
0 |
| || (!e0->bundle[ABOVE][CLIP] && !e1->bundle[ABOVE][CLIP]
|
0 |
0 |
0 |
|
| 2147 |
0 |
▶ | && e0->bside[CLIP] && e1->bside[CLIP]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && e0->bside[CLIP] && e1->bside[CLIP]);
|
0 |
0 |
0 |
| && e0->bside[CLIP] && e1->bside[CLIP]);
|
0 |
0 |
0 |
|
| 2148 |
0 |
▶ | in[SUBJ]= ( e0->bundle[ABOVE][SUBJ] && !e0->bside[SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| in[SUBJ]= ( e0->bundle[ABOVE][SUBJ] && !e0->bside[SUBJ])
|
0 |
0 |
0 |
|
| 2149 |
0 |
▶ | || ( e1->bundle[ABOVE][SUBJ] && e1->bside[SUBJ])
|
Branch: 2 branches
| Branch | True | False | Total |
| || ( e1->bundle[ABOVE][SUBJ] && e1->bside[SUBJ])
|
0 |
0 |
0 |
| || ( e1->bundle[ABOVE][SUBJ] && e1->bside[SUBJ])
|
0 |
0 |
0 |
|
| 2150 |
0 |
▶ | || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
Branch: 3 branches
| Branch | True | False | Total |
| || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
0 |
0 |
0 |
| || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
0 |
0 |
0 |
| || (!e0->bundle[ABOVE][SUBJ] && !e1->bundle[ABOVE][SUBJ]
|
0 |
0 |
0 |
|
| 2151 |
0 |
▶ | && e0->bside[SUBJ] && e1->bside[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && e0->bside[SUBJ] && e1->bside[SUBJ]);
|
0 |
0 |
0 |
| && e0->bside[SUBJ] && e1->bside[SUBJ]);
|
0 |
0 |
0 |
|
| 2152 |
|
|
|
| 2153 |
|
| /* Determine quadrant occupancies */
|
| 2154 |
0 |
| switch (op)
|
| 2155 |
|
| {
|
| 2156 |
0 |
| case GPC_DIFF:
|
| 2157 |
|
| case GPC_INT:
|
| 2158 |
0 |
| tr= (in[CLIP])
|
| 2159 |
0 |
▶ | && (in[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ]);
|
0 |
0 |
0 |
| && (in[SUBJ]);
|
0 |
0 |
0 |
|
| 2160 |
0 |
| tl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP])
|
| 2161 |
0 |
▶ | && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 2162 |
0 |
| br= (in[CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 2163 |
0 |
▶ | && (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| && (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 2164 |
0 |
| bl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 2165 |
0 |
▶ | && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| && (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 2166 |
0 |
| break;
|
| 2167 |
0 |
| case GPC_XOR:
|
| 2168 |
0 |
| tr= (in[CLIP])
|
| 2169 |
0 |
| ^ (in[SUBJ]);
|
| 2170 |
0 |
| tl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP])
|
| 2171 |
0 |
| ^ (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
| 2172 |
0 |
| br= (in[CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 2173 |
0 |
| ^ (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
| 2174 |
0 |
| bl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 2175 |
0 |
| ^ (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
| 2176 |
0 |
| break;
|
| 2177 |
0 |
| case GPC_UNION:
|
| 2178 |
0 |
| tr= (in[CLIP])
|
| 2179 |
0 |
▶ | || (in[SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ]);
|
0 |
0 |
0 |
| || (in[SUBJ]);
|
0 |
0 |
0 |
|
| 2180 |
0 |
| tl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP])
|
| 2181 |
0 |
▶ | || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 2182 |
0 |
| br= (in[CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 2183 |
0 |
▶ | || (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| || (in[SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 2184 |
0 |
| bl= (in[CLIP] ^ e1->bundle[ABOVE][CLIP] ^ e0->bundle[ABOVE][CLIP])
|
| 2185 |
0 |
▶ | || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
Branch: 2 branches
| Branch | True | False | Total |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
| || (in[SUBJ] ^ e1->bundle[ABOVE][SUBJ] ^ e0->bundle[ABOVE][SUBJ]);
|
0 |
0 |
0 |
|
| 2186 |
0 |
| break;
|
| 2187 |
|
| }
|
| 2188 |
|
|
|
| 2189 |
0 |
| vclass= tr + (tl << 1) + (br << 2) + (bl << 3);
|
| 2190 |
|
|
|
| 2191 |
0 |
| switch (vclass)
|
| 2192 |
|
| {
|
| 2193 |
0 |
| case EMN:
|
| 2194 |
0 |
| new_tristrip(&tlist, e1, ix, iy);
|
| 2195 |
0 |
| e0->outp[ABOVE]= e1->outp[ABOVE];
|
| 2196 |
0 |
| break;
|
| 2197 |
0 |
| case ERI:
|
| 2198 |
0 |
▶ | if (p)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p)
|
0 |
0 |
0 |
|
| 2199 |
|
| {
|
| 2200 |
0 |
▶ | P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
0 |
0 |
0 |
|
| 2201 |
0 |
| VERTEX(prev_edge, ABOVE, LEFT, px, iy);
|
| 2202 |
0 |
| VERTEX(e0, ABOVE, RIGHT, ix, iy);
|
| 2203 |
0 |
| e1->outp[ABOVE]= e0->outp[ABOVE];
|
| 2204 |
0 |
| e0->outp[ABOVE]= NULL;
|
| 2205 |
|
| }
|
| 2206 |
0 |
| break;
|
| 2207 |
0 |
| case ELI:
|
| 2208 |
0 |
▶ | if (q)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (q)
|
0 |
0 |
0 |
|
| 2209 |
|
| {
|
| 2210 |
0 |
▶ | N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
0 |
0 |
0 |
|
| 2211 |
0 |
| VERTEX(e1, ABOVE, LEFT, ix, iy);
|
| 2212 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2213 |
0 |
| e0->outp[ABOVE]= e1->outp[ABOVE];
|
| 2214 |
0 |
| e1->outp[ABOVE]= NULL;
|
| 2215 |
|
| }
|
| 2216 |
0 |
| break;
|
| 2217 |
0 |
| case EMX:
|
| 2218 |
0 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
0 |
0 |
0 |
| if (p && q)
|
0 |
0 |
0 |
|
| 2219 |
|
| {
|
| 2220 |
0 |
| VERTEX(e0, ABOVE, LEFT, ix, iy);
|
| 2221 |
0 |
| e0->outp[ABOVE]= NULL;
|
| 2222 |
0 |
| e1->outp[ABOVE]= NULL;
|
| 2223 |
|
| }
|
| 2224 |
0 |
| break;
|
| 2225 |
0 |
| case IMN:
|
| 2226 |
0 |
▶ | P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
0 |
0 |
0 |
|
| 2227 |
0 |
| VERTEX(prev_edge, ABOVE, LEFT, px, iy);
|
| 2228 |
0 |
▶ | N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
0 |
0 |
0 |
|
| 2229 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2230 |
0 |
| new_tristrip(&tlist, prev_edge, px, iy);
|
| 2231 |
0 |
| e1->outp[ABOVE]= prev_edge->outp[ABOVE];
|
| 2232 |
0 |
| VERTEX(e1, ABOVE, RIGHT, ix, iy);
|
| 2233 |
0 |
| new_tristrip(&tlist, e0, ix, iy);
|
| 2234 |
0 |
| next_edge->outp[ABOVE]= e0->outp[ABOVE];
|
| 2235 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2236 |
0 |
| break;
|
| 2237 |
0 |
| case ILI:
|
| 2238 |
0 |
▶ | if (p)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (p)
|
0 |
0 |
0 |
|
| 2239 |
|
| {
|
| 2240 |
0 |
| VERTEX(e0, ABOVE, LEFT, ix, iy);
|
| 2241 |
0 |
▶ | N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
0 |
0 |
0 |
|
| 2242 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2243 |
0 |
| e1->outp[ABOVE]= e0->outp[ABOVE];
|
| 2244 |
0 |
| e0->outp[ABOVE]= NULL;
|
| 2245 |
|
| }
|
| 2246 |
0 |
| break;
|
| 2247 |
0 |
| case IRI:
|
| 2248 |
0 |
▶ | if (q)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (q)
|
0 |
0 |
0 |
|
| 2249 |
|
| {
|
| 2250 |
0 |
| VERTEX(e1, ABOVE, RIGHT, ix, iy);
|
| 2251 |
0 |
▶ | P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
0 |
0 |
0 |
|
| 2252 |
0 |
| VERTEX(prev_edge, ABOVE, LEFT, px, iy);
|
| 2253 |
0 |
| e0->outp[ABOVE]= e1->outp[ABOVE];
|
| 2254 |
0 |
| e1->outp[ABOVE]= NULL;
|
| 2255 |
|
| }
|
| 2256 |
0 |
| break;
|
| 2257 |
0 |
| case IMX:
|
| 2258 |
0 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
0 |
0 |
0 |
| if (p && q)
|
0 |
0 |
0 |
|
| 2259 |
|
| {
|
| 2260 |
0 |
| VERTEX(e0, ABOVE, RIGHT, ix, iy);
|
| 2261 |
0 |
| VERTEX(e1, ABOVE, LEFT, ix, iy);
|
| 2262 |
0 |
| e0->outp[ABOVE]= NULL;
|
| 2263 |
0 |
| e1->outp[ABOVE]= NULL;
|
| 2264 |
0 |
▶ | P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
0 |
0 |
0 |
|
| 2265 |
0 |
| VERTEX(prev_edge, ABOVE, LEFT, px, iy);
|
| 2266 |
0 |
| new_tristrip(&tlist, prev_edge, px, iy);
|
| 2267 |
0 |
▶ | N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
0 |
0 |
0 |
|
| 2268 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2269 |
0 |
| next_edge->outp[ABOVE]= prev_edge->outp[ABOVE];
|
| 2270 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2271 |
|
| }
|
| 2272 |
0 |
| break;
|
| 2273 |
0 |
| case IMM:
|
| 2274 |
0 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
0 |
0 |
0 |
| if (p && q)
|
0 |
0 |
0 |
|
| 2275 |
|
| {
|
| 2276 |
0 |
| VERTEX(e0, ABOVE, RIGHT, ix, iy);
|
| 2277 |
0 |
| VERTEX(e1, ABOVE, LEFT, ix, iy);
|
| 2278 |
0 |
▶ | P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| P_EDGE(prev_edge, e0, ABOVE, px, iy);
|
0 |
0 |
0 |
|
| 2279 |
0 |
| VERTEX(prev_edge, ABOVE, LEFT, px, iy);
|
| 2280 |
0 |
| new_tristrip(&tlist, prev_edge, px, iy);
|
| 2281 |
0 |
▶ | N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
Branch: 1 branch
| Branch | True | False | Total |
| N_EDGE(next_edge, e1, ABOVE, nx, iy);
|
0 |
0 |
0 |
|
| 2282 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2283 |
0 |
| e1->outp[ABOVE]= prev_edge->outp[ABOVE];
|
| 2284 |
0 |
| VERTEX(e1, ABOVE, RIGHT, ix, iy);
|
| 2285 |
0 |
| new_tristrip(&tlist, e0, ix, iy);
|
| 2286 |
0 |
| next_edge->outp[ABOVE]= e0->outp[ABOVE];
|
| 2287 |
0 |
| VERTEX(next_edge, ABOVE, RIGHT, nx, iy);
|
| 2288 |
|
| }
|
| 2289 |
0 |
| break;
|
| 2290 |
0 |
| case EMM:
|
| 2291 |
0 |
▶ | if (p && q)
|
Branch: 2 branches
| Branch | True | False | Total |
| if (p && q)
|
0 |
0 |
0 |
| if (p && q)
|
0 |
0 |
0 |
|
| 2292 |
|
| {
|
| 2293 |
0 |
| VERTEX(e0, ABOVE, LEFT, ix, iy);
|
| 2294 |
0 |
| new_tristrip(&tlist, e1, ix, iy);
|
| 2295 |
0 |
| e0->outp[ABOVE]= e1->outp[ABOVE];
|
| 2296 |
|
| }
|
| 2297 |
0 |
| break;
|
| 2298 |
0 |
| default:
|
| 2299 |
0 |
| break;
|
| 2300 |
|
| } /* End of switch */
|
| 2301 |
|
| } /* End of contributing intersection conditional */
|
| 2302 |
|
|
|
| 2303 |
|
| /* Swap bundle sides in response to edge crossing */
|
| 2304 |
0 |
▶ | if (e0->bundle[ABOVE][CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e0->bundle[ABOVE][CLIP])
|
0 |
0 |
0 |
|
| 2305 |
0 |
| e1->bside[CLIP]= !e1->bside[CLIP];
|
| 2306 |
0 |
▶ | if (e1->bundle[ABOVE][CLIP])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e1->bundle[ABOVE][CLIP])
|
0 |
0 |
0 |
|
| 2307 |
0 |
| e0->bside[CLIP]= !e0->bside[CLIP];
|
| 2308 |
0 |
▶ | if (e0->bundle[ABOVE][SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e0->bundle[ABOVE][SUBJ])
|
0 |
0 |
0 |
|
| 2309 |
0 |
| e1->bside[SUBJ]= !e1->bside[SUBJ];
|
| 2310 |
0 |
▶ | if (e1->bundle[ABOVE][SUBJ])
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e1->bundle[ABOVE][SUBJ])
|
0 |
0 |
0 |
|
| 2311 |
0 |
| e0->bside[SUBJ]= !e0->bside[SUBJ];
|
| 2312 |
|
|
|
| 2313 |
|
| /* Swap e0 and e1 bundles in the AET */
|
| 2314 |
0 |
| prev_edge= e0->prev;
|
| 2315 |
0 |
| next_edge= e1->next;
|
| 2316 |
0 |
▶ | if (e1->next)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e1->next)
|
0 |
0 |
0 |
|
| 2317 |
0 |
| e1->next->prev= e0;
|
| 2318 |
|
|
|
| 2319 |
0 |
▶ | if (e0->bstate[ABOVE] == BUNDLE_HEAD)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (e0->bstate[ABOVE] == BUNDLE_HEAD)
|
0 |
0 |
0 |
|
| 2320 |
|
| {
|
| 2321 |
0 |
| search= TRUE;
|
| 2322 |
0 |
▶ | while (search)
|
Branch: 1 branch
| Branch | True | False | Total |
| while (search)
|
0 |
0 |
0 |
|
| 2323 |
|
| {
|
| 2324 |
0 |
| prev_edge= prev_edge->prev;
|
| 2325 |
0 |
▶ | if (prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge)
|
0 |
0 |
0 |
|
| 2326 |
|
| {
|
| 2327 |
0 |
▶ | if (prev_edge->bundle[ABOVE][CLIP]
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge->bundle[ABOVE][CLIP]
|
0 |
0 |
0 |
|
| 2328 |
0 |
▶ | || prev_edge->bundle[ABOVE][SUBJ]
|
Branch: 1 branch
| Branch | True | False | Total |
| || prev_edge->bundle[ABOVE][SUBJ]
|
0 |
0 |
0 |
|
| 2329 |
0 |
▶ | || (prev_edge->bstate[ABOVE] == BUNDLE_HEAD))
|
Branch: 1 branch
| Branch | True | False | Total |
| || (prev_edge->bstate[ABOVE] == BUNDLE_HEAD))
|
0 |
0 |
0 |
|
| 2330 |
0 |
| search= FALSE;
|
| 2331 |
|
| }
|
| 2332 |
|
| else
|
| 2333 |
0 |
| search= FALSE;
|
| 2334 |
|
| }
|
| 2335 |
|
| }
|
| 2336 |
0 |
▶ | if (!prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (!prev_edge)
|
0 |
0 |
0 |
|
| 2337 |
|
| {
|
| 2338 |
0 |
| e1->next= aet;
|
| 2339 |
0 |
| aet= e0->next;
|
| 2340 |
|
| }
|
| 2341 |
|
| else
|
| 2342 |
|
| {
|
| 2343 |
0 |
| e1->next= prev_edge->next;
|
| 2344 |
0 |
| prev_edge->next= e0->next;
|
| 2345 |
|
| }
|
| 2346 |
0 |
| e0->next->prev= prev_edge;
|
| 2347 |
0 |
| e1->next->prev= e1;
|
| 2348 |
0 |
| e0->next= next_edge;
|
| 2349 |
|
| } /* End of IT loop*/
|
| 2350 |
|
|
|
| 2351 |
|
| /* Prepare for next scanbeam */
|
| 2352 |
0 |
▶ | for (edge= aet; edge; edge= next_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (edge= aet; edge; edge= next_edge)
|
0 |
0 |
0 |
|
| 2353 |
|
| {
|
| 2354 |
0 |
| next_edge= edge->next;
|
| 2355 |
0 |
| succ_edge= edge->succ;
|
| 2356 |
|
|
|
| 2357 |
0 |
▶ | if ((edge->top.y == yt) && succ_edge)
|
Branch: 2 branches
| Branch | True | False | Total |
| if ((edge->top.y == yt) && succ_edge)
|
0 |
0 |
0 |
| if ((edge->top.y == yt) && succ_edge)
|
0 |
0 |
0 |
|
| 2358 |
|
| {
|
| 2359 |
|
| /* Replace AET edge by its successor */
|
| 2360 |
0 |
| succ_edge->outp[BELOW]= edge->outp[ABOVE];
|
| 2361 |
0 |
| succ_edge->bstate[BELOW]= edge->bstate[ABOVE];
|
| 2362 |
0 |
| succ_edge->bundle[BELOW][CLIP]= edge->bundle[ABOVE][CLIP];
|
| 2363 |
0 |
| succ_edge->bundle[BELOW][SUBJ]= edge->bundle[ABOVE][SUBJ];
|
| 2364 |
0 |
| prev_edge= edge->prev;
|
| 2365 |
0 |
▶ | if (prev_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (prev_edge)
|
0 |
0 |
0 |
|
| 2366 |
0 |
| prev_edge->next= succ_edge;
|
| 2367 |
|
| else
|
| 2368 |
0 |
| aet= succ_edge;
|
| 2369 |
0 |
▶ | if (next_edge)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (next_edge)
|
0 |
0 |
0 |
|
| 2370 |
0 |
| next_edge->prev= succ_edge;
|
| 2371 |
0 |
| succ_edge->prev= prev_edge;
|
| 2372 |
0 |
| succ_edge->next= next_edge;
|
| 2373 |
|
| }
|
| 2374 |
|
| else
|
| 2375 |
|
| {
|
| 2376 |
|
| /* Update this edge */
|
| 2377 |
0 |
| edge->outp[BELOW]= edge->outp[ABOVE];
|
| 2378 |
0 |
| edge->bstate[BELOW]= edge->bstate[ABOVE];
|
| 2379 |
0 |
| edge->bundle[BELOW][CLIP]= edge->bundle[ABOVE][CLIP];
|
| 2380 |
0 |
| edge->bundle[BELOW][SUBJ]= edge->bundle[ABOVE][SUBJ];
|
| 2381 |
0 |
| edge->xb= edge->xt;
|
| 2382 |
|
| }
|
| 2383 |
0 |
| edge->outp[ABOVE]= NULL;
|
| 2384 |
|
| }
|
| 2385 |
|
| }
|
| 2386 |
|
| } /* === END OF SCANBEAM PROCESSING ================================== */
|
| 2387 |
|
|
|
| 2388 |
|
| /* Generate result tristrip from tlist */
|
| 2389 |
0 |
| result->strip= NULL;
|
| 2390 |
0 |
| result->num_strips= count_tristrips(tlist);
|
| 2391 |
0 |
▶ | if (result->num_strips > 0)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (result->num_strips > 0)
|
0 |
0 |
0 |
|
| 2392 |
|
| {
|
| 2393 |
0 |
▶ | MALLOC(result->strip, result->num_strips * sizeof(gpc_vertex_list),
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(result->strip, result->num_strips * sizeof(gpc_vertex_list),
|
0 |
0 |
0 |
| MALLOC(result->strip, result->num_strips * sizeof(gpc_vertex_list),
|
0 |
0 |
0 |
|
| 2394 |
|
| "tristrip list creation", gpc_vertex_list);
|
| 2395 |
|
|
|
| 2396 |
0 |
| s= 0;
|
| 2397 |
0 |
▶ | for (tn= tlist; tn; tn= tnn)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (tn= tlist; tn; tn= tnn)
|
0 |
0 |
0 |
|
| 2398 |
|
| {
|
| 2399 |
0 |
| tnn= tn->next;
|
| 2400 |
|
|
|
| 2401 |
0 |
▶ | if (tn->active > 2)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (tn->active > 2)
|
0 |
0 |
0 |
|
| 2402 |
|
| {
|
| 2403 |
|
| /* Valid tristrip: copy the vertices and free the heap */
|
| 2404 |
0 |
| result->strip[s].num_vertices= tn->active;
|
| 2405 |
0 |
▶ | MALLOC(result->strip[s].vertex, tn->active * sizeof(gpc_vertex),
|
Branch: 2 branches
| Branch | True | False | Total |
| MALLOC(result->strip[s].vertex, tn->active * sizeof(gpc_vertex),
|
0 |
0 |
0 |
| MALLOC(result->strip[s].vertex, tn->active * sizeof(gpc_vertex),
|
0 |
0 |
0 |
|
| 2406 |
|
| "tristrip creation", gpc_vertex);
|
| 2407 |
0 |
| v= 0;
|
| 2408 |
|
| if (INVERT_TRISTRIPS)
|
| 2409 |
|
| {
|
| 2410 |
|
| lt= tn->v[RIGHT];
|
| 2411 |
|
| rt= tn->v[LEFT];
|
| 2412 |
|
| }
|
| 2413 |
|
| else
|
| 2414 |
|
| {
|
| 2415 |
0 |
| lt= tn->v[LEFT];
|
| 2416 |
0 |
| rt= tn->v[RIGHT];
|
| 2417 |
|
| }
|
| 2418 |
0 |
▶ | while (lt || rt)
|
Branch: 2 branches
| Branch | True | False | Total |
| while (lt || rt)
|
0 |
0 |
0 |
| while (lt || rt)
|
0 |
0 |
0 |
|
| 2419 |
|
| {
|
| 2420 |
0 |
▶ | if (lt)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (lt)
|
0 |
0 |
0 |
|
| 2421 |
|
| {
|
| 2422 |
0 |
| ltn= lt->next;
|
| 2423 |
0 |
| result->strip[s].vertex[v].x= lt->x;
|
| 2424 |
0 |
| result->strip[s].vertex[v].y= lt->y;
|
| 2425 |
0 |
| v++;
|
| 2426 |
0 |
| FREE(lt);
|
| 2427 |
0 |
| lt= ltn;
|
| 2428 |
|
| }
|
| 2429 |
0 |
▶ | if (rt)
|
Branch: 1 branch
| Branch | True | False | Total |
| if (rt)
|
0 |
0 |
0 |
|
| 2430 |
|
| {
|
| 2431 |
0 |
| rtn= rt->next;
|
| 2432 |
0 |
| result->strip[s].vertex[v].x= rt->x;
|
| 2433 |
0 |
| result->strip[s].vertex[v].y= rt->y;
|
| 2434 |
0 |
| v++;
|
| 2435 |
0 |
| FREE(rt);
|
| 2436 |
0 |
| rt= rtn;
|
| 2437 |
|
| }
|
| 2438 |
|
| }
|
| 2439 |
0 |
| s++;
|
| 2440 |
|
| }
|
| 2441 |
|
| else
|
| 2442 |
|
| {
|
| 2443 |
|
| /* Invalid tristrip: just free the heap */
|
| 2444 |
0 |
▶ | for (lt= tn->v[LEFT]; lt; lt= ltn)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (lt= tn->v[LEFT]; lt; lt= ltn)
|
0 |
0 |
0 |
|
| 2445 |
|
| {
|
| 2446 |
0 |
| ltn= lt->next;
|
| 2447 |
0 |
| FREE(lt);
|
| 2448 |
|
| }
|
| 2449 |
0 |
▶ | for (rt= tn->v[RIGHT]; rt; rt=rtn)
|
Branch: 1 branch
| Branch | True | False | Total |
| for (rt= tn->v[RIGHT]; rt; rt=rtn)
|
0 |
0 |
0 |
|
| 2450 |
|
| {
|
| 2451 |
0 |
| rtn= rt->next;
|
| 2452 |
0 |
| FREE(rt);
|
| 2453 |
|
| }
|
| 2454 |
|
| }
|
| 2455 |
0 |
| FREE(tn);
|
| 2456 |
|
| }
|
| 2457 |
|
| }
|
| 2458 |
|
|
|
| 2459 |
|
| /* Tidy up */
|
| 2460 |
0 |
| reset_it(&it);
|
| 2461 |
0 |
| reset_lmt(&lmt);
|
| 2462 |
0 |
| FREE(c_heap);
|
| 2463 |
0 |
| FREE(s_heap);
|
| 2464 |
0 |
| FREE(sbt);
|
| 2465 |
|
| }
|
| 2466 |
|
|
|
| 2467 |
|
| /*
|
| 2468 |
|
| ===========================================================================
|
| 2469 |
|
| End of file: gpc.c
|
| 2470 |
|
| ===========================================================================
|
| 2471 |
|
| */
|