+ if (requests_line[i].sections[0].num_segments == 0)
+ {
+ printf("HEY!\n");
+ continue;
+ }
+ printf("Request for linelabel, %d sections\n", GARY_SIZE(requests_line[i].sections));
+ print_label(requests_line[i].sections[0].segments[0].label);
+ for (uns j=0; j<GARY_SIZE(requests_line[i].sections); j++)
+ {
+ printf("%d section, %d segments\n", j, GARY_SIZE(requests_line[i].sections[j].segments));
+ for (uns k=0; k<GARY_SIZE(requests_line[i].sections[j].segments); k++)
+ {
+ struct request_segment *rs = &requests_line[i].sections[j].segments[k];
+ printf("[%.2f; %.2f] -- [%.2f; %.2f]\n", rs->x1, rs->y1, rs->x2, rs->y2);
+ }
+ }
+ printf("\n");
+ }
+}
+
+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++)
+ {
+fprintf(stderr, "%d-th placement\n", 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:
+ printf("Testing request type (dump_bitmaps): %d\n", p->request->type);
+ ASSERT(p->request->type != REQUEST_INVALID);
+ continue;
+ }
+
+ printf("Got after with %d-th placement of request type %d\n", i, p->request->type);
+
+ 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");