+static void recalculate_windings(status_t*status)
+{
+ /* TODO: we could use some clever second linked list structure so that we
+ only need to process points we know we marked */
+
+ segment_t*s = actlist_leftmost(status->actlist);
+ segment_t*last = 0;
+ while(s) {
+ windstate_t wind = last?last->wind:status->windrule->start(status->num_polygons);
+ s->wind = status->windrule->add(wind, s->fs, s->dir, s->polygon_nr);
+ s->fs_out = status->windrule->diff(&wind, &s->wind);
+ s->fs_out_ok = 1;
+#ifdef DEBUG
+ fprintf(stderr, "[%d] %s/%d/%s/%s ", s->nr, s->dir==DIR_UP?"up":"down", s->wind.wind_nr, s->wind.is_filled?"fill":"nofill", s->fs_out?"draw":"omit");
+#endif
+ last = s;
+ s = actlist_right(status->actlist, s);
+ }
+#ifdef DEBUG
+ fprintf(stderr, "\n");
+#endif
+
+}
+
+void intersect_with_horizontal(status_t*status, segment_t*h)
+{
+ segment_t* left = actlist_find(status->actlist, h->a, h->a);
+ segment_t* right = actlist_find(status->actlist, h->b, h->b);
+
+ segment_t* s = right;
+
+ while(s!=left) {
+ assert(s);
+ /*
+ x1 + ((x2-x1)*(y-y1)) / dy =
+ (x1*(y2-y) + x2*(y-y1)) / dy
+ */
+ point_t p;
+ p.y = status->y;
+ p.x = XPOS(s, p.y);
+#ifdef DEBUG
+ fprintf(stderr, "...into [%d] (%d,%d) -> (%d,%d) at (%d,%d)\n", s->nr,
+ s->a.x, s->a.y,
+ s->b.x, s->b.y,
+ p.x, p.y
+ );
+#endif
+ assert(p.x >= h->a.x);
+ assert(p.x <= h->b.x);
+ assert(s->delta.x > 0 && p.x >= s->a.x || s->delta.x <= 0 && p.x <= s->a.x);
+ assert(s->delta.x > 0 && p.x <= s->b.x || s->delta.x <= 0 && p.x >= s->b.x);
+ xrow_add(status->xrow, p.x);
+
+ s = actlist_left(status->actlist, s);
+ }
+ xrow_add(status->xrow, h->a.x);
+}
+