| 22 |
|
#define MAXRCARG 10000 |
| 23 |
|
#endif |
| 24 |
|
|
| 25 |
< |
char *progname; /* global argv[0] */ |
| 25 |
> |
#define NOWARN 1 |
| 26 |
> |
#define VERBO 2 |
| 27 |
|
|
| 28 |
< |
int verbose = 0; /* verbose mode (< 0 no warnings) */ |
| 28 |
> |
int verbose = 0; /* verbose/warning mode */ |
| 29 |
|
|
| 30 |
|
char *rcarg[MAXRCARG+1] = {"rcontrib", "-fo+"}; |
| 31 |
|
int nrcargs = 2; |
| 42 |
|
char *kfullfn = "klems_full.cal"; |
| 43 |
|
char *khalffn = "klems_half.cal"; |
| 44 |
|
char *kquarterfn = "klems_quarter.cal"; |
| 45 |
+ |
char *ciefn = "cieskyscan.cal"; |
| 46 |
|
|
| 47 |
|
/* string indicating parameters */ |
| 48 |
< |
const char PARAMSTART[] = "@rfluxmtx"; |
| 48 |
> |
#define PARAMSTART "@rfluxmtx" |
| 49 |
|
|
| 50 |
|
/* surface type IDs */ |
| 51 |
|
#define ST_NONE 0 |
| 142 |
|
|
| 143 |
|
if (ac-- <= 0) |
| 144 |
|
return(NULL); |
| 145 |
< |
if (verbose < 0) { /* turn off warnings */ |
| 145 |
> |
if (verbose & NOWARN) { /* warnings off? */ |
| 146 |
|
strcpy(cp, "-w "); |
| 147 |
|
cp += 3; |
| 148 |
|
} |
| 193 |
|
fputs(": command line too long in popen_arglist()\n", stderr); |
| 194 |
|
return(NULL); |
| 195 |
|
} |
| 196 |
< |
if (verbose > 0) |
| 196 |
> |
if (verbose & VERBO) |
| 197 |
|
fprintf(stderr, "%s: opening pipe %s: %s\n", |
| 198 |
|
progname, (*mode=='w') ? "to" : "from", cmd); |
| 199 |
|
return(popen(cmd, mode)); |
| 212 |
|
fputs(": command line too long in my_exec()\n", stderr); |
| 213 |
|
return(1); |
| 214 |
|
} |
| 215 |
< |
if (verbose > 0) |
| 215 |
> |
if (verbose & VERBO) |
| 216 |
|
fprintf(stderr, "%s: running: %s\n", progname, cmd); |
| 217 |
|
return(system(cmd)); |
| 218 |
|
} |
| 231 |
|
fprintf(stderr, "%s: only one i/o pipe at a time!\n", progname); |
| 232 |
|
return(NULL); |
| 233 |
|
} |
| 234 |
< |
if (verbose > 0) { |
| 234 |
> |
if (verbose & VERBO) { |
| 235 |
|
char cmd[4096]; |
| 236 |
|
if (!convert_commandline(cmd, sizeof(cmd), av)) |
| 237 |
|
strcpy(cmd, "COMMAND TOO LONG TO SHOW"); |
| 276 |
|
fprintf(stderr, "%s: cannot locate %s\n", progname, av[0]); |
| 277 |
|
return(1); |
| 278 |
|
} |
| 279 |
< |
if (verbose > 0) { |
| 279 |
> |
if (verbose & VERBO) { |
| 280 |
|
char cmd[4096]; |
| 281 |
|
if (!convert_commandline(cmd, sizeof(cmd), av)) |
| 282 |
|
strcpy(cmd, "COMMAND TOO LONG TO SHOW"); |
| 501 |
|
calfn = kquarterfn; kquarterfn = NULL; |
| 502 |
|
binf = "kqbin"; |
| 503 |
|
nbins = "Nkqbins"; |
| 504 |
+ |
} else if (!strcasecmp(curparams.hemis, "cie")) { |
| 505 |
+ |
calfn = ciefn; ciefn = NULL; |
| 506 |
+ |
sprintf(sbuf, "rNx=%g,rNy=%g,rNz=%g,Ux=%g,Uy=%g,Uz=%g,RHS=%c1", |
| 507 |
+ |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
| 508 |
+ |
curparams.vup[0], curparams.vup[1], curparams.vup[2], |
| 509 |
+ |
curparams.sign); |
| 510 |
+ |
binv = "cbin"; |
| 511 |
+ |
nbins = "Ncbins"; |
| 512 |
|
} else { |
| 513 |
|
fprintf(stderr, "%s: unrecognized hemisphere sampling: h=%s\n", |
| 514 |
|
progname, curparams.hemis); |
| 518 |
|
sprintf(sbuf, "RHS=%c1", curparams.sign); |
| 519 |
|
params = savqstr(sbuf); |
| 520 |
|
} |
| 521 |
< |
if (!uniform & (curparams.slist->styp == ST_SOURCE)) { |
| 521 |
> |
if (!uniform) { |
| 522 |
|
SURF *sp; |
| 523 |
|
for (sp = curparams.slist; sp != NULL; sp = sp->next) |
| 524 |
< |
if (fabs(sp->area - PI) > 1e-3) { |
| 524 |
> |
if (sp->styp == ST_SOURCE && fabs(sp->area - PI) > 1e-3) { |
| 525 |
|
fprintf(stderr, "%s: source '%s' must be 180-degrees\n", |
| 526 |
|
progname, sp->sname); |
| 527 |
|
exit(1); |
| 750 |
|
{ |
| 751 |
|
int n = sampcnt; |
| 752 |
|
double samp3[3]; |
| 753 |
< |
double duvw[3]; |
| 744 |
< |
FVECT orig_dir[2]; |
| 753 |
> |
FVECT duvw, orig_dir[2]; |
| 754 |
|
int i; |
| 755 |
|
|
| 756 |
|
if (fp == NULL) /* just requesting number of bins? */ |
| 758 |
|
|
| 759 |
|
while (n--) { /* stratified hemisphere sampling */ |
| 760 |
|
SDmultiSamp(samp3, 3, (n+frandom())/sampcnt); |
| 761 |
< |
SDsquare2disk(duvw, samp3[1], samp3[2]); |
| 761 |
> |
square2disk(duvw, samp3[1], samp3[2]); |
| 762 |
|
duvw[2] = -sqrt(1. - duvw[0]*duvw[0] - duvw[1]*duvw[1]); |
| 763 |
|
for (i = 3; i--; ) |
| 764 |
|
orig_dir[1][i] = duvw[0]*p->udir[i] + |
| 778 |
|
{ |
| 779 |
|
int n = sampcnt; |
| 780 |
|
double samp3[3]; |
| 781 |
< |
double duvw[3]; |
| 773 |
< |
FVECT orig_dir[2]; |
| 781 |
> |
FVECT duvw, orig_dir[2]; |
| 782 |
|
int i; |
| 783 |
|
|
| 784 |
|
if (fp == NULL) /* just requesting number of bins? */ |
| 786 |
|
|
| 787 |
|
while (n--) { /* stratified sampling */ |
| 788 |
|
SDmultiSamp(samp3, 3, (n+frandom())/sampcnt); |
| 789 |
< |
SDsquare2disk(duvw, (b/p->hsiz + samp3[1])/curparams.hsiz, |
| 789 |
> |
square2disk(duvw, (b/p->hsiz + samp3[1])/curparams.hsiz, |
| 790 |
|
(b%p->hsiz + samp3[2])/curparams.hsiz); |
| 791 |
|
duvw[2] = sqrt(1. - duvw[0]*duvw[0] - duvw[1]*duvw[1]); |
| 792 |
|
for (i = 3; i--; ) |
| 912 |
|
return(-1); |
| 913 |
|
} |
| 914 |
|
/* misplaced output file spec. */ |
| 915 |
< |
if ((curparams.outfn != NULL) & (verbose >= 0)) |
| 915 |
> |
if ((curparams.outfn != NULL) & !(verbose & NOWARN)) |
| 916 |
|
fprintf(stderr, "%s: warning - ignoring output file in sender ('%s')\n", |
| 917 |
|
progname, curparams.outfn); |
| 918 |
|
/* check/set basis hemisphere */ |
| 1068 |
|
snew->area *= PI*snew->area; |
| 1069 |
|
break; |
| 1070 |
|
} |
| 1071 |
< |
if ((snew->area <= FTINY*FTINY) & (verbose >= 0)) { |
| 1071 |
> |
if ((snew->area <= FTINY*FTINY) & !(verbose & NOWARN)) { |
| 1072 |
|
fprintf(stderr, "%s: warning - zero area for surface '%s'\n", |
| 1073 |
|
progname, oname); |
| 1074 |
|
free(snew); |
| 1105 |
|
} |
| 1106 |
|
/* is it a new receiver? */ |
| 1107 |
|
if ((st = surf_type(otype)) != ST_NONE) { |
| 1100 |
– |
if (curparams.slist != NULL && (st == ST_SOURCE) ^ |
| 1101 |
– |
(curparams.slist->styp == ST_SOURCE)) { |
| 1102 |
– |
fputs(progname, stderr); |
| 1103 |
– |
fputs(": cannot mix source/non-source receivers!\n", stderr); |
| 1104 |
– |
return(-1); |
| 1105 |
– |
} |
| 1108 |
|
if (strcmp(thismod, curmod)) { |
| 1109 |
|
if (curmod[0]) { /* output last receiver? */ |
| 1110 |
|
finish_receiver(); |
| 1240 |
|
FILE *rcfp; |
| 1241 |
|
int nsbins; |
| 1242 |
|
int a, i; |
| 1243 |
+ |
/* set global progname */ |
| 1244 |
+ |
fixargv0(argv[0]); |
| 1245 |
|
/* screen rcontrib options */ |
| 1242 |
– |
progname = argv[0]; |
| 1246 |
|
for (a = 1; a < argc-2; a++) { |
| 1247 |
|
int na; |
| 1248 |
|
/* check for argument expansion */ |
| 1258 |
|
na = 1; |
| 1259 |
|
switch (argv[a][1]) { /* !! Keep consistent !! */ |
| 1260 |
|
case 'v': /* verbose mode */ |
| 1261 |
< |
verbose = 1; |
| 1261 |
> |
verbose ^= VERBO; |
| 1262 |
|
na = 0; |
| 1263 |
|
continue; |
| 1264 |
|
case 'f': /* special case for -fo, -ff, etc. */ |
| 1288 |
|
yrs = argv[++a]; |
| 1289 |
|
na = 0; |
| 1290 |
|
continue; |
| 1291 |
< |
case 'c': /* number of samples */ |
| 1292 |
< |
sampcnt = atoi(argv[++a]); |
| 1293 |
< |
if (sampcnt <= 0) |
| 1294 |
< |
goto userr; |
| 1295 |
< |
na = 0; /* we re-add this later */ |
| 1296 |
< |
continue; |
| 1291 |
> |
case 'c': /* spectral sampling or count */ |
| 1292 |
> |
switch (argv[a][2]) { |
| 1293 |
> |
case 's': |
| 1294 |
> |
na = 2; |
| 1295 |
> |
break; |
| 1296 |
> |
case 'w': |
| 1297 |
> |
na = 3; |
| 1298 |
> |
break; |
| 1299 |
> |
case '\0': |
| 1300 |
> |
sampcnt = atoi(argv[++a]); |
| 1301 |
> |
if (sampcnt <= 0) |
| 1302 |
> |
goto userr; |
| 1303 |
> |
na = 0; /* we re-add this later */ |
| 1304 |
> |
continue; |
| 1305 |
> |
} |
| 1306 |
> |
break; |
| 1307 |
|
case 'I': /* only for pass-through mode */ |
| 1308 |
|
case 'i': |
| 1309 |
|
iropt = argv[a]; |
| 1310 |
|
na = 0; |
| 1311 |
|
continue; |
| 1312 |
|
case 'w': /* options without arguments */ |
| 1313 |
< |
if (!argv[a][2] || strchr("+1tTyY", argv[a][2]) == NULL) |
| 1314 |
< |
verbose = -1; |
| 1313 |
> |
if (!argv[a][2]) |
| 1314 |
> |
verbose ^= NOWARN; |
| 1315 |
> |
else if (strchr("+1tTyY", argv[a][2]) != NULL) |
| 1316 |
> |
verbose &= ~NOWARN; |
| 1317 |
> |
else |
| 1318 |
> |
verbose |= NOWARN; |
| 1319 |
|
break; |
| 1320 |
|
case 'V': |
| 1321 |
|
case 'u': |
| 1325 |
|
case 'n': /* options with 1 argument */ |
| 1326 |
|
case 's': |
| 1327 |
|
case 'o': |
| 1328 |
+ |
case 't': |
| 1329 |
|
na = 2; |
| 1330 |
|
break; |
| 1331 |
|
case 'b': /* special case */ |
| 1435 |
|
#ifdef getc_unlocked |
| 1436 |
|
flockfile(rcfp); |
| 1437 |
|
#endif |
| 1438 |
< |
if (verbose > 0) { |
| 1438 |
> |
if (verbose & VERBO) { |
| 1439 |
|
fprintf(stderr, "%s: sampling %d directions", progname, nsbins); |
| 1440 |
|
if (curparams.nsurfs > 1) |
| 1441 |
|
fprintf(stderr, " (%d elements)\n", curparams.nsurfs); |