[0156ccfc] | 1 | /* cavern.c |
---|
[bb90203] | 2 | * SURVEX Cave surveying software: data reduction main and related functions |
---|
[168df28] | 3 | * Copyright (C) 1991-2003,2004,2005 Olly Betts |
---|
[846746e] | 4 | * |
---|
[89231c4] | 5 | * This program is free software; you can redistribute it and/or modify |
---|
| 6 | * it under the terms of the GNU General Public License as published by |
---|
| 7 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 8 | * (at your option) any later version. |
---|
[846746e] | 9 | * |
---|
| 10 | * This program is distributed in the hope that it will be useful, |
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[89231c4] | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 13 | * GNU General Public License for more details. |
---|
[846746e] | 14 | * |
---|
[89231c4] | 15 | * You should have received a copy of the GNU General Public License |
---|
| 16 | * along with this program; if not, write to the Free Software |
---|
[1b71c05] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[bb90203] | 18 | */ |
---|
| 19 | |
---|
| 20 | #ifdef HAVE_CONFIG_H |
---|
| 21 | #include <config.h> |
---|
| 22 | #endif |
---|
| 23 | |
---|
[17aa816] | 24 | #include <limits.h> |
---|
[bb90203] | 25 | #include <time.h> |
---|
| 26 | |
---|
[5853657] | 27 | #include "cavern.h" |
---|
| 28 | #include "cmdline.h" |
---|
| 29 | #include "commands.h" |
---|
[bb90203] | 30 | #include "datain.h" |
---|
| 31 | #include "debug.h" |
---|
| 32 | #include "message.h" |
---|
| 33 | #include "filename.h" |
---|
| 34 | #include "filelist.h" |
---|
| 35 | #include "img.h" |
---|
| 36 | #include "listpos.h" |
---|
[5853657] | 37 | #include "netbits.h" |
---|
| 38 | #include "netskel.h" |
---|
| 39 | #include "osdepend.h" |
---|
[bb90203] | 40 | #include "out.h" |
---|
[8e8057c] | 41 | #include "str.h" |
---|
[5853657] | 42 | #include "validate.h" |
---|
[bb90203] | 43 | |
---|
[168df28] | 44 | #if (OS==WIN32) |
---|
| 45 | #include <conio.h> /* for _kbhit() and _getch() */ |
---|
| 46 | #endif |
---|
| 47 | |
---|
[ef3c9e2] | 48 | #ifdef CHASM3DX |
---|
[8318645] | 49 | # if OS != RISCOS |
---|
| 50 | /* include header for getcwd() */ |
---|
[9ff87ea] | 51 | # if OS == MSDOS && !defined(__DJGPP__) |
---|
[8318645] | 52 | # include <dir.h> |
---|
[9ff87ea] | 53 | # elif OS == WIN32 |
---|
[6120efa] | 54 | # include <direct.h> |
---|
[8318645] | 55 | # else |
---|
| 56 | # include <unistd.h> |
---|
| 57 | # endif |
---|
[2d3f65a] | 58 | #endif |
---|
[407084d] | 59 | |
---|
[647407d] | 60 | #ifndef MAXPATHLEN |
---|
| 61 | #define MAXPATHLEN 1024 |
---|
| 62 | #endif |
---|
| 63 | #endif |
---|
| 64 | |
---|
[bb90203] | 65 | /* For funcs which want to be immune from messing around with different |
---|
| 66 | * calling conventions */ |
---|
| 67 | #ifndef CDECL |
---|
| 68 | # define CDECL |
---|
| 69 | #endif |
---|
| 70 | |
---|
| 71 | /* Globals */ |
---|
| 72 | node *stnlist = NULL; |
---|
| 73 | settings *pcs; |
---|
| 74 | prefix *root; |
---|
| 75 | long cLegs, cStns; |
---|
| 76 | long cComponents; |
---|
[d1878c51] | 77 | bool fExportUsed = fFalse; |
---|
[bb90203] | 78 | |
---|
| 79 | FILE *fhErrStat = NULL; |
---|
[693388e] | 80 | img *pimg = NULL; |
---|
[bb90203] | 81 | #ifndef NO_PERCENTAGE |
---|
| 82 | bool fPercent = fFalse; |
---|
| 83 | #endif |
---|
[647407d] | 84 | bool fQuiet = fFalse; /* just show brief summary + errors */ |
---|
[ed0f5b6] | 85 | bool fMute = fFalse; /* just show errors */ |
---|
[647407d] | 86 | bool fSuppress = fFalse; /* only output 3d(3dx) file */ |
---|
[2b6eca8] | 87 | static bool fLog = fFalse; /* stdout to .log file */ |
---|
[421b7d2] | 88 | static bool f_warnings_are_errors = fFalse; /* turn warnings into errors */ |
---|
[647407d] | 89 | |
---|
| 90 | nosurveylink *nosurveyhead; |
---|
[bb90203] | 91 | |
---|
| 92 | real totadj, total, totplan, totvert; |
---|
| 93 | real min[3], max[3]; |
---|
| 94 | prefix *pfxHi[3], *pfxLo[3]; |
---|
| 95 | |
---|
| 96 | char *survey_title = NULL; |
---|
| 97 | int survey_title_len; |
---|
| 98 | |
---|
| 99 | bool fExplicitTitle = fFalse; |
---|
| 100 | |
---|
[8e8057c] | 101 | char *fnm_output_base = NULL; |
---|
| 102 | int fnm_output_base_is_dir = 0; |
---|
| 103 | |
---|
[06a871f] | 104 | static void do_stats(void); |
---|
[bb90203] | 105 | |
---|
| 106 | static const struct option long_opts[] = { |
---|
| 107 | /* const char *name; int has_arg (0 no_argument, 1 required_*, 2 optional_*); int *flag; int val; */ |
---|
| 108 | #ifdef NO_PERCENTAGE |
---|
| 109 | {"percentage", no_argument, 0, 0}, |
---|
| 110 | {"no-percentage", no_argument, 0, 0}, |
---|
| 111 | #else |
---|
| 112 | {"percentage", no_argument, 0, 'p'}, |
---|
[2dfd768] | 113 | {"no-percentage", no_argument, 0, 3}, |
---|
[bb90203] | 114 | #endif |
---|
[8e8057c] | 115 | {"output", required_argument, 0, 'o'}, |
---|
[647407d] | 116 | {"quiet", no_argument, 0, 'q'}, |
---|
| 117 | {"no-auxiliary-files", no_argument, 0, 's'}, |
---|
[bb9d869] | 118 | {"warnings-are-errors", no_argument, 0, 'w'}, |
---|
[0dab87a] | 119 | {"log", no_argument, 0, 1}, |
---|
[ef3c9e2] | 120 | #ifdef CHASM3DX |
---|
[773bb23] | 121 | {"chasm-format", no_argument, 0, 'x'}, |
---|
[5b68ae1] | 122 | #endif |
---|
[ce6ab688] | 123 | #if (OS==WIN32) |
---|
[0dab87a] | 124 | {"pause", no_argument, 0, 2}, |
---|
[647407d] | 125 | #endif |
---|
[bb90203] | 126 | {"help", no_argument, 0, HLP_HELP}, |
---|
| 127 | {"version", no_argument, 0, HLP_VERSION}, |
---|
| 128 | {0, 0, 0, 0} |
---|
| 129 | }; |
---|
| 130 | |
---|
[ef3c9e2] | 131 | #ifdef CHASM3DX |
---|
[bb9d869] | 132 | #define short_opts "pxao:qswz:" |
---|
[647407d] | 133 | #else |
---|
[bb9d869] | 134 | #define short_opts "pao:qswz:" |
---|
[647407d] | 135 | #endif |
---|
[bb90203] | 136 | |
---|
[647407d] | 137 | /* TRANSLATE extract help messages to message file */ |
---|
[bb90203] | 138 | static struct help_msg help[] = { |
---|
| 139 | /* <-- */ |
---|
[168df28] | 140 | {HLP_ENCODELONG(0), "display percentage progress"}, |
---|
| 141 | {HLP_ENCODELONG(2), "set location for output files"}, |
---|
| 142 | {HLP_ENCODELONG(3), "only show brief summary (-qq for errors only)"}, |
---|
| 143 | {HLP_ENCODELONG(4), "do not create .err file"}, |
---|
| 144 | {HLP_ENCODELONG(5), "turn warnings into errors"}, |
---|
| 145 | {HLP_ENCODELONG(6), "log output to .log file"}, |
---|
[ef3c9e2] | 146 | #ifdef CHASM3DX |
---|
[168df28] | 147 | {HLP_ENCODELONG(7), "output data in chasm's 3dx format"}, |
---|
[647407d] | 148 | #endif |
---|
[168df28] | 149 | /*{'z', "set optimizations for network reduction"},*/ |
---|
[bb90203] | 150 | {0, 0} |
---|
| 151 | }; |
---|
| 152 | |
---|
[5b68ae1] | 153 | /* atexit functions */ |
---|
[25ab06b] | 154 | static void |
---|
| 155 | delete_output_on_error(void) |
---|
| 156 | { |
---|
[bb9d869] | 157 | if (msg_errors || (f_warnings_are_errors && msg_warnings)) |
---|
| 158 | filename_delete_output(); |
---|
[25ab06b] | 159 | } |
---|
| 160 | |
---|
[5b68ae1] | 161 | #if (OS==WIN32) |
---|
| 162 | static void |
---|
| 163 | pause_on_exit(void) |
---|
| 164 | { |
---|
| 165 | while (_kbhit()) _getch(); |
---|
| 166 | _getch(); |
---|
| 167 | } |
---|
| 168 | #endif |
---|
| 169 | |
---|
[bb90203] | 170 | extern CDECL int |
---|
| 171 | main(int argc, char **argv) |
---|
| 172 | { |
---|
| 173 | int d; |
---|
[17aa816] | 174 | time_t tmUserStart = time(NULL); |
---|
| 175 | clock_t tmCPUStart = clock(); |
---|
[bb90203] | 176 | init_screen(); |
---|
| 177 | |
---|
[bdfe97f] | 178 | msg_init(argv); |
---|
[bb90203] | 179 | |
---|
| 180 | pcs = osnew(settings); |
---|
| 181 | pcs->next = NULL; |
---|
| 182 | pcs->Translate = ((short*) osmalloc(ossizeof(short) * 257)) + 1; |
---|
| 183 | |
---|
| 184 | /* Set up root of prefix hierarchy */ |
---|
| 185 | root = osnew(prefix); |
---|
| 186 | root->up = root->right = root->down = NULL; |
---|
| 187 | root->stn = NULL; |
---|
[421b7d2] | 188 | root->pos = NULL; |
---|
[ff6cfe1] | 189 | root->ident = NULL; |
---|
[932f7e9] | 190 | root->min_export = root->max_export = 0; |
---|
[95c3272] | 191 | root->sflags = BIT(SFLAGS_SURVEY); |
---|
[016068a] | 192 | root->filename = NULL; |
---|
[647407d] | 193 | |
---|
| 194 | nosurveyhead = NULL; |
---|
[bb90203] | 195 | |
---|
| 196 | stnlist = NULL; |
---|
| 197 | cLegs = cStns = cComponents = 0; |
---|
| 198 | totadj = total = totplan = totvert = 0.0; |
---|
| 199 | |
---|
| 200 | for (d = 0; d <= 2; d++) { |
---|
[fa42426] | 201 | min[d] = HUGE_REAL; |
---|
| 202 | max[d] = -HUGE_REAL; |
---|
[bb90203] | 203 | pfxHi[d] = pfxLo[d] = NULL; |
---|
| 204 | } |
---|
| 205 | |
---|
[d06141c] | 206 | /* at least one argument must be given */ |
---|
[b85e20f] | 207 | cmdline_init(argc, argv, short_opts, long_opts, NULL, help, 1, -1); |
---|
[bb90203] | 208 | while (1) { |
---|
[b85e20f] | 209 | int opt = cmdline_getopt(); |
---|
[bb90203] | 210 | if (opt == EOF) break; |
---|
| 211 | switch (opt) { |
---|
| 212 | case 'p': |
---|
| 213 | #ifndef NO_PERCENTAGE |
---|
| 214 | fPercent = 1; |
---|
| 215 | #endif |
---|
| 216 | break; |
---|
[2dfd768] | 217 | #ifndef NO_PERCENTAGE |
---|
| 218 | case 3: |
---|
| 219 | fPercent = 0; |
---|
| 220 | break; |
---|
| 221 | #endif |
---|
[8e8057c] | 222 | case 'o': { |
---|
[168df28] | 223 | osfree(fnm_output_base); /* in case of multiple -o options */ |
---|
[8e8057c] | 224 | /* can be a directory (in which case use basename of leaf input) |
---|
| 225 | * or a file (in which case just trim the extension off) */ |
---|
| 226 | if (fDirectory(optarg)) { |
---|
| 227 | /* this is a little tricky - we need to note the path here, |
---|
| 228 | * and then add the leaf later on (in datain.c) */ |
---|
| 229 | fnm_output_base = base_from_fnm(optarg); |
---|
| 230 | fnm_output_base_is_dir = 1; |
---|
| 231 | } else { |
---|
| 232 | fnm_output_base = base_from_fnm(optarg); |
---|
| 233 | } |
---|
| 234 | break; |
---|
| 235 | } |
---|
[ef3c9e2] | 236 | #ifdef CHASM3DX |
---|
[647407d] | 237 | case 'x': { |
---|
| 238 | fUseNewFormat = 1; |
---|
| 239 | break; |
---|
| 240 | } |
---|
| 241 | #endif |
---|
| 242 | case 'q': |
---|
| 243 | if (fQuiet) fMute = 1; |
---|
| 244 | fQuiet = 1; |
---|
| 245 | break; |
---|
| 246 | case 's': |
---|
| 247 | fSuppress = 1; |
---|
| 248 | break; |
---|
[bb9d869] | 249 | case 'w': |
---|
| 250 | f_warnings_are_errors = 1; |
---|
| 251 | break; |
---|
[8e8057c] | 252 | case 'z': { |
---|
| 253 | /* Control which network optimisations are used (development tool) */ |
---|
| 254 | static int first_opt_z = 1; |
---|
[eb18f4d] | 255 | char c; |
---|
[8e8057c] | 256 | if (first_opt_z) { |
---|
[bb90203] | 257 | optimize = 0; |
---|
[8e8057c] | 258 | first_opt_z = 0; |
---|
[bb90203] | 259 | } |
---|
[c50391b8] | 260 | /* Lollipops, Parallel legs, Iterate mx, Delta* */ |
---|
[eb18f4d] | 261 | while ((c = *optarg++) != '\0') |
---|
[06535ee] | 262 | if (islower((unsigned char)c)) optimize |= BITA(c); |
---|
[0dab87a] | 263 | break; |
---|
| 264 | case 1: |
---|
| 265 | fLog = fTrue; |
---|
[bb90203] | 266 | break; |
---|
[5b68ae1] | 267 | #if (OS==WIN32) |
---|
[0dab87a] | 268 | case 2: |
---|
[5b68ae1] | 269 | atexit(pause_on_exit); |
---|
| 270 | break; |
---|
| 271 | #endif |
---|
[bb90203] | 272 | } |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | |
---|
[0dab87a] | 276 | if (fLog) { |
---|
| 277 | char *fnm; |
---|
[9887ea0] | 278 | if (!fnm_output_base) { |
---|
| 279 | char *p; |
---|
| 280 | p = baseleaf_from_fnm(argv[optind]); |
---|
[0156ccfc] | 281 | fnm = add_ext(p, EXT_LOG); |
---|
[421b7d2] | 282 | osfree(p); |
---|
[9887ea0] | 283 | } else if (fnm_output_base_is_dir) { |
---|
[09e8f4c] | 284 | char *p; |
---|
| 285 | fnm = baseleaf_from_fnm(argv[optind]); |
---|
| 286 | p = use_path(fnm_output_base, fnm); |
---|
| 287 | osfree(fnm); |
---|
[0156ccfc] | 288 | fnm = add_ext(p, EXT_LOG); |
---|
[09e8f4c] | 289 | osfree(p); |
---|
| 290 | } else { |
---|
[0156ccfc] | 291 | fnm = add_ext(fnm_output_base, EXT_LOG); |
---|
[09e8f4c] | 292 | } |
---|
[421b7d2] | 293 | |
---|
[0dab87a] | 294 | if (!freopen(fnm, "w", stdout)) |
---|
| 295 | fatalerror(/*Failed to open output file `%s'*/47, fnm); |
---|
| 296 | |
---|
| 297 | osfree(fnm); |
---|
| 298 | } |
---|
| 299 | |
---|
[168df28] | 300 | if (!fMute) { |
---|
| 301 | const char *p = COPYRIGHT_MSG; |
---|
| 302 | puts(PRETTYPACKAGE" "VERSION); |
---|
| 303 | while (1) { |
---|
| 304 | const char *q = p; |
---|
| 305 | p = strstr(p, "(C)"); |
---|
| 306 | if (p == NULL) { |
---|
| 307 | puts(q); |
---|
| 308 | break; |
---|
| 309 | } |
---|
| 310 | fwrite(q, 1, p - q, stdout); |
---|
| 311 | fputs(msg(/*©*/0), stdout); |
---|
| 312 | p += 3; |
---|
| 313 | } |
---|
| 314 | } |
---|
[bb90203] | 315 | |
---|
[25ab06b] | 316 | atexit(delete_output_on_error); |
---|
| 317 | |
---|
[bb90203] | 318 | /* end of options, now process data files */ |
---|
| 319 | while (argv[optind]) { |
---|
| 320 | const char *fnm = argv[optind]; |
---|
| 321 | |
---|
| 322 | if (!fExplicitTitle) { |
---|
| 323 | char *lf; |
---|
[8e8057c] | 324 | lf = baseleaf_from_fnm(fnm); |
---|
[bb90203] | 325 | if (survey_title) s_catchar(&survey_title, &survey_title_len, ' '); |
---|
| 326 | s_cat(&survey_title, &survey_title_len, lf); |
---|
| 327 | osfree(lf); |
---|
| 328 | } |
---|
| 329 | |
---|
| 330 | /* Select defaults settings */ |
---|
| 331 | default_all(pcs); |
---|
[ef3c9e2] | 332 | #ifdef CHASM3DX |
---|
[647407d] | 333 | /* we need to get the filename of the first one for our base_source */ |
---|
| 334 | /* and also run_file */ |
---|
| 335 | if (fUseNewFormat) { |
---|
| 336 | create_twig(root, fnm); |
---|
| 337 | rhizome = root->twig_link; |
---|
| 338 | limb = get_twig(root); |
---|
| 339 | firstfilename = osstrdup(fnm); |
---|
| 340 | startingdir = osmalloc(MAXPATHLEN); |
---|
[49090c02] | 341 | #if (OS==RISCOS) |
---|
| 342 | strcpy(startingdir, "@"); |
---|
| 343 | #else |
---|
[647407d] | 344 | getcwd(startingdir, MAXPATHLEN); |
---|
[49090c02] | 345 | #endif |
---|
[647407d] | 346 | } |
---|
| 347 | #endif |
---|
[f4b609d] | 348 | data_file(NULL, fnm); /* first argument is current path */ |
---|
[cb3d1e2] | 349 | |
---|
[bb90203] | 350 | optind++; |
---|
| 351 | } |
---|
[cb3d1e2] | 352 | |
---|
[bb90203] | 353 | validate(); |
---|
| 354 | |
---|
| 355 | solve_network(/*stnlist*/); /* Find coordinates of all points */ |
---|
| 356 | validate(); |
---|
[421b7d2] | 357 | |
---|
[ef3c9e2] | 358 | #ifdef CHASM3DX |
---|
[647407d] | 359 | if (fUseNewFormat) { |
---|
[6f185e5] | 360 | /* this actually does all the writing */ |
---|
| 361 | if (!cave_close(pimg)) { |
---|
| 362 | char *fnm = add_ext(fnm_output_base, EXT_SVX_3DX); |
---|
[ecf69ee] | 363 | fatalerror(/*Error writing to file `%s'*/110, fnm); |
---|
[6f185e5] | 364 | } |
---|
[647407d] | 365 | } else { |
---|
[bb90203] | 366 | #endif |
---|
[6f185e5] | 367 | /* close .3d file */ |
---|
| 368 | if (!img_close(pimg)) { |
---|
| 369 | char *fnm = add_ext(fnm_output_base, EXT_SVX_3D); |
---|
| 370 | fatalerror(img_error(), fnm); |
---|
| 371 | } |
---|
[ef3c9e2] | 372 | #ifdef CHASM3DX |
---|
[647407d] | 373 | } |
---|
| 374 | #endif |
---|
[7104f16] | 375 | if (fhErrStat) safe_fclose(fhErrStat); |
---|
[bb90203] | 376 | |
---|
| 377 | out_current_action(msg(/*Calculating statistics*/120)); |
---|
[2b6eca8] | 378 | if (!fMute) do_stats(); |
---|
[647407d] | 379 | if (!fQuiet) { |
---|
[f03053a7] | 380 | /* clock() typically wraps after 72 minutes, but there doesn't seem |
---|
| 381 | * to be a better way. Still 72 minutes means some cave! |
---|
[17aa816] | 382 | * We detect if clock() could have wrapped and suppress CPU time |
---|
| 383 | * printing in this case. |
---|
[f03053a7] | 384 | */ |
---|
[17aa816] | 385 | double tmUser = difftime(time(NULL), tmUserStart); |
---|
| 386 | double tmCPU; |
---|
| 387 | clock_t now = clock(); |
---|
[8db3584] | 388 | #define CLOCK_T_WRAP \ |
---|
| 389 | (sizeof(clock_t)<sizeof(long)?(1ul << (CHAR_BIT * sizeof(clock_t))):0) |
---|
[17aa816] | 390 | tmCPU = (now - (unsigned long)tmCPUStart) |
---|
| 391 | / (double)CLOCKS_PER_SEC; |
---|
| 392 | if (now < tmCPUStart) |
---|
| 393 | tmCPU += CLOCK_T_WRAP / (double)CLOCKS_PER_SEC; |
---|
| 394 | if (tmUser >= tmCPU + CLOCK_T_WRAP / (double)CLOCKS_PER_SEC) |
---|
| 395 | tmCPU = 0; |
---|
[647407d] | 396 | |
---|
[faf71d1] | 397 | /* tmUser is integer, tmCPU not - equivalent to (ceil(tmCPU) >= tmUser) */ |
---|
[647407d] | 398 | if (tmCPU + 1 > tmUser) { |
---|
[421b7d2] | 399 | printf(msg(/*CPU time used %5.2fs*/140), tmCPU); |
---|
[647407d] | 400 | } else if (tmCPU == 0) { |
---|
[faf71d1] | 401 | if (tmUser != 0.0) { |
---|
[421b7d2] | 402 | printf(msg(/*Time used %5.2fs*/141), tmUser); |
---|
[647407d] | 403 | } else { |
---|
[421b7d2] | 404 | fputs(msg(/*Time used unavailable*/142), stdout); |
---|
[647407d] | 405 | } |
---|
[bb90203] | 406 | } else { |
---|
[5b68ae1] | 407 | printf(msg(/*Time used %5.2fs (%5.2fs CPU time)*/143), tmUser, tmCPU); |
---|
[bb90203] | 408 | } |
---|
[5b68ae1] | 409 | putnl(); |
---|
[bb90203] | 410 | |
---|
[5b68ae1] | 411 | puts(msg(/*Done.*/144)); |
---|
[647407d] | 412 | } |
---|
[25ab06b] | 413 | if (msg_warnings || msg_errors) { |
---|
[7ebee5b] | 414 | if (msg_errors || (f_warnings_are_errors && msg_warnings)) { |
---|
| 415 | printf(msg(/*There were %d warning(s) and %d non-fatal error(s) - no output files produced.*/113), |
---|
| 416 | msg_warnings, msg_errors); |
---|
| 417 | putnl(); |
---|
| 418 | return EXIT_FAILURE; |
---|
| 419 | } |
---|
| 420 | printf(msg(/*There were %d warning(s).*/16), msg_warnings); |
---|
[25ab06b] | 421 | putnl(); |
---|
| 422 | } |
---|
[bb9d869] | 423 | return EXIT_SUCCESS; |
---|
[bb90203] | 424 | } |
---|
| 425 | |
---|
| 426 | static void |
---|
[2b6eca8] | 427 | do_range(int d, int msg1, int msg2, int msg3) |
---|
[bb90203] | 428 | { |
---|
[2b6eca8] | 429 | printf(msg(msg1), max[d] - min[d]); |
---|
| 430 | fprint_prefix(stdout, pfxHi[d]); |
---|
| 431 | printf(msg(msg2), max[d]); |
---|
| 432 | fprint_prefix(stdout, pfxLo[d]); |
---|
| 433 | printf(msg(msg3), min[d]); |
---|
| 434 | putnl(); |
---|
[bb90203] | 435 | } |
---|
| 436 | |
---|
| 437 | static void |
---|
[06a871f] | 438 | do_stats(void) |
---|
[bb90203] | 439 | { |
---|
| 440 | long cLoops = cComponents + cLegs - cStns; |
---|
| 441 | |
---|
[2b6eca8] | 442 | putnl(); |
---|
[bb90203] | 443 | |
---|
[a63fdd2a] | 444 | if (cStns == 1) { |
---|
[2b6eca8] | 445 | fputs(msg(/*Survey contains 1 survey station,*/172), stdout); |
---|
[a63fdd2a] | 446 | } else { |
---|
[2b6eca8] | 447 | printf(msg(/*Survey contains %ld survey stations,*/173), cStns); |
---|
[a63fdd2a] | 448 | } |
---|
[bb90203] | 449 | |
---|
[a63fdd2a] | 450 | if (cLegs == 1) { |
---|
[2b6eca8] | 451 | fputs(msg(/* joined by 1 leg.*/174), stdout); |
---|
[a63fdd2a] | 452 | } else { |
---|
[2b6eca8] | 453 | printf(msg(/* joined by %ld legs.*/175), cLegs); |
---|
[a63fdd2a] | 454 | } |
---|
[bb90203] | 455 | |
---|
[2b6eca8] | 456 | putnl(); |
---|
[bb90203] | 457 | |
---|
[a63fdd2a] | 458 | if (cLoops == 1) { |
---|
[2b6eca8] | 459 | fputs(msg(/*There is 1 loop.*/138), stdout); |
---|
[a63fdd2a] | 460 | } else { |
---|
[2b6eca8] | 461 | printf(msg(/*There are %ld loops.*/139), cLoops); |
---|
[a63fdd2a] | 462 | } |
---|
[bb90203] | 463 | |
---|
[2b6eca8] | 464 | putnl(); |
---|
[bb90203] | 465 | |
---|
| 466 | if (cComponents != 1) { |
---|
[2b6eca8] | 467 | printf(msg(/*Survey has %ld connected components.*/178), cComponents); |
---|
[a63fdd2a] | 468 | putnl(); |
---|
| 469 | } |
---|
[bb90203] | 470 | |
---|
[2b6eca8] | 471 | printf(msg(/*Total length of survey legs = %7.2fm (%7.2fm adjusted)*/132), |
---|
| 472 | total, totadj); |
---|
| 473 | putnl(); |
---|
| 474 | printf(msg(/*Total plan length of survey legs = %7.2fm*/133), |
---|
| 475 | totplan); |
---|
| 476 | putnl(); |
---|
| 477 | printf(msg(/*Total vertical length of survey legs = %7.2fm*/134), |
---|
| 478 | totvert); |
---|
| 479 | putnl(); |
---|
| 480 | |
---|
[4ae2ea4] | 481 | /* If there's no underground survey, we've no ranges */ |
---|
| 482 | if (pfxHi[0]) { |
---|
| 483 | do_range(2, /*Vertical range = %4.2fm (from */135, |
---|
| 484 | /* at %4.2fm to */136, /* at %4.2fm)*/137); |
---|
| 485 | do_range(1, /*North-South range = %4.2fm (from */148, |
---|
| 486 | /* at %4.2fm to */196, /* at %4.2fm)*/197); |
---|
| 487 | do_range(0, /*East-West range = %4.2fm (from */149, |
---|
| 488 | /* at %4.2fm to */196, /* at %4.2fm)*/197); |
---|
| 489 | } |
---|
[bb90203] | 490 | |
---|
[2b6eca8] | 491 | print_node_stats(); |
---|
[bb90203] | 492 | /* Also, could give: |
---|
| 493 | * # nodes stations (ie have other than two references or are fixed) |
---|
| 494 | * # fixed stations (list of?) |
---|
| 495 | */ |
---|
| 496 | } |
---|