source: git/src/dump3d.c @ 5a9b8cc

RELEASE/1.0RELEASE/1.1RELEASE/1.2debug-cidebug-ci-sanitisersfaster-cavernloglog-selectstereostereo-2025walls-datawalls-data-hanging-as-warningwarn-only-for-hanging-survey
Last change on this file since 5a9b8cc was 984f49e, checked in by Olly Betts <olly@…>, 23 years ago

survey restriction now works on .plt files.

added --enable-testprogs option to configure.

git-svn-id: file:///home/survex-svn/survex/trunk@1753 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[02da880]1/* dump3d.c */
2/* Show raw contents of .3d file in text form */
[984f49e]3/* Copyright (C) 2001,2002 Olly Betts
[02da880]4 *
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.
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
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
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
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 */
19
20#ifdef HAVE_CONFIG_H
21# include <config.h>
22#endif
23
24#include <stdio.h>
25#include <stdlib.h>
26#include <string.h>
27#include <math.h>
28
29#include "cmdline.h"
30#include "debug.h"
31#include "filelist.h"
32#include "img.h"
33
34static const struct option long_opts[] = {
35   /* const char *name; int has_arg (0 no_argument, 1 required_*, 2 optional_*); int *flag; int val; */
36   {"survey", required_argument, 0, 's'},
37   {"help", no_argument, 0, HLP_HELP},
38   {"version", no_argument, 0, HLP_VERSION},
39   {0, 0, 0, 0}
40};
41
42#define short_opts "s:"
43
44static struct help_msg help[] = {
45/*                              <-- */
[e4138b5]46   {HLP_ENCODELONG(0),          "only load the sub-survey with this prefix"},
[02da880]47   {0, 0}
48};
49
50int
51main(int argc, char **argv)
52{
53   char *fnm;
54   img *pimg;
55   img_point pt;
56   int code;
57   const char *survey = NULL;
58
[bdfe97f]59   msg_init(argv);
[02da880]60
61   cmdline_init(argc, argv, short_opts, long_opts, NULL, help, 1, 1);
62   while (1) {
63      int opt = cmdline_getopt();
64      if (opt == EOF) break;
65      if (opt == 's') survey = optarg;
66   }
67   fnm = argv[optind];
68
69#if 0
70   pimg = img_open_write("dump3d.3d", "dump3d", fTrue);
71   if (!pimg) fatalerror(img_error(), "dump3d.3d");
72   img_write_item(pimg, img_MOVE, 0, NULL, 0, 0, 0);
73   img_write_item(pimg, img_LINE, 0, "161.lostworld.upstream",
74                  36920.120000, 82672.840000, 1528.820000);
75   img_write_item(pimg, img_LINE, 0, "161.keinzimmer",
76                  36918.480000, 82663.360000, 1527.670000);
77   img_write_item(pimg, img_LINE, 0, "161.lostworld.upstream",
78                  36959.760000, 82679.880000, 1537.900000);
79   img_close(pimg);
80#endif
81
[a2ad284]82   pimg = img_open_survey(fnm, survey);
[02da880]83   if (!pimg) fatalerror(img_error(), fnm);
[984f49e]84   printf("TITLE \"%s\"\n", pimg->title);
85   printf("DATE \"%s\"\n", pimg->datestamp);
86   printf("VERSION %d\n", pimg->version);   
87   printf("--\n");
[02da880]88
89   do {
90      code = img_read_item(pimg, &pt);
91      switch (code) {
92       case img_MOVE:
93         printf("MOVE %f %f %f\n", pt.x, pt.y, pt.z);
94         break;
95       case img_LINE:
96         printf("LINE %f %f %f [%s]\n", pt.x, pt.y, pt.z, pimg->label);
97         break;
98       case img_LABEL:
99         printf("NODE %f %f %f [%s]\n", pt.x, pt.y, pt.z, pimg->label);
100         break;
101       case img_BAD:
102         img_close(pimg);
[b8720f8]103         fatalerror(img_error(), fnm);
[02da880]104      }
105   } while (code != img_STOP);
[421b7d2]106
[02da880]107   img_close(pimg);
108
109   return 0;
110}
Note: See TracBrowser for help on using the repository browser.