source: git/src/img.h @ ab5d6a5

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

Fixed scaling when reading PLT files.

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

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/* img.h
2 * Header file for routines to read and write Survex ".3d" image files
3 * Copyright (C) Olly Betts 1993,1994,1997,2001,2002
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#ifndef IMG_H
21# define IMG_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#include <stdio.h>
28
29# ifdef IMG_HOSTED
30#  include "useful.h"
31# endif
32
33# define img_BAD   -2
34# define img_STOP  -1
35# define img_MOVE   0
36# define img_LINE   1
37/* NB: img_CROSS is never output and ignored on input.
38 * Put crosses where labels are. */
39/* # define img_CROSS  2 */
40# define img_LABEL  3
41
42# define img_FLAG_SURFACE   0x01
43# define img_FLAG_DUPLICATE 0x02
44# define img_FLAG_SPLAY     0x04
45
46# define img_SFLAG_SURFACE     0x01
47# define img_SFLAG_UNDERGROUND 0x02
48# define img_SFLAG_ENTRANCE    0x04
49# define img_SFLAG_EXPORTED    0x08
50# define img_SFLAG_FIXED       0x10
51
52/* 3D c3D c3D crdinates (in metres) */
53typedef struct {
54   double x, y, z;
55} img_point;
56
57typedef struct {
58   /* members you can access when reading (don't touch when writing) */
59   char *label;
60   int flags;
61   char *title;
62   char *datestamp;
63   /* all other members are for internal use only */
64   FILE *fh;          /* file handle of image file */
65   char *label_buf;
66   size_t buf_len;
67   size_t label_len;
68# ifdef IMG_HOSTED
69   bool fRead;        /* fTrue for reading, fFalse for writing */
70# else
71   int fRead;        /* fTrue for reading, fFalse for writing */
72# endif
73   long start;
74   /* version of file format:
75    *  -4 => CMAP .xyz file, shot format
76    *  -3 => CMAP .xyz file, station format
77    *  -2 => Compass .plt file
78    *  -1 => .pos file
79    *   0 => 0.01 ascii
80    *   1 => 0.01 binary,
81    *   2 => byte actions and flags
82    *   3 => prefixes for legs; compressed prefixes
83    */
84   int version;
85   char *survey;
86   size_t survey_len;
87   int pending; /* for old style text format files and survey filtering */
88   img_point mv;
89} img;
90
91/* Which version of the file format to output (defaults to newest) */
92extern unsigned int img_output_version;
93
94/* Open a .3d file for reading
95 * fnm is the filename
96 * Returns pointer to an img struct or NULL
97 */
98#define img_open(F) img_open_survey((F), NULL)
99
100/* Open a .3d file for reading
101 * fnm is the filename
102 * Returns pointer to an img struct or NULL
103 * survey points to a survey name to restrict reading to (or NULL for all
104 * survey data in the file)
105 */
106img *img_open_survey(const char *fnm, const char *survey);
107
108/* Open a .3d file for output
109 * fnm is the filename
110 * title_buf is the title
111 * fBinary == 0 for ASCII .3d file
112 *         != 0 for binary .3d file
113 * NB only the original .3d file format has an ASCII variant
114 * Returns pointer to an img struct or NULL for error (check img_error()
115 * for details)
116 */
117# ifdef IMG_HOSTED
118img *img_open_write(const char *fnm, char *title_buf, bool fBinary);
119# else
120img *img_open_write(const char *fnm, char *title_buf, int fBinary);
121# endif
122
123/* Read an item from a .3d file
124 * pimg is a pointer to an img struct returned by img_open()
125 * coordinates are returned in p
126 * flags and label name are returned in fields in pimg
127 * Returns img_XXXX as #define-d above
128 */
129int img_read_item(img *pimg, img_point *p);
130
131/* Write a item to a .3d file
132 * pimg is a pointer to an img struct returned by img_open_write()
133 * code is one of the img_XXXX #define-d above
134 * flags is the leg or station flags (meaningful for img_LINE and img_LABEL
135 * s is the label (only meaningful for img_LABEL)
136 * x, y, z are the coordinates
137 */
138void img_write_item(img *pimg, int code, int flags, const char *s,
139                    double x, double y, double z);
140
141/* rewind a .3d file opened for reading so the data can be read in
142 * several passes
143 * pimg is a pointer to an img struct returned by img_open()
144 * Returns: non-zero for success, zero for error (check img_error() for
145 *   details)
146 */
147int img_rewind(img *pimg);
148
149/* Close a .3d file
150 * pimg is a pointer to an img struct returned by img_open() or
151 *   img_open_write()
152 * Returns: non-zero for success, zero for error (check img_error() for
153 *   details)
154 */
155int img_close(img *pimg);
156
157/* Codes returned by img_error */
158# ifndef IMG_HOSTED
159typedef enum {
160   IMG_NONE = 0, IMG_FILENOTFOUND, IMG_OUTOFMEMORY,
161   IMG_CANTOPENOUT, IMG_BADFORMAT, IMG_DIRECTORY,
162   IMG_READERROR, IMG_WRITEERROR, IMG_TOONEW
163} img_errcode;
164
165/* Read the error code
166 * if img_open() or img_open_write() returns NULL, you can call this
167 * to discover why */
168img_errcode img_error(void);
169# else
170int img_error(void);
171# endif
172
173#ifdef __cplusplus
174}
175#endif
176
177#endif
Note: See TracBrowser for help on using the repository browser.