X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxpoly%2Fpoly.h;h=180a4f1f7cb21f96d73d465a233c1e2a803928e7;hp=8efee2e1b1536fe0f81dcb81d1c752af1d283cac;hb=37ae23b3b4f65f65313ca4648197bf2251211193;hpb=ae2bbf404cbdf63152d22f1b0824468d04f8f8ce diff --git a/lib/gfxpoly/poly.h b/lib/gfxpoly/poly.h index 8efee2e..180a4f1 100644 --- a/lib/gfxpoly/poly.h +++ b/lib/gfxpoly/poly.h @@ -4,6 +4,7 @@ #include #include "../q.h" #include "../types.h" +#include "wind.h" //#define DEBUG #define CHECKS @@ -12,45 +13,24 @@ #define SPLAY #define DONT_REMEMBER_CROSSINGS -typedef enum {DIR_UP, DIR_DOWN, DIR_UNKNOWN} segment_dir_t; typedef enum {EVENT_CROSS, EVENT_END, EVENT_START, EVENT_HORIZONTAL} eventtype_t; typedef enum {SLOPE_POSITIVE, SLOPE_NEGATIVE} slope_t; +#define INVALID_COORD (0x7fffffff) typedef struct _point { int32_t x; int32_t y; } point_t; +type_t point_type; -typedef struct _fillstyle { - char is_filled; -} fillstyle_t; - -typedef struct _windstate -{ - char is_filled; - int wind_nr; -} windstate_t; - -/* TODO: maybe we should merge windcontext and windrule */ -typedef struct _windcontext -{ - int num_polygons; -} windcontext_t; - -typedef struct _windrule -{ - 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) +#define SEGNR(s) ((int)((s)?(s)->nr:-1)) typedef struct _gfxpolystroke { segment_dir_t dir; + edgestyle_t*fs; + int points_size; int num_points; point_t*points; - fillstyle_t*fs; struct _gfxpolystroke*next; } gfxpolystroke_t; typedef struct _gfxpoly { @@ -66,8 +46,8 @@ typedef struct _segment { int32_t minx, maxx; segment_dir_t dir; - fillstyle_t*fs; - fillstyle_t*fs_out; + edgestyle_t*fs; + edgestyle_t*fs_out; #ifdef CHECKS char fs_out_ok; #endif @@ -90,7 +70,9 @@ typedef struct _segment { gfxpolystroke_t*stroke; int stroke_pos; +#ifndef DONT_REMEMBER_CROSSINGS dict_t scheduled_crossings; +#endif } segment_t; #define LINE_EQ(p,s) ((double)(s)->delta.y*(p).x - (double)(s)->delta.x*(p).y - (s)->k) @@ -112,10 +94,15 @@ typedef struct _segment { void gfxpoly_fail(char*expr, char*file, int line, const char*function); char gfxpoly_check(gfxpoly_t*poly); +int gfxpoly_num_segments(gfxpoly_t*poly); int gfxpoly_size(gfxpoly_t*poly); void gfxpoly_dump(gfxpoly_t*poly); void gfxpoly_save(gfxpoly_t*poly, const char*filename); -gfxpoly_t* gfxpoly_process(gfxpoly_t*poly, windrule_t*windrule, windcontext_t*context); +void gfxpoly_save_arrows(gfxpoly_t*poly, const char*filename); +gfxpoly_t* gfxpoly_process(gfxpoly_t*poly1, gfxpoly_t*poly2, windrule_t*windrule, windcontext_t*context); + +gfxpoly_t* gfxpoly_intersect(gfxpoly_t*p1, gfxpoly_t*p2); +gfxpoly_t* gfxpoly_union(gfxpoly_t*p1, gfxpoly_t*p2); #ifndef CHECKS #ifdef assert