forked from therion/therion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thdb1d.h
436 lines (284 loc) · 8.88 KB
/
thdb1d.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
/**
* @file thdb1d.h
* Survey data structure processing class.
*/
/* Copyright (C) 2000 Stacho Mudrak
*
* $Date: $
* $RCSfile: $
* $Revision: $
*
* --------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* --------------------------------------------------------------------
*/
#ifndef thdb1d_h
#define thdb1d_h
#include "thobjectid.h"
#include "thinfnan.h"
#include "thdataleg.h"
#include "thdb3d.h"
#include "thdataleg.h"
#include "thattr.h"
#include <map>
#include <vector>
#include <list>
enum {
TT_TEMPSTATION_NONE,
TT_TEMPSTATION_WALL,
TT_TEMPSTATION_FEATURE,
};
struct thdb1d_loop_leg {
thdb1d_loop_leg * next_leg, * prev_leg;
thdataleg * leg;
bool reverse;
};
struct thdb1d_loop {
thdb1d_loop_leg * first_leg, * last_leg;
class thdb1ds * from, * to;
unsigned long nlegs;
unsigned long id;
bool open;
double err_dx, err_dy, err_dz, err_length, src_length, err;
};
struct thdb1d_traverse {
thdb1d_loop_leg * first_leg, * last_leg;
class thdb1ds * from, * to;
unsigned long nlegs;
unsigned long id;
double src_length, E, H, V;
};
class thdb1d_tree_node {
public:
bool is_attached, is_fixed;
int xx_left;
bool xx_touched, extendx_ok;
thdb1d_tree_node * next_eq, * prev_eq;
unsigned long id, uid, narrows;
double xx, extendx, xx_ratio;
class thdb1d_tree_arrow * first_arrow, * last_arrow, * back_arrow;
std::list<class thdb1d_tree_arrow * > back_buffer;
void push_back_arrow(class thdb1d_tree_arrow * arrow);
class thdb1d_tree_arrow * pop_back_arrow();
thdb1d_tree_node() : is_attached(false), is_fixed(false), xx_left(1), xx_touched(false), extendx_ok(false),
next_eq(NULL), prev_eq(NULL),
id(0), uid(0), narrows(0), xx(0.0), extendx(0.0), xx_ratio(1.0),
first_arrow(NULL), last_arrow(NULL), back_arrow(NULL) {}
};
class thdb1d_tree_arrow {
public:
bool is_discovery, is_nosurvey, is_reversed;
thdb1d_tree_node * start_node, * end_node;
class thdb1dl * leg;
unsigned extend;
std::list<unsigned long> extend_ignore_before;
thdb1d_tree_arrow * negative;
thdb1d_tree_arrow * next_arrow;
thdb1d_tree_arrow() : is_discovery(false), is_nosurvey(false), is_reversed(false),
start_node(NULL), end_node(NULL),
leg(NULL), extend(TT_EXTENDFLAG_NORMAL), negative(NULL), next_arrow(NULL) {}
};
/**
* Stations search map.
*/
typedef std::map <thobjectid, unsigned long> thdb1d_station_map_type;
/**
* Station information class.
*/
class thdb1ds {
public:
unsigned long uid; ///< Unique ID of a station.
double x, y, z; // coordinates
double xx; // coordinate for extended elevation
double asl; // average cave shot length from this point
const char * name, ///< Station name.
* comment; ///< Station comment.
class thsurvey * survey; ///< Station survey.
class thdataobject * fixcontext; ///< Fix context.
bool tmpselect;
std::list<class thdata *> data; ///< Station data.
unsigned data_priority; ///< 0 - undefined, 1 - equate, 2 - leg, 3 - fix
char temps; ///< Station temporary status.
unsigned long flags; ///< Station flags.
int mark, ///< Mark type.
extend; ///< Extend flags: normal, reverse, left, right, break
double extend_ratio;
bool mark_station;
bool adjusted, fixed;
int placed;
double sdx, sdy, sdz;
double explored;
bool d3_parsed; ///< Whether splay shots have been parsed.
thdb3ddata d3_outline; ///< splay 3d outline.
/**
* Default constructor.
*/
thdb1ds() : uid(0), x(0), y(0), z(0), xx(0), asl(0), name(NULL), comment(NULL), survey(NULL), fixcontext(NULL), tmpselect(false),
data_priority(0), temps(TT_TEMPSTATION_NONE),
flags(TT_STATIONFLAG_NONE), mark(TT_DATAMARK_TEMP), extend(TT_EXTENDFLAG_NORMAL), extend_ratio(thnan), mark_station(false),
adjusted(false), fixed(false), placed(0), sdx(0.0), sdy(0.0), sdz(0.0),
explored(thnan), d3_parsed(false) {}
/**
* Default constructor with 2 parameters.
*/
thdb1ds(const char * n, class thsurvey * ps) : uid(0), x(0), y(0), z(0), xx(0), asl(0), name(n),
comment(NULL), survey(ps), fixcontext(NULL), tmpselect(false),
data_priority(0), temps(TT_TEMPSTATION_NONE),
flags(TT_STATIONFLAG_NONE),
mark(TT_DATAMARK_TEMP), extend(TT_EXTENDFLAG_NORMAL), extend_ratio(thnan), mark_station(false),
adjusted(false), fixed(false), placed(0), sdx(0.0), sdy(0.0), sdz(0.0),
explored(thnan), d3_parsed(false) {}
/**
* Set parent data.
*/
void set_parent_data(class thdata * pd, unsigned pd_priority);
/**
* Is station temporary.
*/
bool is_temporary() {return (temps != TT_TEMPSTATION_NONE);}
/**
* Set temporary status.
*/
void set_temporary(char ts) {temps = ts;}
/**
* Set temporary status.
*/
void set_temporary(const char * name);
/**
* Export station attributes to metapost.
*/
void export_mp_flags(FILE * out);
/**
* Return 3D splay outline. Process if necessary.
*/
thdb3ddata * get_3d_outline();
};
/**
* Stations vector.
*/
typedef std::vector < thdb1ds > thdb1d_station_vec_type;
/**
* Leg information class.
*/
class thdb1dl {
public:
class thdataleg * leg;
class thdata * data;
class thsurvey * survey;
bool reverse;
unsigned long series_id, component_id;
thdb1dl() : leg(NULL), data(NULL), survey(NULL), reverse(false),
series_id(0), component_id(0) {}
thdb1dl(class thdataleg * l, class thdata * d, class thsurvey * s) :
leg(l), data(d), survey(s), reverse(false),
series_id(0), component_id(0) {}
};
/**
* Legs vector.
*/
typedef std::vector < thdb1dl > thdb1d_leg_vec_type;
typedef std::list < thdb1d_loop_leg > thdb1d_loop_leg_list_type;
typedef std::list < thdb1d_loop > thdb1d_loop_list_type;
typedef std::list < thdb1d_traverse > thdb1d_traverse_list_type;
/**
* Survey data structure processing class.
*/
class thdb1d {
public:
class thdatabase * db; ///< Our database.
thdb1dl ** tree_legs; ///< Tree structure.
thdb1d_tree_arrow * tree_arrows;
thdb1d_tree_node * tree_nodes;
thdb3ddata d3_data, d3_surface, d3_walls, d3_splay;
thattr m_station_attr;
double min_year, max_year;
bool d3_data_parsed;
unsigned long num_tree_legs; ///< Number of legs in the tree.
unsigned long lsid; ///< Last station id.
double nlength;
/**
* Scan survey stations.
*/
void scan_data();
/**
* Process survey data tree.
*/
void process_tree();
/**
* Insert station into mapping.
*/
unsigned long insert_station(class thobjectname on, class thsurvey * ps, class thdata * pd, unsigned priority);
/**
* Process survey statistics.
*/
void process_survey_stat();
void postprocess_objects();
public:
thdb1d_station_vec_type station_vec; ///< Stations data.
thdb1d_station_map_type station_map; ///< Stations map.
thdb1d_leg_vec_type leg_vec; ///< Survey shots.
thdb1d_loop_leg_list_type loop_leg_list;
thdb1d_loop_list_type loop_list;
thdb1d_traverse_list_type traverse_list;
/**
* Standard constructor.
*/
thdb1d();
/**
* Destructor.
*/
~thdb1d();
/**
* Assign database pointer.
*/
void assigndb(thdatabase * dbptr);
/**
* Make a loop closure and calculate stations coordinates.
*/
void process_data();
/**
* Return station id if exist, 0 otherwise.
*/
unsigned long get_station_id(class thobjectname on, class thsurvey * ps);
/**
* Print self.
*/
void self_print(FILE * outf);
/**
* Return number of legs in the tree.
*/
unsigned long get_tree_size();
/**
* Return tree legs.
*/
thdb1dl ** get_tree_legs();
thdb1d_tree_arrow * get_tree_arrows() {return this->tree_arrows;}
thdb1d_tree_node * get_tree_nodes() {return this->tree_nodes;}
/**
* Find loops.
*/
void find_loops();
/**
* Make loop closure and calculate station coordinates.
*/
void close_loops();
void print_loops();
void process_xelev();
thdb3ddata * get_3d();
thdb3ddata * get_3d_splay();
thdb3ddata * get_3d_surface();
thdb3ddata * get_3d_walls();
};
#endif