11 |
|
#include "standard.h" |
12 |
|
#include "rhd_qtree.h" |
13 |
|
|
14 |
– |
static RLEAF *leafpile; /* our collection of leaf values */ |
15 |
– |
static int nleaves; /* count of leaves in our pile */ |
16 |
– |
static int bleaf, tleaf; /* bottom and top (next) leaf index (ring) */ |
17 |
– |
|
14 |
|
RTREE qtrunk; /* our quadtree trunk */ |
15 |
|
double qtDepthEps = .02; /* epsilon to compare depths (z fraction) */ |
16 |
|
int qtMinNodesiz = 2; /* minimum node dimension (pixels) */ |
17 |
|
|
18 |
+ |
static RLEAF *leafpile; /* our collection of leaf values */ |
19 |
+ |
static int nleaves; /* count of leaves in our pile */ |
20 |
+ |
static int bleaf, tleaf; /* bottom and top (next) leaf index (ring) */ |
21 |
+ |
|
22 |
|
#define TBUNDLESIZ 409 /* number of twigs in a bundle */ |
23 |
|
|
24 |
|
static RTREE **twigbundle; /* free twig blocks (NULL term.) */ |
59 |
|
|
60 |
|
|
61 |
|
static |
62 |
< |
freetwigs(really) /* free allocated twigs */ |
62 |
> |
freetree(really) /* free allocated twigs */ |
63 |
|
int really; |
64 |
|
{ |
65 |
|
register int i; |
101 |
|
unsigned nbytes; |
102 |
|
register unsigned i; |
103 |
|
|
104 |
< |
freetwigs(0); /* make sure tree is empty */ |
104 |
> |
freetree(0); /* make sure tree is empty */ |
105 |
|
if (n <= 0) |
106 |
|
return(0); |
107 |
|
if (nleaves >= n) |
124 |
|
|
125 |
|
qtFreeLeaves() /* free our allocated leaves and twigs */ |
126 |
|
{ |
127 |
< |
freetwigs(1); /* free tree also */ |
127 |
> |
freetree(1); /* free tree also */ |
128 |
|
if (nleaves <= 0) |
129 |
|
return; |
130 |
|
free((char *)leafpile); |
140 |
|
register int i, li; |
141 |
|
|
142 |
|
for (i = 0; i < 4; i++) |
143 |
< |
if (tp->flgs & BRF(i)) { |
144 |
< |
if (shaketree(tp->k[i].b)) |
145 |
< |
tp->flgs |= CHF(i); |
146 |
< |
} else if (tp->k[i].l != NULL) { |
143 |
> |
if (tp->flgs & BRF(i)) |
144 |
> |
shaketree(tp->k[i].b); |
145 |
> |
else if (tp->k[i].l != NULL) { |
146 |
|
li = tp->k[i].l - leafpile; |
147 |
|
if (bleaf < tleaf ? (li < bleaf || li >= tleaf) : |
148 |
|
(li < bleaf && li >= tleaf)) { |
149 |
|
tmAddHisto(&tp->k[i].l->brt, 1, -1); |
150 |
|
tp->k[i].l = NULL; |
152 |
– |
tp->flgs |= CHF(i); |
151 |
|
} |
152 |
|
} |
155 |
– |
return(tp->flgs & CH_ANY); |
153 |
|
} |
154 |
|
|
155 |
|
|
164 |
|
return(0); |
165 |
|
nused = tleaf > bleaf ? tleaf-bleaf : tleaf+nleaves-bleaf; |
166 |
|
if (nclear >= nused) { /* clear them all */ |
167 |
< |
freetwigs(0); |
167 |
> |
freetree(0); |
168 |
|
bleaf = tleaf = 0; |
169 |
|
return(nused); |
170 |
|
} |
262 |
|
|
263 |
|
if (bleaf == tleaf) /* anything to replant? */ |
264 |
|
return; |
265 |
< |
freetwigs(0); /* blow the tree away */ |
265 |
> |
freetree(0); /* blow the tree away */ |
266 |
|
/* now rebuild it */ |
267 |
|
for (i = bleaf; i != tleaf; ) { |
268 |
|
addleaf(leafpile+i); |