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 |
#include "sm_qtree.h" |
11 |
|
12 |
#define SQRT3_INV 0.5773502692 |
13 |
|
14 |
|
15 |
typedef struct _STREE { |
16 |
QUADTREE root; /* quadtree triangulation of sphere */ |
17 |
FVECT center; /* sphere center */ |
18 |
FVECT base[4]; /* 4 vertices on sphere that define base triangulation |
19 |
of 4 triangles: assume cover sphere and triangles |
20 |
are base verts (0,1,2),(0,2,3),(0,3,1), and (1,3,2) |
21 |
*/ |
22 |
}STREE; |
23 |
|
24 |
#define ST_ROOT(s) ((s)->root) |
25 |
#define ST_ROOT_PTR(s) (&(s)->root) |
26 |
#define ST_NTH_ROOT(s,n) QT_NTH_CHILD(ST_ROOT(s),n) |
27 |
#define ST_NTH_ROOT_PTR(s,n) QT_NTH_CHILD_PTR(ST_ROOT(s),n) |
28 |
#define ST_CLEAR_ROOT(s) QT_CLEAR_CHILDREN(ST_ROOT(s)) |
29 |
|
30 |
#define ST_CENTER(s) ((s)->center) |
31 |
#define ST_SET_CENTER(s,b) VCOPY(ST_CENTER(s),b) |
32 |
#define ST_BASE(s) ((s)->base) |
33 |
#define ST_NTH_BASE(s,n) ((s)->base[(n)]) |
34 |
#define ST_SET_NTH_BASE(s,n,b) VCOPY(ST_NTH_BASE(s,n),b) |
35 |
#define ST_SET_BASE(s,b) (VCOPY(ST_NTH_BASE(s,0),(b)[0]), \ |
36 |
VCOPY(ST_NTH_BASE(s,1),(b)[1]), \ |
37 |
VCOPY(ST_NTH_BASE(s,2),(b)[2]), \ |
38 |
VCOPY(ST_NTH_BASE(s,3),(b)[3])) |
39 |
#define ST_COORD(s,p,r) VSUB(r,p,ST_CENTER(s)) |
40 |
#define ST_CLEAR_FLAGS(s) qtClearAllFlags() |
41 |
/* STREE functions |
42 |
|
43 |
|
44 |
STREE *stInit(STREE *st) |
45 |
Initialize STREE: if st = NULL, allocate a new one, else clear |
46 |
return pointer to initialized structure |
47 |
|
48 |
QUADTREE *stPoint_locate(STREE *st,FVECT pt) |
49 |
Find stree node that projection of pt on sphere falls in |
50 |
|
51 |
stInsert_tri() |
52 |
for every quadtree tri in the base- find node all leaf nodes that |
53 |
tri overlaps and add tri to set. If this causes any of the nodes |
54 |
to be over threshhold- split |
55 |
stDelete_tri() |
56 |
for every quadtree tri in the base- find node all leaf nodes that |
57 |
tri overlaps. If this causes any of the nodes to be under |
58 |
threshold- merge |
59 |
*/ |
60 |
extern int stTri_verts[4][3]; |
61 |
extern int stTri_nbrs[4][3]; |
62 |
extern FVECT stDefault_base[4]; |
63 |
|
64 |
|
65 |
extern STREE *stAlloc(); |
66 |
extern QUADTREE *stPoint_locate_cell(); |
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|