| 66 |
|
void *priv; /* private data (malloc'ed) */ |
| 67 |
|
char sname[32]; /* surface name */ |
| 68 |
|
FVECT snrm; /* surface normal */ |
| 69 |
< |
double area; /* surface area (or solid angle) */ |
| 69 |
> |
double area; /* surface area / proj. solid angle */ |
| 70 |
|
short styp; /* surface type */ |
| 71 |
|
short nfargs; /* number of real arguments */ |
| 72 |
|
double farg[1]; /* real values (extends struct) */ |
| 372 |
|
static void |
| 373 |
|
finish_receiver(void) |
| 374 |
|
{ |
| 375 |
+ |
char sbuf[256]; |
| 376 |
+ |
int uniform = 0; |
| 377 |
|
char *calfn = NULL; |
| 378 |
+ |
char *params = NULL; |
| 379 |
|
char *binv = NULL; |
| 380 |
|
char *binf = NULL; |
| 381 |
|
char *nbins = NULL; |
| 379 |
– |
char sbuf[256]; |
| 382 |
|
|
| 383 |
|
if (!curmod[0]) { |
| 384 |
|
fputs(progname, stderr); |
| 390 |
|
rcarg[nrcargs++] = "-o"; |
| 391 |
|
rcarg[nrcargs++] = curparams.outfn; |
| 392 |
|
} |
| 393 |
< |
/* add bin specification */ |
| 393 |
> |
/* check arguments */ |
| 394 |
|
if (!curparams.hemis[0]) { |
| 395 |
|
fputs(progname, stderr); |
| 396 |
|
fputs(": missing hemisphere sampling type!\n", stderr); |
| 406 |
|
curparams.vup[2] = 1; |
| 407 |
|
else |
| 408 |
|
curparams.vup[1] = 1; |
| 409 |
+ |
/* determine sample type/bin */ |
| 410 |
|
if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') { |
| 411 |
< |
binv = "0"; |
| 411 |
> |
binv = "0"; /* uniform sampling -- one bin */ |
| 412 |
> |
uniform = 1; |
| 413 |
|
} else if (tolower(curparams.hemis[0]) == 's' && |
| 414 |
|
tolower(curparams.hemis[1]) == 'c') { |
| 415 |
|
/* assign parameters */ |
| 418 |
|
fputs(": missing size for Shirley-Chiu sampling!\n", stderr); |
| 419 |
|
exit(1); |
| 420 |
|
} |
| 421 |
+ |
calfn = shirchiufn; shirchiufn = NULL; |
| 422 |
|
sprintf(sbuf, "SCdim=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g", |
| 423 |
|
curparams.hsiz, |
| 424 |
|
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
| 425 |
|
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
| 426 |
< |
CHECKARGC(2); |
| 422 |
< |
rcarg[nrcargs++] = "-p"; |
| 423 |
< |
rcarg[nrcargs++] = savqstr(sbuf); |
| 424 |
< |
calfn = shirchiufn; shirchiufn = NULL; |
| 426 |
> |
params = savqstr(sbuf); |
| 427 |
|
binv = "scbin"; |
| 428 |
|
nbins = "SCdim*SCdim"; |
| 429 |
|
} else if ((tolower(curparams.hemis[0]) == 'r') | |
| 430 |
|
(tolower(curparams.hemis[0]) == 't')) { |
| 431 |
|
calfn = reinhfn; reinhfn = NULL; |
| 432 |
< |
/* XXX Need to set number of divisions */ |
| 433 |
< |
binf = "rhbin"; |
| 434 |
< |
nbins = "Nrhbins"; |
| 432 |
> |
sprintf(sbuf, "MF=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g", |
| 433 |
> |
curparams.hsiz, |
| 434 |
> |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
| 435 |
> |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
| 436 |
> |
params = savqstr(sbuf); |
| 437 |
> |
binv = "rbin"; |
| 438 |
> |
nbins = "Nrbins"; |
| 439 |
|
} else if (tolower(curparams.hemis[0]) == 'k' && |
| 440 |
|
!curparams.hemis[1] | |
| 441 |
|
(tolower(curparams.hemis[1]) == 'f') | |
| 460 |
|
progname, curparams.hemis); |
| 461 |
|
exit(1); |
| 462 |
|
} |
| 463 |
+ |
if (!uniform & (curparams.slist->styp == ST_SOURCE)) { |
| 464 |
+ |
SURF *sp; |
| 465 |
+ |
for (sp = curparams.slist; sp != NULL; sp = sp->next) |
| 466 |
+ |
if (fabs(sp->area - PI) > 1e-3) { |
| 467 |
+ |
fprintf(stderr, "%s: source '%s' must be 180-degrees\n", |
| 468 |
+ |
progname, sp->sname); |
| 469 |
+ |
exit(1); |
| 470 |
+ |
} |
| 471 |
+ |
} |
| 472 |
|
if (calfn != NULL) { /* add cal file if needed */ |
| 473 |
|
CHECKARGC(2); |
| 474 |
|
rcarg[nrcargs++] = "-f"; |
| 475 |
|
rcarg[nrcargs++] = calfn; |
| 476 |
|
} |
| 477 |
+ |
if (params != NULL) { /* parameters _after_ cal file */ |
| 478 |
+ |
CHECKARGC(2); |
| 479 |
+ |
rcarg[nrcargs++] = "-p"; |
| 480 |
+ |
rcarg[nrcargs++] = params; |
| 481 |
+ |
} |
| 482 |
|
if (nbins != NULL) { /* add #bins if set */ |
| 483 |
|
CHECKARGC(2); |
| 484 |
|
rcarg[nrcargs++] = "-bn"; |
| 485 |
|
rcarg[nrcargs++] = nbins; |
| 486 |
|
} |
| 487 |
< |
if (binfv != NULL) { |
| 487 |
> |
if (binv != NULL) { |
| 488 |
|
CHECKARGC(2); /* assign bin variable */ |
| 489 |
|
rcarg[nrcargs++] = "-b"; |
| 490 |
|
rcarg[nrcargs++] = binv; |
| 491 |
|
} else if (binf != NULL) { |
| 492 |
|
CHECKARGC(2); /* assign bin function */ |
| 493 |
+ |
rcarg[nrcargs++] = "-b"; |
| 494 |
|
sprintf(sbuf, "%s(%g,%g,%g,%g,%g,%g)", binf, |
| 495 |
|
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
| 496 |
|
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
| 476 |
– |
rcarg[nrcargs++] = "-b"; |
| 497 |
|
rcarg[nrcargs++] = savqstr(sbuf); |
| 498 |
|
} |
| 499 |
|
CHECKARGC(2); /* modifier argument goes last */ |
| 991 |
|
VCOPY(snew->snrm, snew->farg); |
| 992 |
|
if (normalize(snew->snrm) == 0) |
| 993 |
|
goto badnorm; |
| 994 |
< |
snew->area = 2.*PI*(1. - cos((PI/180./2.)*snew->farg[3])); |
| 994 |
> |
snew->area = sin((PI/180./2.)*snew->farg[3]); |
| 995 |
> |
snew->area *= PI*snew->area; |
| 996 |
|
break; |
| 997 |
|
} |
| 998 |
|
if (snew->area <= FTINY) { |
| 1152 |
|
main(int argc, char *argv[]) |
| 1153 |
|
{ |
| 1154 |
|
char fmtopt[6] = "-faa"; /* default output is ASCII */ |
| 1155 |
+ |
char *xrs=NULL, *yrs=NULL, *ldopt=NULL; |
| 1156 |
|
char *sendfn; |
| 1157 |
|
char sampcntbuf[32], nsbinbuf[32]; |
| 1158 |
|
FILE *rcfp; |
| 1186 |
|
goto userr; |
| 1187 |
|
} |
| 1188 |
|
break; |
| 1189 |
+ |
case 'x': /* x-resolution */ |
| 1190 |
+ |
xrs = argv[++a]; |
| 1191 |
+ |
na = 0; |
| 1192 |
+ |
continue; |
| 1193 |
+ |
case 'y': /* y-resolution */ |
| 1194 |
+ |
yrs = argv[++a]; |
| 1195 |
+ |
na = 0; |
| 1196 |
+ |
continue; |
| 1197 |
|
case 'c': /* number of samples */ |
| 1198 |
|
sampcnt = atoi(argv[a+1]); |
| 1199 |
|
if (sampcnt <= 0) |
| 1205 |
|
case 'u': |
| 1206 |
|
case 'i': |
| 1207 |
|
case 'h': |
| 1208 |
+ |
case 'r': |
| 1209 |
|
break; |
| 1210 |
|
case 'n': /* options with 1 argument */ |
| 1211 |
|
case 's': |
| 1216 |
|
if (argv[a][2] != 'v') goto userr; |
| 1217 |
|
break; |
| 1218 |
|
case 'l': /* special case */ |
| 1219 |
< |
if (argv[a][2] == 'd') goto userr; |
| 1219 |
> |
if (argv[a][2] == 'd') { |
| 1220 |
> |
ldopt = argv[a]; |
| 1221 |
> |
na = 0; |
| 1222 |
> |
continue; |
| 1223 |
> |
} |
| 1224 |
|
na = 2; |
| 1225 |
|
break; |
| 1226 |
|
case 'd': /* special case */ |
| 1251 |
|
if (sendfn[0] == '-') { /* user wants pass-through mode? */ |
| 1252 |
|
if (sendfn[1]) goto userr; |
| 1253 |
|
sendfn = NULL; |
| 1254 |
+ |
if (xrs) { |
| 1255 |
+ |
CHECKARGC(2); |
| 1256 |
+ |
rcarg[nrcargs++] = "-x"; |
| 1257 |
+ |
rcarg[nrcargs++] = xrs; |
| 1258 |
+ |
} |
| 1259 |
+ |
if (yrs) { |
| 1260 |
+ |
CHECKARGC(2); |
| 1261 |
+ |
rcarg[nrcargs++] = "-y"; |
| 1262 |
+ |
rcarg[nrcargs++] = yrs; |
| 1263 |
+ |
} |
| 1264 |
+ |
if (ldopt) { |
| 1265 |
+ |
CHECKARGC(1); |
| 1266 |
+ |
rcarg[nrcargs++] = ldopt; |
| 1267 |
+ |
} |
| 1268 |
|
if (sampcnt <= 0) sampcnt = 1; |
| 1269 |
|
} else { /* else FVECT determines input format */ |
| 1270 |
|
fmtopt[3] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f'; |