ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/sm_stree.h
Revision: 3.5
Committed: Thu Jun 10 15:22:24 1999 UTC (24 years, 10 months ago) by gwlarson
Content type: text/plain
Branch: MAIN
Changes since 3.4: +3 -36 lines
Log Message:
Implemented sample quadtree in place of triangle quadtree
Made geometric predicates more robust
Added #define LORES which utilizes a single precision floating point
  sample array, the default is a double sample array
Added topology DEBUG commands (for DEBUG > 1)
Made code optimizations

File Contents

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