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