23 intersections_t ilist = {0};
28 for (
size_t i = 0; i < n_polys; i++)
29 nverts += polys[i]->pn;
33 for (
size_t i = 0, vno = 0; i < n_polys; i++) {
34 polygon_list[i].
start = &vertex_list[vno];
35 for (
size_t j = 0; j < polys[i]->
pn; j++) {
36 vertex_list[vno].
pos.
x = polys[i]->
ps[j].
x;
37 vertex_list[vno].
pos.
y = polys[i]->
ps[j].
y;
38 vertex_list[vno].
poly = &polygon_list[i];
41 polygon_list[i].
finish = &vertex_list[vno - 1];
46#define EQ_PT(v,w) (((v).x == (w).x) && ((v).y == (w).y))
49 struct position vft, vsd, avft, avsd;
50 for (
size_t i = 0; i <
LIST_SIZE(&ilist); i++) {
56 if ((vft.
x != avft.
x && vsd.
x != avsd.
x) ||
57 (vft.
x == avft.
x && !
EQ_PT(vft, inter) && !
EQ_PT(avft, inter)) ||
58 (vsd.
x == avsd.
x && !
EQ_PT(vsd, inter) && !
EQ_PT(avsd, inter))) {
60 fprintf(stderr,
"\nintersection %" PRISIZE_T " at %.3f %.3f\n",
62 fprintf(stderr,
"seg#1 : (%.3f, %.3f) (%.3f, %.3f)\n",
67 fprintf(stderr,
"seg#2 : (%.3f, %.3f) (%.3f, %.3f)\n",
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static int find_ints(vertex vertex_list[], size_t nvertices)
type-generic dynamically expanding list
#define LIST_GET(list, index)
int Plegal_arrangement(Ppoly_t **polys, size_t n_polys)