]> mj.ucw.cz Git - leo.git/blobdiff - labeller.c
Labelling: Placements have indices
[leo.git] / labeller.c
index 3c5e4fa486c1ec6ca1e908b1fec10a60f29eb4da..25fd5c81a82e40b20eea46ab32dd42e5c0318c44 100644 (file)
@@ -103,6 +103,7 @@ int move_min = 0;
 int move_max = 1;
 
 int num_requests = 0;
+int num_placements = 0;
 
 int conf_map_part_width = 5;
 int conf_map_part_height = 5;
@@ -150,7 +151,7 @@ void dump_longlines(void);
 void dump_linelabel_requests(void);
 void dump_individual(struct individual *individual);
 void print_label(struct symbol *sym);
-void dump_penalties(void);
+void dump_penalties(struct individual **population);
 
 double gen_movement(void);
 double gen_movement_uniform(void);
@@ -837,8 +838,7 @@ void make_segments(void)
       rs->x2 = e->n2->o->x;
       rs->y2 = e->n2->o->y;
 
-      // FIXME: Set text rotation
-      rs->angle = atan2(rs->x2 - rs->x1, rs->y2 - rs->y1);
+      rs->slope = (rs->y2 - rs->y1) / (rs->x2 - rs->x1);
       rs->zindex = e->zindex;
 
       cur_length += e->length;
@@ -1042,11 +1042,11 @@ if (dbg_plan)
   }
 }
 
-void dump_penalties(void)
+void dump_penalties(struct individual **population)
 {
   for (int i=0; i<conf_pop_size; i++)
   {
-    printf("Individual %d has penalty %d\n", i, population1[i]->penalty);
+    printf("Individual %d has penalty %d\n", i, population[i]->penalty);
   }
 }
 
@@ -1066,7 +1066,7 @@ printf("Having %u point requests, %u line requests and %u area requests\n", GARY
   qsort(population1, conf_pop_size, sizeof(struct individual *), cmp_individual);
 
   if (dbg_evolution)
-    dump_penalties();
+    dump_penalties(population1);
 
   printf("Dealing with %d requests\n", num_requests);
 
@@ -1101,13 +1101,13 @@ printf("Having %u point requests, %u line requests and %u area requests\n", GARY
     pop2_ind = 0;
 
     if (dbg_evolution)
-      dump_penalties();
+      dump_penalties(population1);
 
     rank_population();
     qsort(population1, conf_pop_size, sizeof(struct individual *), cmp_individual);
 
     if (dbg_evolution)
-      dump_penalties();
+      dump_penalties(population1);
   }
 
   plan_individual(population1[0]);
@@ -1125,6 +1125,7 @@ void make_population(void)
 {
   for (int i=0; i<conf_pop_size; i++)
   {
+    num_placements = 0; // FIXME: This IS a terrible HACK
     struct individual *i2 = ep_alloc(ep_individuals);
     init_individual(i2);
     population2[i] = i2;
@@ -1720,6 +1721,7 @@ void hide_segment_labels(struct individual *individual)
 void init_placement(struct placement *p, struct individual *individual, struct request *r)
 {
   // FIXME
+  p->ind = num_placements++;
   p->request = r;
   p->processed = 0;
   p->x = p->y = 0; // To prevent valgrind from complaining