ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/octree.h
Revision: 2.7
Committed: Fri Mar 14 21:27:46 2003 UTC (21 years, 1 month ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.6: +5 -1 lines
Log Message:
Added -a option to obj2mesh to incorporate materials in mesh

File Contents

# User Rev Content
1 greg 2.6 /* RCSid $Id$ */
2 greg 1.1 /*
3     * octree.h - header file for routines using octrees.
4 greg 2.5 */
5    
6 greg 2.6 #include "copyright.h"
7 greg 1.1
8     /*
9     * An octree is expressed as an integer which is either
10     * an index to eight other nodes, the empty tree, or an index
11     * to a set of objects. If the octree has a value:
12     *
13     * > -1: it is an index to eight other nodes.
14     *
15     * -1: it is empty
16     *
17     * < -1: it is an index to a set of objects
18     */
19    
20 greg 1.5 #ifndef OCTREE
21     #define OCTREE int
22     #endif
23 greg 1.1
24     #define EMPTY (-1)
25    
26     #define isempty(ot) ((ot) == EMPTY)
27     #define isfull(ot) ((ot) < EMPTY)
28     #define istree(ot) ((ot) > EMPTY)
29    
30     #define oseti(ot) (-(ot)-2) /* object set index */
31 gwlarson 2.4 #define OCTBLKSIZ 04000 /* octree block size */
32     #define octbi(ot) ((ot)>>11) /* octree block index */
33     #define octti(ot) (((ot)&03777)<<3)/* octree index in block */
34 greg 1.1
35 greg 1.5 #ifndef MAXOBLK
36     #ifdef BIGMEM
37 gwlarson 2.4 #define MAXOBLK 32767 /* maximum octree block */
38 greg 1.5 #else
39 gwlarson 2.4 #define MAXOBLK 4095 /* maximum octree block */
40 greg 1.5 #endif
41     #endif
42 greg 1.1
43     extern OCTREE *octblock[MAXOBLK]; /* octree blocks */
44    
45     #define octkid(ot,br) (octblock[octbi(ot)][octti(ot)+br])
46    
47     /*
48     * The cube structure is used to hold an octree and its cubic
49     * boundaries.
50     */
51    
52     typedef struct {
53     OCTREE cutree; /* the octree for this cube */
54     FVECT cuorg; /* the cube origin */
55     double cusize; /* the cube size */
56     } CUBE;
57    
58     extern CUBE thescene; /* the main scene */
59    
60     /* flags for reading and writing octrees */
61     #define IO_CHECK 0 /* verify file type */
62     #define IO_INFO 01 /* information header */
63     #define IO_SCENE 02 /* objects */
64     #define IO_TREE 04 /* octree */
65     #define IO_FILES 010 /* object file names */
66     #define IO_BOUNDS 020 /* octree boundary */
67     #define IO_ALL (~0) /* everything */
68 greg 1.4 /* octree format identifier */
69     #define OCTFMT "Radiance_octree"
70 greg 1.1 /* magic number for octree files */
71 greg 1.5 #define MAXOBJSIZ 8 /* maximum sizeof(OBJECT) */
72     #define OCTMAGIC ( 4 *MAXOBJSIZ+251) /* increment first value */
73 greg 1.1 /* octree node types */
74     #define OT_EMPTY 0
75     #define OT_FULL 1
76     #define OT_TREE 2
77 greg 1.2 /* return values for surface functions */
78     #define O_MISS 0 /* no intersection */
79     #define O_HIT 1 /* intersection */
80     #define O_IN 2 /* cube contained entirely */
81 greg 2.5
82     #ifdef NOPROTO
83    
84     extern OCTREE octalloc();
85     extern void octfree();
86     extern void octdone();
87     extern OCTREE combine();
88     extern void culocate();
89     extern void cucopy();
90     extern int incube();
91     extern int readoct();
92 greg 2.7 extern void readscene();
93     extern void writescene();
94 greg 2.5
95     #else
96    
97     extern OCTREE octalloc(void);
98     extern void octfree(OCTREE ot);
99     extern void octdone(void);
100     extern OCTREE combine(OCTREE ot);
101     extern void culocate(CUBE *cu, FVECT pt);
102     extern void cucopy(CUBE *cu1, CUBE *cu2);
103     extern int incube(CUBE *cu, FVECT pt);
104    
105     extern int readoct(char *fname, int load, CUBE *scene, char *ofn[]);
106 greg 2.7
107     extern void readscene(FILE *fp, int objsiz);
108     extern void writescene(int firstobj, int nobjs, FILE *fp);
109 greg 2.5
110     #endif