53 |
|
char *khalffn = "klems_half.cal"; |
54 |
|
char *kquarterfn = "klems_quarter.cal"; |
55 |
|
|
56 |
< |
#define PARAMSTART "@rfluxmtx" /* string indicating parameters */ |
56 |
> |
/* string indicating parameters */ |
57 |
> |
const char PARAMSTART[] = "@rfluxmtx"; |
58 |
|
|
59 |
|
/* surface type IDs */ |
60 |
|
#define ST_NONE 0 |
67 |
|
void *priv; /* private data (malloc'ed) */ |
68 |
|
char sname[32]; /* surface name */ |
69 |
|
FVECT snrm; /* surface normal */ |
70 |
< |
double area; /* surface area (or solid angle) */ |
70 |
> |
double area; /* surface area / proj. solid angle */ |
71 |
|
short styp; /* surface type */ |
72 |
|
short nfargs; /* number of real arguments */ |
73 |
|
double farg[1]; /* real values (extends struct) */ |
373 |
|
static void |
374 |
|
finish_receiver(void) |
375 |
|
{ |
376 |
+ |
char sbuf[256]; |
377 |
+ |
int uniform = 0; |
378 |
|
char *calfn = NULL; |
379 |
+ |
char *params = NULL; |
380 |
|
char *binv = NULL; |
381 |
|
char *binf = NULL; |
382 |
|
char *nbins = NULL; |
379 |
– |
char sbuf[256]; |
383 |
|
|
384 |
|
if (!curmod[0]) { |
385 |
|
fputs(progname, stderr); |
391 |
|
rcarg[nrcargs++] = "-o"; |
392 |
|
rcarg[nrcargs++] = curparams.outfn; |
393 |
|
} |
394 |
< |
/* add bin specification */ |
394 |
> |
/* check arguments */ |
395 |
|
if (!curparams.hemis[0]) { |
396 |
|
fputs(progname, stderr); |
397 |
|
fputs(": missing hemisphere sampling type!\n", stderr); |
407 |
|
curparams.vup[2] = 1; |
408 |
|
else |
409 |
|
curparams.vup[1] = 1; |
410 |
+ |
/* determine sample type/bin */ |
411 |
|
if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') { |
412 |
< |
binv = "0"; |
412 |
> |
binv = "0"; /* uniform sampling -- one bin */ |
413 |
> |
uniform = 1; |
414 |
|
} else if (tolower(curparams.hemis[0]) == 's' && |
415 |
|
tolower(curparams.hemis[1]) == 'c') { |
416 |
|
/* assign parameters */ |
419 |
|
fputs(": missing size for Shirley-Chiu sampling!\n", stderr); |
420 |
|
exit(1); |
421 |
|
} |
422 |
+ |
calfn = shirchiufn; shirchiufn = NULL; |
423 |
|
sprintf(sbuf, "SCdim=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g", |
424 |
|
curparams.hsiz, |
425 |
|
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
426 |
|
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
427 |
< |
CHECKARGC(2); |
422 |
< |
rcarg[nrcargs++] = "-p"; |
423 |
< |
rcarg[nrcargs++] = savqstr(sbuf); |
424 |
< |
calfn = shirchiufn; shirchiufn = NULL; |
427 |
> |
params = savqstr(sbuf); |
428 |
|
binv = "scbin"; |
429 |
|
nbins = "SCdim*SCdim"; |
430 |
|
} else if ((tolower(curparams.hemis[0]) == 'r') | |
431 |
|
(tolower(curparams.hemis[0]) == 't')) { |
432 |
|
calfn = reinhfn; reinhfn = NULL; |
433 |
< |
/* XXX Need to set number of divisions */ |
434 |
< |
binf = "rhbin"; |
435 |
< |
nbins = "Nrhbins"; |
433 |
> |
sprintf(sbuf, "MF=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g", |
434 |
> |
curparams.hsiz, |
435 |
> |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
436 |
> |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
437 |
> |
params = savqstr(sbuf); |
438 |
> |
binv = "rbin"; |
439 |
> |
nbins = "Nrbins"; |
440 |
|
} else if (tolower(curparams.hemis[0]) == 'k' && |
441 |
|
!curparams.hemis[1] | |
442 |
|
(tolower(curparams.hemis[1]) == 'f') | |
461 |
|
progname, curparams.hemis); |
462 |
|
exit(1); |
463 |
|
} |
464 |
+ |
if (!uniform & (curparams.slist->styp == ST_SOURCE)) { |
465 |
+ |
SURF *sp; |
466 |
+ |
for (sp = curparams.slist; sp != NULL; sp = sp->next) |
467 |
+ |
if (fabs(sp->area - PI) > 1e-3) { |
468 |
+ |
fprintf(stderr, "%s: source '%s' must be 180-degrees\n", |
469 |
+ |
progname, sp->sname); |
470 |
+ |
exit(1); |
471 |
+ |
} |
472 |
+ |
} |
473 |
|
if (calfn != NULL) { /* add cal file if needed */ |
474 |
|
CHECKARGC(2); |
475 |
|
rcarg[nrcargs++] = "-f"; |
476 |
|
rcarg[nrcargs++] = calfn; |
477 |
|
} |
478 |
+ |
if (params != NULL) { /* parameters _after_ cal file */ |
479 |
+ |
CHECKARGC(2); |
480 |
+ |
rcarg[nrcargs++] = "-p"; |
481 |
+ |
rcarg[nrcargs++] = params; |
482 |
+ |
} |
483 |
|
if (nbins != NULL) { /* add #bins if set */ |
484 |
|
CHECKARGC(2); |
485 |
|
rcarg[nrcargs++] = "-bn"; |
486 |
|
rcarg[nrcargs++] = nbins; |
487 |
|
} |
488 |
< |
if (binfv != NULL) { |
488 |
> |
if (binv != NULL) { |
489 |
|
CHECKARGC(2); /* assign bin variable */ |
490 |
|
rcarg[nrcargs++] = "-b"; |
491 |
|
rcarg[nrcargs++] = binv; |
492 |
|
} else if (binf != NULL) { |
493 |
|
CHECKARGC(2); /* assign bin function */ |
494 |
+ |
rcarg[nrcargs++] = "-b"; |
495 |
|
sprintf(sbuf, "%s(%g,%g,%g,%g,%g,%g)", binf, |
496 |
|
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
497 |
|
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
476 |
– |
rcarg[nrcargs++] = "-b"; |
498 |
|
rcarg[nrcargs++] = savqstr(sbuf); |
499 |
|
} |
500 |
|
CHECKARGC(2); /* modifier argument goes last */ |
992 |
|
VCOPY(snew->snrm, snew->farg); |
993 |
|
if (normalize(snew->snrm) == 0) |
994 |
|
goto badnorm; |
995 |
< |
snew->area = 2.*PI*(1. - cos((PI/180./2.)*snew->farg[3])); |
995 |
> |
snew->area = sin((PI/180./2.)*snew->farg[3]); |
996 |
> |
snew->area *= PI*snew->area; |
997 |
|
break; |
998 |
|
} |
999 |
|
if (snew->area <= FTINY) { |
1123 |
|
continue; |
1124 |
|
} |
1125 |
|
if (c == '#') { /* parameters/comment */ |
1126 |
< |
if (fscanf(fp, "%s", inpbuf) == 1 && |
1126 |
> |
if ((c = getc(fp)) == EOF || ungetc(c,fp) == EOF) |
1127 |
> |
break; |
1128 |
> |
if (!isspace(c) && fscanf(fp, "%s", inpbuf) == 1 && |
1129 |
|
!strcmp(inpbuf, PARAMSTART)) { |
1130 |
|
if (fgets(inpbuf, sizeof(inpbuf), fp) != NULL) |
1131 |
|
parse_params(inpbuf); |
1155 |
|
main(int argc, char *argv[]) |
1156 |
|
{ |
1157 |
|
char fmtopt[6] = "-faa"; /* default output is ASCII */ |
1158 |
+ |
char *xrs=NULL, *yrs=NULL, *ldopt=NULL; |
1159 |
|
char *sendfn; |
1160 |
|
char sampcntbuf[32], nsbinbuf[32]; |
1161 |
|
FILE *rcfp; |
1189 |
|
goto userr; |
1190 |
|
} |
1191 |
|
break; |
1192 |
+ |
case 'x': /* x-resolution */ |
1193 |
+ |
xrs = argv[++a]; |
1194 |
+ |
na = 0; |
1195 |
+ |
continue; |
1196 |
+ |
case 'y': /* y-resolution */ |
1197 |
+ |
yrs = argv[++a]; |
1198 |
+ |
na = 0; |
1199 |
+ |
continue; |
1200 |
|
case 'c': /* number of samples */ |
1201 |
|
sampcnt = atoi(argv[a+1]); |
1202 |
|
if (sampcnt <= 0) |
1208 |
|
case 'u': |
1209 |
|
case 'i': |
1210 |
|
case 'h': |
1211 |
+ |
case 'r': |
1212 |
|
break; |
1213 |
|
case 'n': /* options with 1 argument */ |
1214 |
|
case 's': |
1219 |
|
if (argv[a][2] != 'v') goto userr; |
1220 |
|
break; |
1221 |
|
case 'l': /* special case */ |
1222 |
< |
if (argv[a][2] == 'd') goto userr; |
1222 |
> |
if (argv[a][2] == 'd') { |
1223 |
> |
ldopt = argv[a]; |
1224 |
> |
na = 0; |
1225 |
> |
continue; |
1226 |
> |
} |
1227 |
|
na = 2; |
1228 |
|
break; |
1229 |
|
case 'd': /* special case */ |
1254 |
|
if (sendfn[0] == '-') { /* user wants pass-through mode? */ |
1255 |
|
if (sendfn[1]) goto userr; |
1256 |
|
sendfn = NULL; |
1257 |
+ |
if (xrs) { |
1258 |
+ |
CHECKARGC(2); |
1259 |
+ |
rcarg[nrcargs++] = "-x"; |
1260 |
+ |
rcarg[nrcargs++] = xrs; |
1261 |
+ |
} |
1262 |
+ |
if (yrs) { |
1263 |
+ |
CHECKARGC(2); |
1264 |
+ |
rcarg[nrcargs++] = "-y"; |
1265 |
+ |
rcarg[nrcargs++] = yrs; |
1266 |
+ |
} |
1267 |
+ |
if (ldopt) { |
1268 |
+ |
CHECKARGC(1); |
1269 |
+ |
rcarg[nrcargs++] = ldopt; |
1270 |
+ |
} |
1271 |
|
if (sampcnt <= 0) sampcnt = 1; |
1272 |
|
} else { /* else FVECT determines input format */ |
1273 |
|
fmtopt[3] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f'; |
1320 |
|
userr: |
1321 |
|
if (a < argc-2) |
1322 |
|
fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]); |
1323 |
< |
fprintf(stderr, "Usage: %s [rcontrib options] sender.rad receiver.rad [system.rad ..]\n", |
1323 |
> |
fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n", |
1324 |
|
progname); |
1325 |
|
return(1); |
1326 |
|
} |