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];
49#define EQ_PT(v,w) (((v).x == (w).x) && ((v).y == (w).y))
52 struct position vft, vsd, avft, avsd;
53 for (
int i = 0; i < input.
ninters; i++) {
55 avft =
after(ilist[i].firstv)->pos;
57 avsd =
after(ilist[i].secondv)->pos;
58 if ((vft.
x != avft.
x && vsd.
x != avsd.
x) ||
59 (vft.
x == avft.
x && !
EQ_PT(vft, ilist[i]) && !
EQ_PT(avft, ilist[i])) ||
60 (vsd.
x == avsd.
x && !
EQ_PT(vsd, ilist[i]) && !
EQ_PT(avsd, ilist[i]))) {
62 fprintf(stderr,
"\nintersection %d at %.3f %.3f\n",
63 i, ilist[i].
x, ilist[i].
y);
64 fprintf(stderr,
"seg#1 : (%.3f, %.3f) (%.3f, %.3f)\n",
65 ilist[i].firstv->pos.
x
67 ,
after(ilist[i].firstv)->pos.x
68 ,
after(ilist[i].firstv)->pos.y);
69 fprintf(stderr,
"seg#2 : (%.3f, %.3f) (%.3f, %.3f)\n",
70 ilist[i].secondv->pos.
x
72 ,
after(ilist[i].secondv)->pos.x
73 ,
after(ilist[i].secondv)->pos.y);