ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/holo.h
Revision: 3.23
Committed: Mon Jul 14 22:24:00 2003 UTC (20 years, 9 months ago) by schorsch
Content type: text/plain
Branch: MAIN
Changes since 3.22: +14 -1 lines
Log Message:
Instrumented headers against multiple inclusion and for use from C++.
Moved includes in headers out of "C" scope.

File Contents

# User Rev Content
1 schorsch 3.23 /* RCSid: $Id: holo.h,v 3.22 2003/06/20 00:25:49 greg Exp $ */
2 gregl 3.1 /*
3     * Header file for holodeck programs
4     *
5     * 9/29/97 GWLarson
6     */
7 schorsch 3.23 #ifndef _RAD_HOLO_H_
8     #define _RAD_HOLO_H_
9 gregl 3.1
10     #include "standard.h"
11     #include "color.h"
12    
13 schorsch 3.23 #ifdef __cplusplus
14     extern "C" {
15     #endif
16    
17 gregl 3.1 #ifndef HDMAX
18     #define HDMAX 128 /* maximum active holodeck sections */
19     #endif
20    
21 gwlarson 3.17 #ifndef MAXDIRSE
22     #define MAXDIRSE 32 /* maximum seeks per directory write */
23     #endif
24    
25 gregl 3.1 #define DCINF (unsigned)((1L<<16)-1) /* special value for infinity */
26     #define DCLIN (unsigned)(1L<<11) /* linear depth limit */
27    
28     typedef struct {
29     BYTE r[2][2]; /* ray direction index */
30 gwlarson 3.15 COLR v; /* color value */
31 greg 3.22 uint16 d; /* depth code (from entry wall) */
32 gwlarson 3.15 } RAYVAL; /* ray value */
33 gregl 3.1
34     /*
35     * Walls are ordered: X0 X1 X2 WN
36     * 0 ? ? 0
37     * 1 ? ? 1
38     * ? 0 ? 2
39     * ? 1 ? 3
40     * ? ? 0 4
41     * ? ? 1 5
42     *
43     * Grid on wall WN corresponds to X(WN/2+1)%3 and X(WN/2+2)%3, resp.
44     */
45    
46     typedef struct {
47     short w; /* wall number */
48     short i[2]; /* index on wall grid */
49 gregl 3.2 } GCOORD; /* grid coordinates (two for beam) */
50 gregl 3.1
51     typedef struct {
52 greg 3.22 uint32 nrd; /* number of beam rays bundled on disk */
53 greg 3.21 off_t fo; /* position in file */
54 gregl 3.1 } BEAMI; /* beam index */
55    
56     typedef struct {
57 greg 3.22 uint32 nrm; /* number of beam rays bundled in memory */
58 gregl 3.1 unsigned long tick; /* clock tick for LRU replacement */
59     } BEAM; /* followed by nrm RAYVAL's */
60    
61 gregl 3.3 #define hdbray(bp) ((RAYVAL *)((bp)+1))
62 gregl 3.1 #define hdbsiz(nr) (sizeof(BEAM)+(nr)*sizeof(RAYVAL))
63    
64     typedef struct {
65     FVECT orig; /* prism origin (first) */
66     FVECT xv[3]; /* side vectors (second) */
67 greg 3.22 int16 grid[3]; /* grid resolution (third) */
68 gregl 3.1 } HDGRID; /* holodeck section grid (must match HOLO struct) */
69    
70     typedef struct holo {
71     FVECT orig; /* prism origin (first) */
72     FVECT xv[3]; /* side vectors (second) */
73 greg 3.22 int16 grid[3]; /* grid resolution (third) */
74 gregl 3.1 int fd; /* file descriptor */
75 gwlarson 3.17 struct {
76     int s, n; /* dirty section start, length */
77     } dirseg[MAXDIRSE+1]; /* dirty beam index segments */
78     short dirty; /* number of dirty segments */
79 gregl 3.1 double tlin; /* linear range for depth encoding */
80 gregl 3.13 FVECT wg[3]; /* wall grid vectors (derived) */
81 gregl 3.1 int wi[6]; /* wall super-indices (derived) */
82     char *priv; /* pointer to private client data */
83     BEAM **bl; /* beam pointers (memory cache) */
84     BEAMI bi[1]; /* beam index (extends struct) */
85     } HOLO; /* holodeck section */
86    
87 gregl 3.9 typedef struct {
88     HOLO *h; /* pointer to holodeck */
89     int b; /* beam index */
90     } HDBEAMI; /* holodeck beam index */
91    
92 gregl 3.14 #define nbeams(hp) (((hp)->wi[5]-1)<<1)
93 gregl 3.1 #define biglob(hp) ((hp)->bi)
94     #define blglob(hp) (*(hp)->bl)
95    
96     #define bnrays(hp,i) ((hp)->bl[i]!=NULL ? (hp)->bl[i]->nrm : (hp)->bi[i].nrd)
97    
98 gwlarson 3.16 #define hdflush(hp) (hdfreebeam(hp,0), hdsync(hp,0))
99     #define hdclobber(hp) (hdkillbeam(hp,0), hdsync(hp,0))
100 gregl 3.1
101 gregl 3.4 extern HOLO *hdinit(), *hdalloc();
102 gregl 3.1 extern BEAM *hdgetbeam();
103     extern RAYVAL *hdnewrays();
104 gregl 3.9 extern unsigned hdmemuse();
105 greg 3.21 extern off_t hdfiluse(), hdfilen(), hdallocfrag();
106 gregl 3.1 extern double hdray(), hdinter();
107     extern unsigned hdcode();
108 gregl 3.14 extern int hdfilord();
109 gregl 3.1
110 gwlarson 3.19 #define FF_NEVER 0 /* never free fragments */
111     #define FF_WRITE 01 /* free fragment on write */
112     #define FF_ALLOC 02 /* free fragment on ray alloc */
113     #define FF_READ 04 /* free fragment on read */
114     #define FF_KILL 010 /* free fragment on beam kill */
115    
116     extern int hdfragflags; /* tells when to free fragments */
117 gregl 3.9 extern unsigned hdcachesize; /* target cache size (bytes) */
118 gregl 3.1 extern unsigned long hdclock; /* holodeck system clock */
119     extern HOLO *hdlist[HDMAX+1]; /* holodeck pointers (NULL term.) */
120    
121     extern float hd_depthmap[]; /* depth conversion map */
122 gregl 3.13
123     extern int hdwg0[6]; /* wall grid 0 index */
124     extern int hdwg1[6]; /* wall grid 1 index */
125 gregl 3.1
126     #define hddepth(hp,dc) ( (dc) >= DCINF ? FHUGE : \
127     (hp)->tlin * ( (dc) >= DCLIN ? \
128     hd_depthmap[(dc)-DCLIN] : \
129     ((dc)+.5)/DCLIN ) )
130    
131     #define HOLOFMT "Holodeck" /* file format identifier */
132     #define HOLOVERS 0 /* file format version number */
133 greg 3.21 #define HOLOMAGIC (323+sizeof(off_t)+8*HOLOVERS) /* file magic number */
134 gregl 3.1
135     /*
136     * A holodeck file consists of an information header terminated by a
137     * blank line, with "FORMAT=Holodeck" somewhere in it.
138     * The first integer after the information header is the
139     * above magic number, which includes the file format version number.
140 gregl 3.6 * The first longword after the magic number is a pointer to the pointer
141     * just before the SECOND holodeck section, or 0 if there is only one.
142 gregl 3.1 * This longword is immediately followed by the first holodeck
143     * section header and directory.
144     * Similarly, every holodeck section in the file is preceeded by
145     * a pointer to the following section, or 0 for the final section.
146     * Since holodeck files consist of directly written C data structures,
147     * they are not generally portable between different machine architectures.
148     * In particular, different floating point formats or bit/byte ordering
149     * will make the data unusable. This is unfortunate, and may be changed
150     * in future versions, but we thought this would be best for paging speed
151     * in our initial implementation.
152     */
153 schorsch 3.23
154    
155     #ifdef __cplusplus
156     }
157     #endif
158     #endif /* _RAD_HOLO_H_ */
159