DICT_ITERATE_ITEMS(d2, point_t*, p2, void*, c2) {
int count = (ptroff_t)c2;
if(count!=0) {
- if(count>0) fprintf(stderr, "Error: Point (%d,%d) has %d more incoming than outgoing segments\n", p2->x, p2->y, count);
- if(count<0) fprintf(stderr, "Error: Point (%d,%d) has %d more outgoing than incoming segments\n", p2->x, p2->y, -count);
+ if(count>0) fprintf(stderr, "Error: Point (%.2f,%.2f) has %d more incoming than outgoing segments\n", p2->x * poly->gridsize, p2->y * poly->gridsize, count);
+ if(count<0) fprintf(stderr, "Error: Point (%.2f,%.2f) has %d more outgoing than incoming segments\n", p2->x * poly->gridsize, p2->y * poly->gridsize, -count);
dict_destroy(d2);
return 0;
}
static void segment_init(segment_t*s, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int polygon_nr, segment_dir_t dir)
{
+ static int segment_count=0;
+ s->nr = segment_count++;
s->dir = dir;
if(y1!=y2) {
assert(y1<y2);
"up/down" for horizontal segments is handled by "rotating"
them 90° counterclockwise in screen coordinates (tilt your head to
the right). In other words, the "normal" direction (what's positive dy for
- vertical segments) is positive dx for horizontal segments.
+ vertical segments) is positive dx for horizontal segments ("down" is right).
*/
if(x1>x2) {
s->dir = DIR_INVERT(s->dir);
int32_t x = x1;x1=x2;x2=x;
int32_t y = y1;y1=y2;y2=y;
}
+ fprintf(stderr, "Scheduling horizontal segment [%d] (%.2f,%.2f) -> (%.2f,%.2f) %s\n",
+ segment_count,
+ x1 * 0.05, y1 * 0.05, x2 * 0.05, y2 * 0.05, s->dir==DIR_UP?"up":"down");
}
s->a.x = x1;
s->a.y = y1;
s->pos = s->a;
s->polygon_nr = polygon_nr;
- static int segment_count=0;
- s->nr = segment_count++;
#ifdef CHECKS
/* notice: on some systems (with some compilers), for the line
segment_t* left = actlist_find(status->actlist, h->a, h->a);
segment_t* right = actlist_find(status->actlist, h->b, h->b);
- /* not strictly necessary, also done by the event */
+ /* h->a.x is not strictly necessary, as it's also done by the event */
xrow_add(status->xrow, h->a.x);
+ xrow_add(status->xrow, h->b.x);
if(!right) {
assert(!left);
segment_t* left = actlist_find(status->actlist, p1, p2);
assert(!left || left->fs_out_ok);
#ifdef DEBUG
- fprintf(stderr, " fragment %.2f..%.2f\n",
+ fprintf(stderr, " fragment %.2f..%.2f edge=%08x\n",
x * status->gridsize,
- next_x * status->gridsize);
+ next_x * status->gridsize,
+ h->fs);
if(left) {
fprintf(stderr, " segment [%d] (%.2f,%.2f -> %.2f,%2f, at %.2f,%.2f) is to the left\n",
SEGNR(left),
#ifdef DEBUG
fprintf(stderr, " ...storing\n");
#endif
- append_stroke(status, p1, p2, h->dir, fs);
+ append_stroke(status, p1, p2, DIR_INVERT(h->dir), fs);
} else {
#ifdef DEBUG
- fprintf(stderr, " ...ignoring\n");
+ fprintf(stderr, " ...ignoring (below: (wind_nr=%d, filled=%d), above: (wind_nr=%d, filled=%d) %s\n",
+ below.wind_nr, below.is_filled,
+ above.wind_nr, above.is_filled,
+ h->dir==DIR_UP?"up":"down"
+ );
#endif
}
x = next_x;
status_t status;
memset(&status, 0, sizeof(status_t));
status.gridsize = poly1->gridsize;
+
+ gfxpoly_dump(poly1);
queue_init(&status.queue);
gfxpoly_enqueue(poly1, &status.queue, 0, /*polygon nr*/0);
int teststroke(int argn, char*argv[])
{
- gfxline_t*box1 = gfxline_makerectangle(-100,-100,100,100);
- assert(gfxpoly_check(gfxpoly_from_stroke(box1, 2.0, gfx_capRound, gfx_joinRound, 0, 0.05), 1));
+ //gfxline_t*box1 = gfxline_makerectangle(-100,-100,100,100);
+ gfxline_t*box1 = gfxline_makerectangle(100,100,200,200);
+ gfxpoly_t*poly = gfxpoly_from_stroke(box1, 10.0, gfx_capRound, gfx_joinMiter, 1000, 0.05);
+ assert(gfxpoly_check(poly, 1));
}
int test0(int argn, char*argv[])
int main(int argn, char*argv[])
{
- teststroke(argn, argv);
+ test4(argn, argv);
}