+void dump_bitmaps(struct individual *individual)
+{
+ bool *bitmap = malloc(page_width_int * page_height_int * sizeof(bool));
+ printf("Bitmap size is %d\n", page_width_int * page_height_int);
+ for (int i=0; i<page_height_int; i++)
+ for (int j=0; j<page_width_int; j++)
+ bitmap[i*page_width_int + j] = 0;
+
+ for (uns i=0; i<GARY_SIZE(individual->placements); i++)
+ {
+ struct placement *p = &(individual->placements[i]);
+ struct point_variant *v = NULL;
+
+ switch (p->request->type)
+ {
+ case REQUEST_SEGMENT: ;
+ struct request_segment *rs = (struct request_segment *) p->request;
+ v = rs->variant;
+ break;
+ case REQUEST_POINT: ;
+ struct request_point *rp = (struct request_point *) p->request;
+ v = &(rp->variants[p->variant_used]);
+ break;
+ case REQUEST_AREA: ;
+ struct request_area *ra = (struct request_area *) p->request;
+ printf("Using %d-th of %d variants\n", p->variant_used, GARY_SIZE(ra->variants));
+ v = &(ra->variants[p->variant_used]);
+ break;
+ default:
+ ASSERT(p->request->type != REQUEST_INVALID);
+ continue;
+ }
+
+ printf("Rendering %d-th label %d x %d (w x h)\n", i, v->width, v->height);
+ for (int row = max2(p->y, 0); row < min2(p->y + v->height, page_height_int); row++)
+ {
+ for (int col = max2(p->x, 0); col < min2(p->x + v->width, page_width_int); col++)
+ {
+ printf("Writing to %d\n", row*page_width_int + col);
+ bitmap[row * page_width_int + col] = 1;
+ }
+ }
+ }
+
+ errno = 0;
+ FILE *fd_dump = fopen("dump.pbm", "w");
+ fprintf(fd_dump, "P1\n");
+ fprintf(fd_dump, "%d %d\n", page_width_int, page_height_int);
+ for (int i=0; i<page_height_int; i++)
+ {
+ for (int j=0; j<page_width_int; j++)
+ {
+ fprintf(fd_dump, "%d", bitmap[(int) (i*page_width_int + j)] ? 1 : 0);
+ }
+ fprintf(fd_dump, "\n");
+ }
+ fclose(fd_dump);
+}
+