X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxpoly%2Fpoly.h;h=ff623d362038cdc84c8c6d44c73c7c5aeb02ba0a;hp=68026228cfc4765cd90c0fa95750f02c7ef5b113;hb=3513ae007a04da02f11cdca9f0d08ddda9eac245;hpb=33e9461da6b886671749d6cbabd80b355ab1f6d9 diff --git a/lib/gfxpoly/poly.h b/lib/gfxpoly/poly.h index 6802622..ff623d3 100644 --- a/lib/gfxpoly/poly.h +++ b/lib/gfxpoly/poly.h @@ -5,10 +5,10 @@ #include "../q.h" //#define DEBUG -//#define CHECKS +#define CHECKS #define SPLAY -typedef enum {DIR_UP, DIR_DOWN} segment_dir_t; +typedef enum {DIR_UP, DIR_DOWN, DIR_UNKNOWN} segment_dir_t; typedef enum {EVENT_CROSS, EVENT_END, EVENT_CORNER, EVENT_START, EVENT_HORIZONTAL} eventtype_t; typedef enum {SLOPE_POSITIVE, SLOPE_NEGATIVE} slope_t; @@ -25,7 +25,9 @@ typedef struct _edge { point_t a; point_t b; fillstyle_t*style; +#ifdef DEBUG int tmp; +#endif struct _edge *next; } edge_t; @@ -33,27 +35,36 @@ typedef struct _windstate { char is_filled; int wind_nr; - int num_polygons; } windstate_t; +/* TODO: maybe we should merge windcontext and windrule */ +typedef struct _windcontext +{ + int num_polygons; +} windcontext_t; + typedef struct _windrule { - windstate_t (*start)(int num_polygons); - windstate_t (*add)(windstate_t left, fillstyle_t*edge, segment_dir_t dir, int polygon_nr); + windstate_t (*start)(windcontext_t* num_polygons); + windstate_t (*add)(windcontext_t*context, windstate_t left, fillstyle_t*edge, segment_dir_t dir, int polygon_nr); fillstyle_t* (*diff)(windstate_t*left, windstate_t*right); } windrule_t; +#define SEGNR(s) ((s)?(s)->nr:-1) + typedef struct _segment { point_t a; point_t b; point_t delta; double k; //k = a.x*b.y-a.y*b.x = delta.y*a.x - delta.x*a.y (=0 for points on the segment) - int minx, maxx; + int32_t minx, maxx; segment_dir_t dir; fillstyle_t*fs; fillstyle_t*fs_out; +#ifdef CHECKS char fs_out_ok; +#endif int polygon_nr; windstate_t wind; @@ -94,6 +105,18 @@ typedef struct _gfxpoly { edge_t*edges; } gfxpoly_t; +typedef struct _gfxstroke { + segment_dir_t dir; + int num_points; + point_t*points; + fillstyle_t*fs; +} gfxstroke_t; +typedef struct _gfxcompactpoly { + double gridsize; + int num_strokes; + gfxstroke_t*strokes; +} gfxcompactpoly_t; + void gfxpoly_fail(char*expr, char*file, int line, const char*function); gfxpoly_t* gfxpoly_new(double gridsize); @@ -101,7 +124,7 @@ char gfxpoly_check(gfxpoly_t*poly); int gfxpoly_size(gfxpoly_t*poly); void gfxpoly_dump(gfxpoly_t*poly); gfxpoly_t* gfxpoly_save(gfxpoly_t*poly, const char*filename); -gfxpoly_t* gfxpoly_process(gfxpoly_t*poly, windrule_t*windrule); +gfxpoly_t* gfxpoly_process(gfxpoly_t*poly, windrule_t*windrule, windcontext_t*context); typedef struct _event { eventtype_t type;