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