| 14 |
|
#include "rtio.h" |
| 15 |
|
#include "resolu.h" |
| 16 |
|
#include "bsdfrep.h" |
| 17 |
< |
/* which quadrants are represented */ |
| 17 |
> |
/* coverage/symmetry using INP_QUAD? flags */ |
| 18 |
|
int inp_coverage = 0; |
| 19 |
|
/* all incident angles in-plane so far? */ |
| 20 |
|
int single_plane_incident = -1; |
| 281 |
|
RBFNODE *rbf; |
| 282 |
|
|
| 283 |
|
for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) |
| 284 |
< |
if (rbf->ord == ord); |
| 284 |
> |
if (rbf->ord == ord) |
| 285 |
|
return(rbf); |
| 286 |
|
return(NULL); |
| 287 |
|
} |
| 312 |
|
int |
| 313 |
|
get_triangles(RBFNODE *rbfv[2], const MIGRATION *mig) |
| 314 |
|
{ |
| 315 |
< |
const MIGRATION *ej, *ej2; |
| 315 |
> |
const MIGRATION *ej1, *ej2; |
| 316 |
|
RBFNODE *tv; |
| 317 |
|
|
| 318 |
|
rbfv[0] = rbfv[1] = NULL; |
| 319 |
|
if (mig == NULL) |
| 320 |
|
return(0); |
| 321 |
< |
for (ej = mig->rbfv[0]->ejl; ej != NULL; |
| 322 |
< |
ej = nextedge(mig->rbfv[0],ej)) { |
| 323 |
< |
if (ej == mig) |
| 321 |
> |
for (ej1 = mig->rbfv[0]->ejl; ej1 != NULL; |
| 322 |
> |
ej1 = nextedge(mig->rbfv[0],ej1)) { |
| 323 |
> |
if (ej1 == mig) |
| 324 |
|
continue; |
| 325 |
< |
tv = opp_rbf(mig->rbfv[0],ej); |
| 325 |
> |
tv = opp_rbf(mig->rbfv[0],ej1); |
| 326 |
|
for (ej2 = tv->ejl; ej2 != NULL; ej2 = nextedge(tv,ej2)) |
| 327 |
|
if (opp_rbf(tv,ej2) == mig->rbfv[1]) { |
| 328 |
|
rbfv[is_rev_tri(mig->rbfv[0]->invec, |
| 334 |
|
return((rbfv[0] != NULL) + (rbfv[1] != NULL)); |
| 335 |
|
} |
| 336 |
|
|
| 337 |
+ |
/* Clear our BSDF representation and free memory */ |
| 338 |
+ |
void |
| 339 |
+ |
clear_bsdf_rep(void) |
| 340 |
+ |
{ |
| 341 |
+ |
while (mig_list != NULL) { |
| 342 |
+ |
MIGRATION *mig = mig_list; |
| 343 |
+ |
mig_list = mig->next; |
| 344 |
+ |
free(mig); |
| 345 |
+ |
} |
| 346 |
+ |
while (dsf_list != NULL) { |
| 347 |
+ |
RBFNODE *rbf = dsf_list; |
| 348 |
+ |
dsf_list = rbf->next; |
| 349 |
+ |
free(rbf); |
| 350 |
+ |
} |
| 351 |
+ |
inp_coverage = 0; |
| 352 |
+ |
single_plane_incident = -1; |
| 353 |
+ |
input_orient = output_orient = 0; |
| 354 |
+ |
} |
| 355 |
+ |
|
| 356 |
|
/* Write our BSDF mesh interpolant out to the given binary stream */ |
| 357 |
|
void |
| 358 |
|
save_bsdf_rep(FILE *ofp) |
| 389 |
|
/* write out as sparse data */ |
| 390 |
|
n = mtx_nrows(mig) * mtx_ncols(mig); |
| 391 |
|
for (i = 0; i < n; i++) { |
| 392 |
< |
if (zerocnt >= 0xff) { |
| 393 |
< |
putint(zerocnt, 1, ofp); zerocnt = 0; |
| 392 |
> |
if (zerocnt == 0xff) { |
| 393 |
> |
putint(0xff, 1, ofp); zerocnt = 0; |
| 394 |
|
} |
| 395 |
|
if (mig->mtx[i] != 0) { |
| 396 |
|
putint(zerocnt, 1, ofp); zerocnt = 0; |
| 436 |
|
RBFNODE rbfh; |
| 437 |
|
int from_ord, to_ord; |
| 438 |
|
int i; |
| 439 |
< |
#ifdef DEBUG |
| 440 |
< |
if ((dsf_list != NULL) | (mig_list != NULL)) { |
| 422 |
< |
fprintf(stderr, |
| 423 |
< |
"%s: attempt to load BSDF interpolant over existing\n", |
| 424 |
< |
progname); |
| 425 |
< |
return(0); |
| 426 |
< |
} |
| 427 |
< |
#endif |
| 428 |
< |
input_orient = output_orient = 0; |
| 429 |
< |
single_plane_incident = -1; |
| 439 |
> |
|
| 440 |
> |
clear_bsdf_rep(); |
| 441 |
|
if (getheader(ifp, headline, NULL) < 0 || single_plane_incident < 0 | |
| 442 |
|
!input_orient | !output_orient) { |
| 443 |
|
fprintf(stderr, "%s: missing/bad format for BSDF interpolant\n", |
| 452 |
|
rbfh.invec[0] = getflt(ifp); |
| 453 |
|
rbfh.invec[1] = getflt(ifp); |
| 454 |
|
rbfh.invec[2] = getflt(ifp); |
| 455 |
+ |
rbfh.vtotal = getflt(ifp); |
| 456 |
|
rbfh.nrbf = getint(4, ifp); |
| 445 |
– |
if (!new_input_vector(rbfh.invec)) |
| 446 |
– |
return(0); |
| 457 |
|
newrbf = (RBFNODE *)malloc(sizeof(RBFNODE) + |
| 458 |
|
sizeof(RBFVAL)*(rbfh.nrbf-1)); |
| 459 |
|
if (newrbf == NULL) |
| 497 |
|
memset(newmig->mtx, 0, sizeof(float)*n); |
| 498 |
|
for (i = 0; ; ) { /* read sparse data */ |
| 499 |
|
int zc = getint(1, ifp) & 0xff; |
| 490 |
– |
if (zc == 0xff) { |
| 491 |
– |
i += 0xff; |
| 492 |
– |
continue; |
| 493 |
– |
} |
| 500 |
|
if ((i += zc) >= n) |
| 501 |
|
break; |
| 502 |
+ |
if (zc == 0xff) |
| 503 |
+ |
continue; |
| 504 |
|
newmig->mtx[i++] = getflt(ifp); |
| 505 |
|
} |
| 506 |
|
if (feof(ifp)) |