source: git/src/img.h @ 7011db8

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 7011db8 was 0ff23cb, checked in by Olly Betts <olly@…>, 24 years ago

Trim of any prefix given by --survey.

Removed references to img_CROSS and commented it out in the header.

print*: reduced memory usage by storing a "label" with coordinates and
using it for crosses too, rather than storing separate cross and label
elements.

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

  • Property mode set to 100644
File size: 4.9 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
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
52typedef struct {
53   double x, y, z;
54} img_point;
55   
56typedef struct {
57   /* members you can access when reading (don't touch when writing) */
58   char *label;
59   int flags;
60   /* all other members are for internal use only */
61   FILE *fh;          /* file handle of image file */
62   char *label_buf;
63   size_t buf_len;
64   size_t label_len;
65# ifdef IMG_HOSTED
66   bool fRead;        /* fTrue for reading, fFalse for writing */
67# else
68   int fRead;        /* fTrue for reading, fFalse for writing */
69# endif
70   long start;
71   /* version of file format (0 => 0.01 ascii, 1 => 0.01 binary,
72    * 2 => byte actions and flags, 3 => prefixes for legs; compressed
73    * prefixes) */
74   int version;
75   char *survey;
76   size_t survey_len;
77   int pending; /* for old style text format files and survey filtering */
78   img_point mv;
79} img;
80
81/* Which version of the file format to output (defaults to newest) */
82extern unsigned int img_output_version;
83
84/* Open a .3d file for reading
85 * fnm is the filename
86 * title_buf and date_buf should be buffers to put the title and datestamp in
87 * (each of size 256 chars) or NULL if you don't want the information
88 * Returns pointer to an img struct or NULL
89 */
90#define img_open(F, T, D) img_open_survey((F), (T), (D), NULL)
91
92/* Open a .3d file for reading
93 * fnm is the filename
94 * title_buf and date_buf should be buffers to put the title and datestamp in
95 * (each of size 256 chars) or NULL if you don't want the information
96 * Returns pointer to an img struct or NULL
97 * survey points to a survey name to restrict reading to (or NULL for all
98 * survey data in the file)
99 */
100img *img_open_survey(const char *fnm, char *title_buf, char *date_buf,
101                     const char *survey);
102
103/* Open a .3d file for output
104 * fnm is the filename
105 * title_buf is the title
106 * fBinary == 0 for ASCII .3d file
107 *         != 0 for binary .3d file
108 * NB only the original .3d file format has an ASCII variant
109 * Returns pointer to an img struct or NULL
110 */
111# ifdef IMG_HOSTED
112img *img_open_write(const char *fnm, char *title_buf, bool fBinary);
113# else
114img *img_open_write(const char *fnm, char *title_buf, int fBinary);
115# endif
116
117/* Read an item from a .3d file
118 * pimg is a pointer to an img struct returned by img_open()
119 * coordinates are returned in p
120 * flags and label name are returned in fields in pimg
121 * Returns img_XXXX as #define-d above
122 */
123int img_read_item(img *pimg, img_point *p);
124
125/* Write a item to a .3d file
126 * pimg is a pointer to an img struct returned by img_open_write()
127 * code is one of the img_XXXX #define-d above
128 * flags is the leg or station flags (meaningful for img_LINE and img_LABEL
129 * s is the label (only meaningful for img_LABEL)
130 * x, y, z are the coordinates
131 */
132void img_write_item(img *pimg, int code, int flags, const char *s,
133                    double x, double y, double z);
134
135/* rewind a .3d file opened for reading so the data can be read in
136 * several passes
137 * pimg is a pointer to an img struct returned by img_open()
138 */
139void img_rewind(img *pimg);
140
141/* Close a .3d file
142 * pimg is a pointer to an img struct returned by img_open() or
143 *   img_open_write()
144 */
145void img_close(img *pimg);
146
147/* Codes returned by img_error */
148# ifndef IMG_HOSTED
149typedef enum {
150   IMG_NONE = 0, IMG_FILENOTFOUND, IMG_OUTOFMEMORY,
151   IMG_CANTOPENOUT, IMG_BADFORMAT, IMG_DIRECTORY
152} img_errcode;
153
154/* Read the error code
155 * if img_open() or img_open_write() returns NULL, you can call this
156 * to discover why */
157img_errcode img_error(void);
158# else
159int img_error(void);
160# endif
161
162#ifdef __cplusplus
163}
164#endif
165
166#endif
Note: See TracBrowser for help on using the repository browser.