ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/idmap.h
Revision: 2.1
Committed: Fri Jul 19 22:25:03 2019 UTC (4 years, 10 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Created rcode_ident file to create indexed identifier files

File Contents

# Content
1 /* RCSid $Id$ */
2 /*
3 * Definitions and delcarations for loading identifier maps
4 *
5 * Include after stdio.h
6 * Includes resolu.h
7 */
8
9 #ifndef _RAD_IDMAP_H_
10 #define _RAD_IDMAP_H_
11
12 #include "resolu.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 #define IDMAP8FMT "8-bit_indexed_name"
19 #define IDMAP16FMT "16-bit_indexed_name"
20 #define IDMAP24FMT "24-bit_indexed_name"
21 #define IDMAPFMT "*-bit_indexed_name"
22
23 #define HF_HEADOUT 0x2
24 #define HF_RESOUT 0x8
25
26 /* Structure for reading identifier maps */
27 typedef struct {
28 FILE *finp; /* input file pointer */
29 long dstart; /* start of data */
30 long curpos; /* current input position */
31 RESOLU res; /* input resolution */
32 int bytespi; /* 1, 2, or 3 bytes per index */
33 int nids; /* ID count */
34 int *idoffset; /* offsets to identifiers */
35 char idtable[1]; /* nul-terminated ID strings */
36 } IDMAP;
37
38 /* Get indexed ID */
39 #define mapID(mp,i) ( (i) >= (mp)->nids ? (char *)NULL : \
40 (mp)->idtable+(mp)->idoffset[i] )
41
42 /* Open ID map file for reading, copying info to stdout based on hflags */
43 extern IDMAP *idmap_ropen(const char *fname, int hflags);
44
45 /* Read the next ID from input */
46 extern const char *idmap_next(IDMAP *idmp);
47
48 /* Seek to a specific pixel position in ID map */
49 extern int idmap_seek(IDMAP *idmp, int x, int y);
50
51 /* Read ID at a pixel position */
52 extern const char *idmap_pix(IDMAP *idmp, int x, int y);
53
54 /* Close ID map and free resources */
55 extern void idmap_close(IDMAP *idmp);
56
57 #ifdef __cplusplus
58 }
59 #endif
60 #endif /* _RAD_IDMAP_H_ */