+static void add_points(status_t*status)
+{
+ /* TODO: we could use some clever second linked list structure so that we
+ only need to process points which we know we marked */
+ int t;
+ segment_t*s = actlist_leftmost(status->actlist);
+ while(s) {
+ if(s->new_point.y == status->y) {
+ insert_point_into_segment(status, s, s->new_point);
+ s->pos = s->new_pos;
+ }
+ s = actlist_right(status->actlist, s);
+ }
+}
+
+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);
+}
+