ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_stree.h
Revision: 3.6
Committed: Sat Feb 22 02:07:25 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 3.5: +1 -4 lines
Log Message:
Changes and check-in for 3.5 release
Includes new source files and modifications not recorded for many years
See ray/doc/notes/ReleaseNotes for notes between 3.1 and 3.5 release

File Contents

# Content
1 /* RCSid: $Id$ */
2 /*
3 * sm_stree.h - header file for spherical quadtree code:
4 *
5 */
6
7 #define STR_INDEX(s) (stRoot_indices[(s)])
8 #define STR_NTH_INDEX(s,n) (stRoot_indices[(s)][(n)])
9
10 #define ST_NUM_ROOT_NODES 8
11
12
13
14 /* The base is an octahedron: Each face contains a planar quadtree. At
15 the root level, the "top" (positive y) four faces, and bottom four faces
16 are stored together:forming two root quadtree nodes
17 */
18
19 typedef struct _STREE {
20 QUADTREE qt[2]; /* root[0]= top four faces, root[1]=bottom 4 faces*/
21
22 }STREE;
23
24
25 #define ST_BASEI(n) ((n)>>2) /* root index: top or bottom */
26 #define ST_INDEX(n) ((n) & 0x3) /* which child in root */
27 #define ST_QT(s,i) ((s)->qt[ST_BASEI(i)]) /* top or bottom root*/
28 #define ST_QT_PTR(s,i) (&ST_QT(s,i)) /* ptr to top(0)/bottom(1)root*/
29 #define ST_TOP_QT(s) ((s)->qt[0]) /* top root (y>0)*/
30 #define ST_BOTTOM_QT(s) ((s)->qt[1]) /* bottom qt (y <= 0)*/
31 #define ST_TOP_QT_PTR(s) (&ST_TOP_QT(s)) /* ptr to top qt */
32 #define ST_BOTTOM_QT_PTR(s) (&ST_BOTTOM_QT(s)) /* ptr to bottom qt*/
33
34 #define ST_NTH_V(s,n,w) (stDefault_base[stBase_verts[n][w]])
35 #define ST_ROOT_QT(s,n) QT_NTH_CHILD(ST_QT(s,n),ST_INDEX(n))
36
37 #define ST_CLEAR_QT(st) (ST_TOP_QT(st)=EMPTY,ST_BOTTOM_QT(st)=EMPTY)
38 #define ST_INIT_QT(st) (QT_CLEAR_CHILDREN(ST_TOP_QT(st)), \
39 QT_CLEAR_CHILDREN(ST_BOTTOM_QT(st)))
40
41 #define ST_CLEAR_FLAGS(s) qtClearAllFlags()
42
43 /* Point location based on coordinate signs */
44 #define stLocate_root(p) (((p)[2]>0.0?0:4)|((p)[1]>0.0?0:2)|((p)[0]>0.0?0:1))
45 #define stClear(st) stInit(st)
46
47 #define ST_CLIP_VERTS 16
48 /* STREE functions
49 void stInit(STREE *st,FVECT center)
50 Initializes an stree structure with origin 'center':
51 Frees existing quadtrees hanging off of the roots
52
53 STREE *stAlloc(STREE *st)
54 Allocates a stree structure and creates octahedron base
55
56
57 QUADTREE stPoint_locate(STREE *st,FVECT p)
58 Returns quadtree leaf node containing point 'p'.
59
60 int stAdd_tri(STREE *st,int id,FVECT t0,t1,t2)
61 Add triangle 'id' with coordinates 't0,t1,t2' to the stree: returns
62 FALSE on error, TRUE otherwise
63
64 int stRemove_tri(STREE *st,int id,FVECT t0,t1,t2)
65 Removes triangle 'id' with coordinates 't0,t1,t2' from stree: returns
66 FALSE on error, TRUE otherwise
67
68 int stTrace_ray(STREE *st,FVECT orig,dir,int (*func)(),int *arg1,*arg2)
69 Trace ray 'orig-dir' through stree and apply 'func(arg1,arg2)' at each
70 node that it intersects
71
72 int stApply_to_tri(STREE *st,FVECT t0,t1,t2,int (*edge_func)(),
73 (*tri_func)(),int arg1,*arg2)
74 Visit nodes intersected by tri 't0,t1,t2'.Apply 'edge_func(arg1,arg2,arg3)',
75 to those nodes intersected by edges, and interior_func to ALL nodes:
76 ie some Nodes will be visited more than once
77 */
78
79 extern int stBase_verts[8][3];
80 extern FVECT stDefault_base[6];
81 extern STREE *stAlloc();
82 extern QUADTREE stPoint_locate();
83
84
85
86
87