| 189 |
|
} |
| 190 |
|
} |
| 191 |
|
|
| 192 |
+ |
/* Compute minimum BSDF from histogram and clear it */ |
| 193 |
+ |
static void |
| 194 |
+ |
comp_bsdf_min() |
| 195 |
+ |
{ |
| 196 |
+ |
int cnt; |
| 197 |
+ |
int i, target; |
| 198 |
+ |
|
| 199 |
+ |
cnt = 0; |
| 200 |
+ |
for (i = HISTLEN; i--; ) |
| 201 |
+ |
cnt += bsdf_hist[i]; |
| 202 |
+ |
if (!cnt) { /* shouldn't happen */ |
| 203 |
+ |
bsdf_min = 0; |
| 204 |
+ |
return; |
| 205 |
+ |
} |
| 206 |
+ |
target = cnt/100; /* ignore bottom 1% */ |
| 207 |
+ |
cnt = 0; |
| 208 |
+ |
for (i = 0; cnt <= target; i++) |
| 209 |
+ |
cnt += bsdf_hist[i]; |
| 210 |
+ |
bsdf_min = histval(i-1); |
| 211 |
+ |
memset(bsdf_hist, 0, sizeof(bsdf_hist)); |
| 212 |
+ |
} |
| 213 |
+ |
|
| 214 |
|
/* Count up filled nodes and build RBF representation from current grid */ |
| 215 |
|
RBFNODE * |
| 216 |
|
make_rbfrep(void) |
| 229 |
|
for (i = 0; i < GRIDRES; i++) |
| 230 |
|
for (j = 0; j < GRIDRES; j++) |
| 231 |
|
nn += dsf_grid[i][j].nval; |
| 232 |
+ |
/* compute minimum BSDF */ |
| 233 |
+ |
comp_bsdf_min(); |
| 234 |
|
/* allocate RBF array */ |
| 235 |
|
newnode = (RBFNODE *)malloc(sizeof(RBFNODE) + sizeof(RBFVAL)*(nn-1)); |
| 236 |
|
if (newnode == NULL) |