]> mj.ucw.cz Git - leo.git/blob - labeller.h
Labelling: Clean-up and a lot of new mess
[leo.git] / labeller.h
1 #ifndef _LEO_LABELLER_H
2 #define _LEO_LABELLER_H
3
4 enum request_type
5 {
6   REQUEST_INVALID,
7   REQUEST_POINT,
8   REQUEST_AREA,
9   REQUEST_LINE,
10   REQUEST_SEGMENT,
11 };
12
13 enum term_cond
14 {
15   TERM_COND_PENALTY,
16   TERM_COND_STAGNATION,
17   TERM_COND_ITERATIONS,
18 };
19
20 struct point_variant
21 {
22   double width;
23   double height;
24   bool *bitmap;
25 };
26
27 struct line_variant
28 {
29   bool *masks;
30 };
31
32 struct request
33 {
34   enum request_type type;
35   int ind;
36 };
37
38 struct request_point
39 {
40   struct request request;
41   struct symbol *sym;
42   z_index_t zindex;
43   double x;
44   double y;
45   double offset_x;
46   double offset_y;
47   int num_variants;
48   struct point_variant *variants;
49 };
50
51 struct request_segment
52 {
53   struct request request;
54   double x1;
55   double y1;
56   double x2;
57   double y2;
58   double k;
59   struct sym_line *sym;
60   struct symbol *label;
61   struct point_variant *variant;
62   z_index_t zindex;
63 };
64
65 struct request_line
66 {
67   struct request request;
68   struct symbol *line;
69   int num_variants;
70   int num_segments;
71   struct line_variant *variants;
72   struct request_segment *segments;
73 };
74
75 struct request_area
76 {
77   struct request request;
78   struct osm_multipolygon *o;
79   struct symbol *label;
80   struct point_variant *variants;
81   z_index_t zindex;
82   double cx, cy;
83 };
84
85 struct buffer_line
86 {
87   struct sym_line *line;
88   z_index_t zindex;
89 };
90
91 struct buffer_linelabel
92 {
93   struct osm_way *way;
94   struct symbol *label;
95   z_index_t zindex;
96 };
97
98 struct graph_node
99 {
100   osm_id_t id;
101   struct osm_node *o;
102   struct graph_edge **edges;
103   int num;
104 };
105
106 struct graph_edge
107 {
108   osm_id_t id;
109   double length;
110   color_t color;
111   bool visited;
112   struct graph_edge *prev;
113   struct graph_edge *next;
114   struct graph_node *n1;
115   struct graph_node *n2;
116   uns longline;
117   struct symbol *label;
118   struct sym_line *line;
119   z_index_t zindex;
120   int dir;
121   struct graph_node *anode;
122   struct graph_node *bnode; // DEBUG PRINT
123   int num; // DEBUG
124 };
125
126 struct longline
127 {
128   uns id;
129   struct graph_edge *first;
130 };
131
132 struct placement
133 {
134   struct request *request;
135   double x;
136   double y;
137   int variant_used;
138   bool processed;
139 };
140
141 struct map_part
142 {
143 };
144
145 struct individual
146 {
147   struct placement *placements;
148   struct map_part **map;
149   int penalty;
150 };
151
152 void labeller_init(void);
153 void labeller_add_point(struct symbol *sym, struct osm_object *object, z_index_t zindex);
154 void labeller_add_line(struct symbol *sym, z_index_t zindex);
155 void labeller_label(void);
156 void labeller_add_linelabel(struct symbol *sym, struct osm_object *o, z_index_t zindex);
157 void labeller_add_arealabel(struct symbol *sym, struct osm_object *o, z_index_t zindex);
158
159 void make_bitmap_icon(struct point_variant *v, struct sym_icon *si);
160 void make_bitmap_point(struct point_variant *v, struct sym_point *sp);
161 void make_bitmap_label(struct point_variant *v, struct sym_text *text);
162
163 void make_graph(void);
164 void label_graph(void);
165 void join_edge(struct graph_edge *e, int dir);
166 void bfs(void);
167 void make_segments(void);
168
169 void make_population(void);
170 bool shall_terminate(void);
171 void breed(void);
172 void mutate(void);
173 void elite(void);
174 void rank_population(void);
175
176 struct individual **perform_crossover(struct individual *parent1, struct individual *parent2);
177 void perform_mutation(struct individual *individual);
178
179 void init_placement(struct placement *p, struct request *r);
180 void init_individual(struct individual *i);
181 void gen_coords_point(struct placement *p);
182 void gen_coords(struct placement *p);
183 struct map_part **get_parts(struct placement *symbol, struct individual *individual);
184
185 int randint(int min, int max);
186
187 struct placement **get_closure(struct placement *placement, struct individual *parent1, struct individual *parent2);
188 void copy_symbols(struct placement **closure, struct individual *parent, struct individual *child);
189 void move_symbol(struct placement *p);
190 void move_symbol_point(struct placement *p);
191
192 struct placement **get_overlapping(struct placement *p);
193 void filter(struct placement **list, bool *pred);
194
195 int flip(int a, int b);
196 double randdouble(void);
197
198 void cleanup(void);
199
200 void copy_individual(struct individual *src, struct individual *dest);
201
202 #endif