GList * geom_poly_segments_insert(GList *list, struct geom_poly_segment *first, struct geom_poly_segment *second, struct geom_poly_segment *third) { int count; struct geom_poly_segment *ret; struct coord *pos; if (!second) return NULL; ret=g_new(struct geom_poly_segment, 1); ret->type=second->type; count=(second->last-second->first)+1; if (first) count+=(first->last-first->first); if (third) count+=(third->last-third->first); #if 0 fprintf(stderr,"count=%d first=%p second=%p third=%p\n",count,first,second,third); if (first) fprintf(stderr,"first:0x%x,0x%x-0x%x,0x%x (%d)\n",first->first->x,first->first->y,first->last->x,first->last->y, first->last-first->first+1); if (second) fprintf(stderr,"second:0x%x,0x%x-0x%x,0x%x (%d)\n",second->first->x,second->first->y,second->last->x,second->last->y, second->last-second->first+1); if (third) fprintf(stderr,"third:0x%x,0x%x-0x%x,0x%x (%d)\n",third->first->x,third->first->y,third->last->x,third->last->y, third->last-third->first+1); #endif ret->first=g_new(struct coord, count); pos=ret->first; if (first) { count=(first->last-first->first)+1; geom_coord_copy(first->first, pos, count, coord_is_equal(*first->first, *second->first)); pos+=count-1; } count=(second->last-second->first)+1; geom_coord_copy(second->first, pos, count, 0); pos+=count; if (third) { pos--; count=(third->last-third->first)+1; geom_coord_copy(third->first, pos, count, coord_is_equal(*third->last, *second->last)); pos+=count; } ret->last=pos-1; #if 0 fprintf(stderr,"result:0x%x,0x%x-0x%x,0x%x (%d)\n",ret->first->x,ret->first->y,ret->last->x,ret->last->y, ret->last-ret->first+1); #endif list=g_list_prepend(list, ret); #if 0 fprintf(stderr,"List=%p\n",list); #endif return list; }
struct geom_poly_segment * item_bin_to_poly_segment(struct item_bin *ib, int type) { struct geom_poly_segment *ret=g_new(struct geom_poly_segment, 1); int count=ib->clen*sizeof(int)/sizeof(struct coord); ret->type=type; ret->first=g_new(struct coord, count); ret->last=ret->first+count-1; geom_coord_copy((struct coord *)(ib+1), ret->first, count, 0); return ret; }