23 |
|
#endif |
24 |
|
|
25 |
|
#ifdef _WIN32 |
26 |
< |
#define SPECIALS " \t$*?" |
26 |
> |
#define SPECIALS " \t\"$*?" |
27 |
|
#define QUOTCHAR '"' |
28 |
|
#else |
29 |
< |
#define SPECIALS " \t\n'\"()${}*?[]" |
29 |
> |
#define SPECIALS " \t\n'\"()${}*?[];|&" |
30 |
|
#define QUOTCHAR '\'' |
31 |
|
#define ALTQUOT '"' |
32 |
|
#endif |
45 |
|
#define CHECKARGC(n) if (nrcargs >= MAXRCARG-(n)) \ |
46 |
|
{ fprintf(stderr, overflowerr, progname); exit(1); } |
47 |
|
|
48 |
< |
int sampcnt = 0; /* sample count (unset) */ |
48 |
> |
int sampcnt = 0; /* sample count (0==unset) */ |
49 |
|
|
50 |
< |
char *reinhfn = "reinhart.cal"; |
51 |
< |
char *shirchufn = "disk2square.cal"; |
50 |
> |
char *reinhfn = "reinhartb.cal"; |
51 |
> |
char *shirchiufn = "disk2square.cal"; |
52 |
|
char *kfullfn = "klems_full.cal"; |
53 |
|
char *khalffn = "klems_half.cal"; |
54 |
|
char *kquarterfn = "klems_quarter.cal"; |
68 |
|
FVECT snrm; /* surface normal */ |
69 |
|
double area; /* surface area (or solid angle) */ |
70 |
|
short styp; /* surface type */ |
71 |
< |
short nfargs; /* number of arguments */ |
72 |
< |
double farg[1]; /* arguments (extends struct) */ |
71 |
> |
short nfargs; /* number of real arguments */ |
72 |
> |
double farg[1]; /* real values (extends struct) */ |
73 |
|
} SURF; /* surface structure */ |
74 |
|
|
75 |
|
typedef struct { |
372 |
|
static void |
373 |
|
finish_receiver(void) |
374 |
|
{ |
375 |
< |
char binbuf[128]; |
375 |
> |
char *calfn = NULL; |
376 |
> |
char *params = NULL; |
377 |
> |
char *binv = NULL; |
378 |
> |
char *binf = NULL; |
379 |
> |
char *nbins = NULL; |
380 |
> |
char sbuf[256]; |
381 |
|
|
382 |
|
if (!curmod[0]) { |
383 |
|
fputs(progname, stderr); |
406 |
|
else |
407 |
|
curparams.vup[1] = 1; |
408 |
|
if (tolower(curparams.hemis[0]) == 'u' | curparams.hemis[0] == '1') { |
409 |
< |
CHECKARGC(2); |
405 |
< |
rcarg[nrcargs++] = "-b"; |
406 |
< |
rcarg[nrcargs++] = "0"; |
409 |
> |
binv = "0"; /* uniform sampling -- one bin */ |
410 |
|
} else if (tolower(curparams.hemis[0]) == 's' && |
411 |
|
tolower(curparams.hemis[1]) == 'c') { |
412 |
< |
if (shirchufn != NULL) { |
410 |
< |
CHECKARGC(2); |
411 |
< |
rcarg[nrcargs++] = "-f"; |
412 |
< |
rcarg[nrcargs++] = shirchufn; |
413 |
< |
shirchufn = NULL; |
414 |
< |
} |
415 |
< |
fputs("Shirley-Chiu unimplemented...\n",stderr); exit(1); |
412 |
> |
/* assign parameters */ |
413 |
|
if (curparams.hsiz <= 1) { |
414 |
|
fputs(progname, stderr); |
415 |
|
fputs(": missing size for Shirley-Chiu sampling!\n", stderr); |
416 |
|
exit(1); |
417 |
|
} |
418 |
+ |
calfn = shirchiufn; shirchiufn = NULL; |
419 |
+ |
sprintf(sbuf, "SCdim=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g", |
420 |
+ |
curparams.hsiz, |
421 |
+ |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
422 |
+ |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
423 |
+ |
params = savqstr(sbuf); |
424 |
+ |
binv = "scbin"; |
425 |
+ |
nbins = "SCdim*SCdim"; |
426 |
|
} else if ((tolower(curparams.hemis[0]) == 'r') | |
427 |
|
(tolower(curparams.hemis[0]) == 't')) { |
428 |
< |
if (reinhfn != NULL) { |
429 |
< |
CHECKARGC(2); |
430 |
< |
rcarg[nrcargs++] = "-f"; |
431 |
< |
rcarg[nrcargs++] = reinhfn; |
432 |
< |
reinhfn = NULL; |
433 |
< |
} |
434 |
< |
fputs("Reinhart/Tregenza unimplemented...\n",stderr); exit(1); |
428 |
> |
calfn = reinhfn; reinhfn = NULL; |
429 |
> |
sprintf(sbuf, "MF=%d,Nx=%g,Ny=%g,Nz=%g,Ux=%g,Uy=%g,Uz=%g", |
430 |
> |
curparams.hsiz, |
431 |
> |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
432 |
> |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
433 |
> |
params = savqstr(sbuf); |
434 |
> |
binv = "rbin"; |
435 |
> |
nbins = "Nrbins"; |
436 |
|
} else if (tolower(curparams.hemis[0]) == 'k' && |
437 |
|
!curparams.hemis[1] | |
438 |
|
(tolower(curparams.hemis[1]) == 'f') | |
439 |
|
(curparams.hemis[1] == '1')) { |
440 |
< |
if (kfullfn != NULL) { |
441 |
< |
CHECKARGC(2); |
442 |
< |
rcarg[nrcargs++] = "-f"; |
437 |
< |
rcarg[nrcargs++] = kfullfn; |
438 |
< |
kfullfn = NULL; |
439 |
< |
} |
440 |
< |
CHECKARGC(4); |
441 |
< |
sprintf(binbuf, "kbin(%g,%g,%g,%g,%g,%g)", |
442 |
< |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
443 |
< |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
444 |
< |
rcarg[nrcargs++] = "-b"; |
445 |
< |
rcarg[nrcargs++] = savqstr(binbuf); |
446 |
< |
rcarg[nrcargs++] = "-bn"; |
447 |
< |
rcarg[nrcargs++] = "Nkbins"; |
440 |
> |
calfn = kfullfn; kfullfn = NULL; |
441 |
> |
binf = "kbin"; |
442 |
> |
nbins = "Nkbins"; |
443 |
|
} else if (tolower(curparams.hemis[0]) == 'k' && |
444 |
|
(tolower(curparams.hemis[1]) == 'h') | |
445 |
|
(curparams.hemis[1] == '2')) { |
446 |
< |
if (khalffn != NULL) { |
447 |
< |
CHECKARGC(2); |
448 |
< |
rcarg[nrcargs++] = "-f"; |
454 |
< |
rcarg[nrcargs++] = khalffn; |
455 |
< |
khalffn = NULL; |
456 |
< |
} |
457 |
< |
CHECKARGC(4); |
458 |
< |
sprintf(binbuf, "khbin(%g,%g,%g,%g,%g,%g)", |
459 |
< |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
460 |
< |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
461 |
< |
rcarg[nrcargs++] = "-b"; |
462 |
< |
rcarg[nrcargs++] = savqstr(binbuf); |
463 |
< |
rcarg[nrcargs++] = "-bn"; |
464 |
< |
rcarg[nrcargs++] = "Nkhbins"; |
446 |
> |
calfn = khalffn; khalffn = NULL; |
447 |
> |
binf = "khbin"; |
448 |
> |
nbins = "Nkhbins"; |
449 |
|
} else if (tolower(curparams.hemis[0]) == 'k' && |
450 |
|
(tolower(curparams.hemis[1]) == 'q') | |
451 |
|
(curparams.hemis[1] == '4')) { |
452 |
< |
if (kquarterfn != NULL) { |
453 |
< |
CHECKARGC(2); |
454 |
< |
rcarg[nrcargs++] = "-f"; |
471 |
< |
rcarg[nrcargs++] = kquarterfn; |
472 |
< |
kquarterfn = NULL; |
473 |
< |
} |
474 |
< |
CHECKARGC(4); |
475 |
< |
sprintf(binbuf, "kqbin(%g,%g,%g,%g,%g,%g)", |
476 |
< |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
477 |
< |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
478 |
< |
rcarg[nrcargs++] = "-b"; |
479 |
< |
rcarg[nrcargs++] = savqstr(binbuf); |
480 |
< |
rcarg[nrcargs++] = "-bn"; |
481 |
< |
rcarg[nrcargs++] = "Nkqbins"; |
452 |
> |
calfn = kquarterfn; kquarterfn = NULL; |
453 |
> |
binf = "kqbin"; |
454 |
> |
nbins = "Nkqbins"; |
455 |
|
} else { |
456 |
|
fprintf(stderr, "%s: unrecognized hemisphere sampling: h=%s\n", |
457 |
|
progname, curparams.hemis); |
458 |
|
exit(1); |
459 |
|
} |
460 |
< |
CHECKARGC(2); /* modifier argument goes last */ |
460 |
> |
if (calfn != NULL) { /* add cal file if needed */ |
461 |
> |
CHECKARGC(2); |
462 |
> |
rcarg[nrcargs++] = "-f"; |
463 |
> |
rcarg[nrcargs++] = calfn; |
464 |
> |
} |
465 |
> |
if (params != NULL) { /* parameters _after_ cal file */ |
466 |
> |
CHECKARGC(2); |
467 |
> |
rcarg[nrcargs++] = "-p"; |
468 |
> |
rcarg[nrcargs++] = params; |
469 |
> |
} |
470 |
> |
if (nbins != NULL) { /* add #bins if set */ |
471 |
> |
CHECKARGC(2); |
472 |
> |
rcarg[nrcargs++] = "-bn"; |
473 |
> |
rcarg[nrcargs++] = nbins; |
474 |
> |
} |
475 |
> |
if (binv != NULL) { |
476 |
> |
CHECKARGC(2); /* assign bin variable */ |
477 |
> |
rcarg[nrcargs++] = "-b"; |
478 |
> |
rcarg[nrcargs++] = binv; |
479 |
> |
} else if (binf != NULL) { |
480 |
> |
CHECKARGC(2); /* assign bin function */ |
481 |
> |
rcarg[nrcargs++] = "-b"; |
482 |
> |
sprintf(sbuf, "%s(%g,%g,%g,%g,%g,%g)", binf, |
483 |
> |
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
484 |
> |
curparams.vup[0], curparams.vup[1], curparams.vup[2]); |
485 |
> |
rcarg[nrcargs++] = savqstr(sbuf); |
486 |
> |
} |
487 |
> |
CHECKARGC(2); /* modifier argument goes last */ |
488 |
|
rcarg[nrcargs++] = "-m"; |
489 |
|
rcarg[nrcargs++] = savqstr(curmod); |
490 |
|
} |