| 19 |
|
#include "sm_qtree.h" |
| 20 |
|
#include "sm_stree.h" |
| 21 |
|
|
| 22 |
+ |
|
| 23 |
|
#ifdef TEST_DRIVER |
| 24 |
|
extern FVECT Pick_point[500],Pick_v0[500],Pick_v1[500],Pick_v2[500]; |
| 25 |
|
extern int Pick_cnt; |
| 64 |
|
{ |
| 65 |
|
int i,j; |
| 66 |
|
|
| 67 |
< |
ST_TOP_QT(st) = qtAlloc(); |
| 67 |
< |
ST_BOTTOM_QT(st) = qtAlloc(); |
| 68 |
< |
/* Clear the children */ |
| 67 |
> |
qtDone(); |
| 68 |
|
|
| 69 |
+ |
ST_TOP_QT(st) = qtAlloc(); |
| 70 |
+ |
ST_BOTTOM_QT(st) = qtAlloc(); |
| 71 |
+ |
/* Clear the children */ |
| 72 |
+ |
|
| 73 |
|
QT_CLEAR_CHILDREN(ST_TOP_QT(st)); |
| 74 |
|
QT_CLEAR_CHILDREN(ST_BOTTOM_QT(st)); |
| 75 |
|
} |
| 76 |
|
|
| 77 |
< |
/* Frees the children of the 2 quadtrees rooted at st, |
| 78 |
< |
Does not free root nodes: just clears |
| 76 |
< |
*/ |
| 77 |
< |
stClear(st) |
| 78 |
< |
STREE *st; |
| 77 |
> |
stFree(st) |
| 78 |
> |
STREE *st; |
| 79 |
|
{ |
| 80 |
< |
qtDone(); |
| 81 |
< |
stInit(st); |
| 80 |
> |
qtDone(); |
| 81 |
> |
free(st); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
/* Allocates a stree structure and creates octahedron base */ |
| 97 |
|
/* Allocate the top and bottom quadtree root nodes */ |
| 98 |
|
stInit(st); |
| 99 |
|
|
| 100 |
– |
|
| 101 |
– |
/* will go ********************************************/ |
| 102 |
– |
/* Set the octahedron base */ |
| 103 |
– |
ST_SET_BASE(st,stDefault_base); |
| 104 |
– |
|
| 105 |
– |
/* Calculate octahedron face and edge normals */ |
| 106 |
– |
for(i=0; i < ST_NUM_ROOT_NODES; i++) |
| 107 |
– |
{ |
| 108 |
– |
VCOPY(v0,ST_NTH_V(st,i,0)); |
| 109 |
– |
VCOPY(v1,ST_NTH_V(st,i,1)); |
| 110 |
– |
VCOPY(v2,ST_NTH_V(st,i,2)); |
| 111 |
– |
tri_plane_equation(v0,v1,v2, &ST_NTH_PLANE(st,i),FALSE); |
| 112 |
– |
m = max_index(FP_N(ST_NTH_PLANE(st,i)),NULL); |
| 113 |
– |
FP_X(ST_NTH_PLANE(st,i)) = (m+1)%3; |
| 114 |
– |
FP_Y(ST_NTH_PLANE(st,i)) = (m+2)%3; |
| 115 |
– |
FP_Z(ST_NTH_PLANE(st,i)) = m; |
| 116 |
– |
VCROSS(ST_EDGE_NORM(st,i,0),v0,v1); |
| 117 |
– |
VCROSS(ST_EDGE_NORM(st,i,1),v1,v2); |
| 118 |
– |
VCROSS(ST_EDGE_NORM(st,i,2),v2,v0); |
| 119 |
– |
} |
| 120 |
– |
|
| 121 |
– |
/*****************************************************************/ |
| 100 |
|
return(st); |
| 101 |
|
} |
| 102 |
|
|
| 723 |
|
} |
| 724 |
|
} |
| 725 |
|
|
| 726 |
+ |
stInsert_samp(st,p,f) |
| 727 |
+ |
STREE *st; |
| 728 |
+ |
FVECT p; |
| 729 |
+ |
FUNC f; |
| 730 |
+ |
{ |
| 731 |
+ |
|
| 732 |
+ |
QUADTREE qt; |
| 733 |
+ |
BCOORD bcoordi[3]; |
| 734 |
+ |
int i,done; |
| 735 |
+ |
|
| 736 |
+ |
/* Find root quadtree that contains p */ |
| 737 |
+ |
i = stLocate_root(p); |
| 738 |
+ |
qt = ST_ROOT_QT(st,i); |
| 739 |
+ |
|
| 740 |
+ |
/* Will return lowest level triangle containing point: It the |
| 741 |
+ |
point is on an edge or vertex: will return first associated |
| 742 |
+ |
triangle encountered in the child traversal- the others can |
| 743 |
+ |
be derived using triangle adjacency information |
| 744 |
+ |
*/ |
| 745 |
+ |
vert_to_qt_frame(i,p,bcoordi); |
| 746 |
+ |
ST_ROOT_QT(st,i) = qtInsert_point(i,qt,EMPTY,qtRoot[0],qtRoot[1], |
| 747 |
+ |
qtRoot[2],bcoordi,MAXBCOORD2>>1,f,0,&done); |
| 748 |
+ |
|
| 749 |
+ |
} |
| 750 |
|
|
| 751 |
|
|
| 752 |
|
|