]> mj.ucw.cz Git - leo.git/blob - labeller.h
fae5f21b643088ab2800b7791af7bec4d4a0cdf7
[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 };
15
16 enum term_cond
17 {
18   TERM_COND_PENALTY,
19   TERM_COND_STAGNATION,
20   TERM_COND_ITERATIONS,
21 };
22
23 struct sym_placement
24 {
25   double x;
26   double y;
27   int variant;
28   struct request *request;
29 };
30
31 struct request
32 {
33   enum request_type type;
34   int ind;
35 };
36
37 struct point_variant
38 {
39   double width;
40   double height;
41   bool *bitmap;
42 };
43
44 struct line_variant
45 {
46   bool *masks;
47 };
48
49 struct request_point
50 {
51   struct request request;
52   struct symbol *sym;
53   struct osm_object *object;
54   z_index_t zindex;
55   double x;
56   double y;
57   double offset_x;
58   double offset_y;
59   int num_variants;
60   struct point_variant *variants;
61 };
62
63 struct request_segment
64 {
65   struct request request;
66   double x1;
67   double y1;
68   double x2;
69   double y2;
70   double k;
71   struct sym_line *sym;
72   struct point_variant *variant;
73 };
74
75 struct request_line
76 {
77   struct request request;
78   struct symbol *sym;
79   int num_variants;
80   int num_segments;
81   struct line_variant *variants;
82   struct request_segment *segments;
83 };
84
85 struct request_area
86 {
87   struct request request;
88   struct osm_multipolygon *o;
89   z_index_t zindex;
90 };
91
92 struct buffer_line
93 {
94   struct sym_line *line;
95   z_index_t zindex;
96 };
97
98 struct buffer_linelabel
99 {
100   struct osm_way *way;
101   struct sym_text *text;
102   z_index_t zindex;
103 };
104
105 struct graph_node
106 {
107   osm_id_t id;
108   struct graph_edge **edges;
109 };
110
111 struct graph_edge
112 {
113   osm_id_t id;
114   double length;
115   color_t color;
116   bool visited;
117   struct graph_edge *prev;
118   struct graph_edge *next;
119   struct graph_node *n1;
120   struct graph_node *n2;
121   uns longline;
122   struct sym_text *text;
123   struct sym_line *sym;
124 };
125
126 struct longline
127 {
128   uns id;
129   struct graph_edge *first;
130 };
131
132 struct placement
133 {
134   double x;
135   double y;
136   int variant_used;
137   bool processed;
138   struct request *request;
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 gen_coords_point(struct placement *p);
181 void gen_coords(struct placement *p);
182 struct map_part **get_parts(struct placement *symbol, struct individual *individual);
183
184 int randint(int min, int max);
185
186 void get_closure(struct placement **closure, struct placement *placement, struct individual *parent1, struct individual *parent2);
187 void copy_symbols(struct placement **closure, struct individual *parent, struct individual *child);
188 void move_symbol(struct placement *p);
189 void move_symbol_point(struct placement *p);
190
191 struct placement **get_overlapping(struct placement *p);
192 void filter(struct placement **list, bool *pred);
193
194 int flip(int a, int b);
195 double randdouble(void);
196
197 #endif