source: git/src/img.h @ df590e5b

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 df590e5b was 9f9c05e, checked in by Olly Betts <olly@…>, 23 years ago

Improved handling of Compass PLT files and CMAP xyz files - no longer change
dots to spaces in survey and station names - instead use a space as the
separator between survey name and station name.

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

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