+char gfxcompactpoly_check(gfxcompactpoly_t*poly)
+{
+ dict_t*d = dict_new2(&point_type);
+ int s,t;
+ for(t=0;t<poly->num_strokes;t++) {
+ gfxpolystroke_t*stroke = &poly->strokes[t];
+ for(s=0;s<stroke->num_points;s++) {
+ point_t p = stroke->points[s];
+ int num = (s>=1 && s<stroke->num_points-1)?2:1; // mid points are two points (start+end)
+ if(!dict_contains(d, &p)) {
+ dict_put(d, &p, (void*)(ptroff_t)num);
+ } else {
+ int count = (ptroff_t)dict_lookup(d, &p);
+ dict_del(d, &p);
+ count+=num;
+ dict_put(d, &p, (void*)(ptroff_t)count);
+ }
+ }
+ }
+ DICT_ITERATE_ITEMS(d, point_t*, p, void*, c) {
+ int count = (ptroff_t)c;
+ if(count&1) {
+ fprintf(stderr, "Point (%f,%f) occurs %d times\n", p->x*poly->gridsize, p->y*poly->gridsize, count);
+ dict_destroy(d);
+ return 0;
+ }
+ }
+ dict_destroy(d);
+ return 1;
+}
+