1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
< |
|
3 |
< |
/* SCCSid "$SunId$ LBL" */ |
4 |
< |
|
1 |
> |
/* RCSid $Id$ */ |
2 |
|
/* |
3 |
|
* octree.h - header file for routines using octrees. |
7 |
– |
* |
8 |
– |
* 7/28/85 |
4 |
|
*/ |
5 |
+ |
#ifndef _RAD_OCTREE_H_ |
6 |
+ |
#define _RAD_OCTREE_H_ |
7 |
+ |
#ifdef __cplusplus |
8 |
+ |
extern "C" { |
9 |
+ |
#endif |
10 |
|
|
11 |
|
/* |
12 |
|
* An octree is expressed as an integer which is either |
20 |
|
* < -1: it is an index to a set of objects |
21 |
|
*/ |
22 |
|
|
23 |
< |
typedef int OCTREE; |
23 |
> |
#ifndef OCTREE |
24 |
> |
#define OCTREE int |
25 |
> |
#endif |
26 |
|
|
27 |
|
#define EMPTY (-1) |
28 |
|
|
31 |
|
#define istree(ot) ((ot) > EMPTY) |
32 |
|
|
33 |
|
#define oseti(ot) (-(ot)-2) /* object set index */ |
34 |
< |
#define octbi(ot) ((ot)>>8) /* octree block index */ |
35 |
< |
#define octti(ot) (((ot)&0377)<<3)/* octree index in block */ |
34 |
> |
#define OCTBLKSIZ 04000 /* octree block size */ |
35 |
> |
#define octbi(ot) ((ot)>>11) /* octree block index */ |
36 |
> |
#define octti(ot) (((ot)&03777)<<3)/* octree index in block */ |
37 |
|
|
38 |
+ |
#ifndef MAXOBLK |
39 |
+ |
#ifdef SMLMEM |
40 |
|
#define MAXOBLK 4095 /* maximum octree block */ |
41 |
+ |
#else |
42 |
+ |
#define MAXOBLK 262143 /* maximum octree block */ |
43 |
+ |
#endif |
44 |
+ |
#endif |
45 |
|
|
46 |
|
extern OCTREE *octblock[MAXOBLK]; /* octree blocks */ |
47 |
|
|
48 |
|
#define octkid(ot,br) (octblock[octbi(ot)][octti(ot)+br]) |
49 |
|
|
41 |
– |
extern OCTREE octalloc(), combine(), fullnode(); |
42 |
– |
|
50 |
|
/* |
51 |
|
* The cube structure is used to hold an octree and its cubic |
52 |
|
* boundaries. |
53 |
|
*/ |
54 |
|
|
55 |
|
typedef struct { |
49 |
– |
OCTREE cutree; /* the octree for this cube */ |
56 |
|
FVECT cuorg; /* the cube origin */ |
57 |
|
double cusize; /* the cube size */ |
58 |
+ |
OCTREE cutree; /* the octree for this cube */ |
59 |
|
} CUBE; |
60 |
|
|
61 |
|
extern CUBE thescene; /* the main scene */ |
68 |
|
#define IO_FILES 010 /* object file names */ |
69 |
|
#define IO_BOUNDS 020 /* octree boundary */ |
70 |
|
#define IO_ALL (~0) /* everything */ |
71 |
+ |
/* octree format identifier */ |
72 |
+ |
#define OCTFMT "Radiance_octree" |
73 |
|
/* magic number for octree files */ |
74 |
< |
#define OCTMAGIC (283+sizeof(OBJECT)) |
74 |
> |
#define MAXOBJSIZ 8 /* maximum sizeof(OBJECT) */ |
75 |
> |
#define OCTMAGIC ( 4 *MAXOBJSIZ+251) /* increment first value */ |
76 |
|
/* octree node types */ |
77 |
|
#define OT_EMPTY 0 |
78 |
|
#define OT_FULL 1 |
81 |
|
#define O_MISS 0 /* no intersection */ |
82 |
|
#define O_HIT 1 /* intersection */ |
83 |
|
#define O_IN 2 /* cube contained entirely */ |
84 |
+ |
|
85 |
+ |
|
86 |
+ |
extern OCTREE octalloc(void); |
87 |
+ |
extern void octfree(OCTREE ot); |
88 |
+ |
extern void octdone(void); |
89 |
+ |
extern OCTREE combine(OCTREE ot); |
90 |
+ |
extern void culocate(CUBE *cu, FVECT pt); |
91 |
+ |
extern int incube(CUBE *cu, FVECT pt); |
92 |
+ |
|
93 |
+ |
extern int readoct(char *fname, int load, CUBE *scene, char *ofn[]); |
94 |
+ |
|
95 |
+ |
extern void readscene(FILE *fp, int objsiz); |
96 |
+ |
extern void writescene(int firstobj, int nobjs, FILE *fp); |
97 |
+ |
|
98 |
+ |
|
99 |
+ |
#ifdef __cplusplus |
100 |
+ |
} |
101 |
+ |
#endif |
102 |
+ |
#endif /* _RAD_OCTREE_H_ */ |
103 |
+ |
|