made gfxpoly_dump print out segments in the right order
authorMatthias Kramm <kramm@quiss.org>
Tue, 6 Apr 2010 02:46:54 +0000 (19:46 -0700)
committerMatthias Kramm <kramm@quiss.org>
Tue, 6 Apr 2010 02:46:54 +0000 (19:46 -0700)
lib/gfxpoly/poly.c
lib/gfxpoly/test.c

index 8279b11..7eb6509 100644 (file)
@@ -210,12 +210,21 @@ void gfxpoly_dump(gfxpoly_t*poly)
     fprintf(stderr, "polyon %p (gridsize: %f)\n", poly, poly->gridsize);
     gfxpolystroke_t*stroke = poly->strokes;
     for(;stroke;stroke=stroke->next) {
     fprintf(stderr, "polyon %p (gridsize: %f)\n", poly, poly->gridsize);
     gfxpolystroke_t*stroke = poly->strokes;
     for(;stroke;stroke=stroke->next) {
-       fprintf(stderr, "%p", stroke);
-       for(s=0;s<stroke->num_points-1;s++) {
-           point_t a = stroke->points[s];
-           point_t b = stroke->points[s+1];
-           fprintf(stderr, "%s (%f,%f) -> (%f,%f)%s\n", s?"           ":"", a.x*g, a.y*g, b.x*g, b.y*g,
-                                                       s==stroke->num_points-2?"]":"");
+       fprintf(stderr, "%11p", stroke);
+       if(stroke->dir==DIR_UP) {
+           for(s=stroke->num_points-1;s>=1;s--) {
+               point_t a = stroke->points[s];
+               point_t b = stroke->points[s-1];
+               fprintf(stderr, "%s (%f,%f) -> (%f,%f)%s%s\n", s!=stroke->num_points-1?"           ":"", a.x*g, a.y*g, b.x*g, b.y*g,
+                                                           s==1?"]":"", a.y==b.y?"H":"");
+           }
+       } else {
+           for(s=0;s<stroke->num_points-1;s++) {
+               point_t a = stroke->points[s];
+               point_t b = stroke->points[s+1];
+               fprintf(stderr, "%s (%f,%f) -> (%f,%f)%s%s\n", s?"           ":"", a.x*g, a.y*g, b.x*g, b.y*g,
+                                                           s==stroke->num_points-2?"]":"", a.y==b.y?"H":"");
+           }
        }
     }
 }
        }
     }
 }
@@ -1201,14 +1210,20 @@ static void add_horizontals(gfxpoly_t*poly, windrule_t*windrule, windcontext_t*c
                     e->s2 = 0;
                     hqueue_put(&hqueue, e);
                     left = actlist_left(actlist, s);
                     e->s2 = 0;
                     hqueue_put(&hqueue, e);
                     left = actlist_left(actlist, s);
-                   dir_down^=1;
+                   if(e->s1->dir==DIR_UP)
+                       dir_up^=1;
+                   else
+                       dir_down^=1;
                     break;
                 }
                 case EVENT_END: {
                     left = actlist_left(actlist, s);
                     actlist_delete(actlist, s);
                    advance_stroke(0, &hqueue, s->stroke, s->polygon_nr, s->stroke_pos);
                     break;
                 }
                 case EVENT_END: {
                     left = actlist_left(actlist, s);
                     actlist_delete(actlist, s);
                    advance_stroke(0, &hqueue, s->stroke, s->polygon_nr, s->stroke_pos);
-                   dir_up^=1;
+                   if(e->s1->dir==DIR_DOWN)
+                       dir_up^=1;
+                   else
+                       dir_down^=1;
                     break;
                 }
                 default: assert(0);
                     break;
                 }
                 default: assert(0);
index 6d12513..e968c17 100644 (file)
@@ -216,7 +216,7 @@ int test1(int argn, char*argv[])
     gfxline_t*b = 0;
     b = gfxline_append(b, box1);
     b = gfxline_append(b, box2);
     gfxline_t*b = 0;
     b = gfxline_append(b, box1);
     b = gfxline_append(b, box2);
-    b = gfxline_append(b, box3);
+    //b = gfxline_append(b, box3);
 
     gfxmatrix_t matrix;
     memset(&matrix, 0, sizeof(gfxmatrix_t));
 
     gfxmatrix_t matrix;
     memset(&matrix, 0, sizeof(gfxmatrix_t));
@@ -236,6 +236,7 @@ int test1(int argn, char*argv[])
 
     gfxpoly_dump(poly);
     gfxpoly_t*poly2 = gfxpoly_process(poly, 0, &windrule_evenodd, &onepolygon);
 
     gfxpoly_dump(poly);
     gfxpoly_t*poly2 = gfxpoly_process(poly, 0, &windrule_evenodd, &onepolygon);
+    gfxpoly_dump(poly2);
     gfxpoly_destroy(poly);
     gfxpoly_destroy(poly2);
 }
     gfxpoly_destroy(poly);
     gfxpoly_destroy(poly2);
 }
@@ -638,6 +639,6 @@ void test5(int argn, char*argv[])
 
 int main(int argn, char*argv[])
 {
 
 int main(int argn, char*argv[])
 {
-    test3(argn, argv);
+    test1(argn, argv);
 }
 
 }