11 #define DONT_REMEMBER_CROSSINGS
13 typedef enum {EVENT_CROSS
, EVENT_END
, EVENT_START
, EVENT_HORIZONTAL
} eventtype_t
;
14 typedef enum {SLOPE_POSITIVE
, SLOPE_NEGATIVE
} slope_t
;
16 #define INVALID_COORD (0x7fffffff)
17 typedef struct _point
{
23 #define SEGNR(s) ((int)((s)?(s)->nr:-1))
25 typedef struct _gfxpolystroke
{
31 struct _gfxpolystroke
*next
;
33 typedef struct _gfxpoly
{
35 gfxpolystroke_t
*strokes
;
38 typedef struct _segment
{
42 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)
57 struct _segment
*parent
;
58 struct _segment
*leftchild
;
59 struct _segment
*rightchild
;
62 struct _segment
*right
;
67 gfxpolystroke_t
*stroke
;
70 #ifndef DONT_REMEMBER_CROSSINGS
71 dict_t scheduled_crossings
;
75 typedef struct _moments
{
80 #define LINE_EQ(p,s) ((double)(s)->delta.y*(p).x - (double)(s)->delta.x*(p).y - (s)->k)
82 /* x1 + ((x2-x1)*(y-y1)) / dy =
83 (x1*(y2-y1) + (x2-x1)*(y-y1)) / dy =
84 (x1*(y2-y) + x2 *(y-y1)) / dy =
85 (x1*y2 - x2*y1 + x2*y - y*x1) / dy =
86 (k + x2*y - x1*y) / dy
89 //#define XPOS(s,ypos) ((s)->a.x + ((s)->delta.x * (double)((ypos) - (s)->a.y)) / (s)->delta.y)
90 #define XPOS(s,ypos) (((s)->k + (double)(s)->delta.x*ypos) / (s)->delta.y)
92 #define XPOS_INT(s,ypos) ((int)ceil(XPOS((s),ypos)))
93 #define XDIFF(s1,s2,ypos) (((s1)->k + (double)(s1)->delta.x*ypos)*(s2)->delta.y - \
94 ((s2)->k + (double)(s2)->delta.x*ypos)*(s1)->delta.y)
96 void gfxpoly_fail(char*expr
, char*file
, int line
, const char*function
);
98 char gfxpoly_check(gfxpoly_t
*poly
, char updown
);
99 int gfxpoly_num_segments(gfxpoly_t
*poly
);
100 int gfxpoly_size(gfxpoly_t
*poly
);
101 void gfxpoly_dump(gfxpoly_t
*poly
);
102 void gfxpoly_save(gfxpoly_t
*poly
, const char*filename
);
103 void gfxpoly_save_arrows(gfxpoly_t
*poly
, const char*filename
);
104 gfxpoly_t
* gfxpoly_process(gfxpoly_t
*poly1
, gfxpoly_t
*poly2
, windrule_t
*windrule
, windcontext_t
*context
, moments_t
*moments
);
106 gfxpoly_t
* gfxpoly_intersect(gfxpoly_t
*p1
, gfxpoly_t
*p2
);
107 gfxpoly_t
* gfxpoly_union(gfxpoly_t
*p1
, gfxpoly_t
*p2
);
108 double gfxpoly_area(gfxpoly_t
*p
);
109 double gfxpoly_intersection_area(gfxpoly_t
*p1
, gfxpoly_t
*p2
);
117 #define assert(x) ((x)?0:gfxpoly_fail(__STRING(x), __FILE__, __LINE__, __PRETTY_FUNCTION__))