| 44 |
|
char *kquarterfn = "klems_quarter.cal"; |
| 45 |
|
char *ciefn = "cieskyscan.cal"; |
| 46 |
|
|
| 47 |
+ |
char *binjitter = NULL; |
| 48 |
|
/* string indicating parameters */ |
| 49 |
|
#define PARAMSTART "@rfluxmtx" |
| 50 |
|
|
| 100 |
|
}; |
| 101 |
|
|
| 102 |
|
/* Clear parameter set */ |
| 103 |
< |
static void |
| 103 |
> |
void |
| 104 |
|
clear_params(PARAMS *p, int reset_only) |
| 105 |
|
{ |
| 106 |
|
while (p->slist != NULL) { |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
/* Get surface type from name */ |
| 125 |
< |
static int |
| 125 |
> |
int |
| 126 |
|
surf_type(const char *otype) |
| 127 |
|
{ |
| 128 |
|
if (!strcmp(otype, "polygon")) |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
/* Add arguments to oconv command */ |
| 138 |
< |
static char * |
| 138 |
> |
char * |
| 139 |
|
oconv_command(int ac, char *av[]) |
| 140 |
|
{ |
| 141 |
|
static char oconvbuf[2048] = "!oconv -f "; |
| 185 |
|
#if defined(_WIN32) || defined(_WIN64) |
| 186 |
|
|
| 187 |
|
/* Open a pipe to/from a command given as an argument list */ |
| 188 |
< |
static FILE * |
| 188 |
> |
FILE * |
| 189 |
|
popen_arglist(char *av[], char *mode) |
| 190 |
|
{ |
| 191 |
|
char cmd[10240]; |
| 204 |
|
#define pclose_al pclose |
| 205 |
|
|
| 206 |
|
/* Execute system command (Windows version) */ |
| 207 |
< |
static int |
| 207 |
> |
int |
| 208 |
|
my_exec(char *av[]) |
| 209 |
|
{ |
| 210 |
|
char cmd[10240]; |
| 224 |
|
static SUBPROC rt_proc = SP_INACTIVE; /* we only support one of these */ |
| 225 |
|
|
| 226 |
|
/* Open a pipe to a command using an argument list */ |
| 227 |
< |
static FILE * |
| 227 |
> |
FILE * |
| 228 |
|
popen_arglist(char *av[], char *mode) |
| 229 |
|
{ |
| 230 |
|
int fd; |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
/* Close command pipe (returns -1 on error to match pclose) */ |
| 258 |
< |
static int |
| 258 |
> |
int |
| 259 |
|
pclose_al(FILE *fp) |
| 260 |
|
{ |
| 261 |
|
int prob = (fclose(fp) == EOF); |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
/* Execute system command in our stead (Unix version) */ |
| 272 |
< |
static int |
| 272 |
> |
int |
| 273 |
|
my_exec(char *av[]) |
| 274 |
|
{ |
| 275 |
|
char *compath; |
| 292 |
|
#endif |
| 293 |
|
|
| 294 |
|
/* Get normalized direction vector from string specification */ |
| 295 |
< |
static int |
| 295 |
> |
int |
| 296 |
|
get_direction(FVECT dv, const char *s) |
| 297 |
|
{ |
| 298 |
|
int sign = 1; |
| 332 |
|
} |
| 333 |
|
|
| 334 |
|
/* Parse program parameters (directives) */ |
| 335 |
< |
static int |
| 335 |
> |
int |
| 336 |
|
parse_params(PARAMS *p, char *pargs) |
| 337 |
|
{ |
| 338 |
|
char *cp = pargs; |
| 410 |
|
return(-1); /* pro forma return */ |
| 411 |
|
} |
| 412 |
|
|
| 413 |
+ |
/* Append bin jitter to the parameter string */ |
| 414 |
+ |
int |
| 415 |
+ |
addbinjitter(char *s) |
| 416 |
+ |
{ |
| 417 |
+ |
if (binjitter == NULL) |
| 418 |
+ |
return(0); |
| 419 |
+ |
s += strlen(s); |
| 420 |
+ |
strcpy(s, ",JTR="); |
| 421 |
+ |
strcpy(s+5, binjitter); |
| 422 |
+ |
return(1); |
| 423 |
+ |
} |
| 424 |
+ |
|
| 425 |
|
/* Add receiver arguments (directives) corresponding to the current modifier */ |
| 426 |
< |
static void |
| 426 |
> |
void |
| 427 |
|
finish_receiver(void) |
| 428 |
|
{ |
| 429 |
|
char sbuf[256]; |
| 485 |
|
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
| 486 |
|
curparams.vup[0], curparams.vup[1], curparams.vup[2], |
| 487 |
|
curparams.sign); |
| 488 |
+ |
addbinjitter(sbuf); |
| 489 |
|
params = savqstr(sbuf); |
| 490 |
|
binv = "scbin"; |
| 491 |
|
nbins = "SCdim*SCdim"; |
| 497 |
|
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
| 498 |
|
curparams.vup[0], curparams.vup[1], curparams.vup[2], |
| 499 |
|
curparams.sign); |
| 500 |
+ |
addbinjitter(sbuf); |
| 501 |
|
params = savqstr(sbuf); |
| 502 |
|
binv = "rbin"; |
| 503 |
|
nbins = "Nrbins"; |
| 526 |
|
curparams.nrm[0], curparams.nrm[1], curparams.nrm[2], |
| 527 |
|
curparams.vup[0], curparams.vup[1], curparams.vup[2], |
| 528 |
|
curparams.sign); |
| 529 |
+ |
addbinjitter(sbuf); |
| 530 |
|
params = savqstr(sbuf); |
| 531 |
|
binv = "cbin"; |
| 532 |
|
nbins = "Ncbins"; |
| 537 |
|
} |
| 538 |
|
if (tolower(curparams.hemis[0]) == 'k') { |
| 539 |
|
sprintf(sbuf, "RHS=%c1", curparams.sign); |
| 540 |
+ |
addbinjitter(sbuf); |
| 541 |
|
params = savqstr(sbuf); |
| 542 |
|
} |
| 543 |
|
if (!uniform) { |
| 582 |
|
} |
| 583 |
|
|
| 584 |
|
/* Make randomly oriented tangent plane axes for given normal direction */ |
| 585 |
< |
static void |
| 585 |
> |
void |
| 586 |
|
make_axes(FVECT uva[2], const FVECT nrm) |
| 587 |
|
{ |
| 588 |
|
int i; |
| 596 |
|
} |
| 597 |
|
|
| 598 |
|
/* Illegal sender surfaces end up here */ |
| 599 |
< |
static int |
| 599 |
> |
int |
| 600 |
|
ssamp_bad(FVECT orig, SURF *sp, double x) |
| 601 |
|
{ |
| 602 |
|
fprintf(stderr, "%s: illegal sender surface '%s'\n", |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
/* Generate origin on ring surface from uniform random variable */ |
| 608 |
< |
static int |
| 608 |
> |
int |
| 609 |
|
ssamp_ring(FVECT orig, SURF *sp, double x) |
| 610 |
|
{ |
| 611 |
|
FVECT *uva = (FVECT *)sp->priv; |
| 634 |
|
} |
| 635 |
|
|
| 636 |
|
/* Add triangle to polygon's list (call-back function) */ |
| 637 |
< |
static int |
| 637 |
> |
int |
| 638 |
|
add_triangle(const Vert2_list *tp, int a, int b, int c) |
| 639 |
|
{ |
| 640 |
|
POLYTRIS *ptp = (POLYTRIS *)tp->p; |
| 647 |
|
} |
| 648 |
|
|
| 649 |
|
/* Generate origin on polygon surface from uniform random variable */ |
| 650 |
< |
static int |
| 650 |
> |
int |
| 651 |
|
ssamp_poly(FVECT orig, SURF *sp, double x) |
| 652 |
|
{ |
| 653 |
|
POLYTRIS *ptp = (POLYTRIS *)sp->priv; |
| 720 |
|
} |
| 721 |
|
|
| 722 |
|
/* Compute sample origin based on projected areas of sender subsurfaces */ |
| 723 |
< |
static int |
| 723 |
> |
int |
| 724 |
|
sample_origin(PARAMS *p, FVECT orig, const FVECT rdir, double x) |
| 725 |
|
{ |
| 726 |
|
static double *projsa; |
| 767 |
|
} |
| 768 |
|
|
| 769 |
|
/* Uniform sample generator */ |
| 770 |
< |
static int |
| 770 |
> |
int |
| 771 |
|
sample_uniform(PARAMS *p, int b, FILE *fp) |
| 772 |
|
{ |
| 773 |
|
int n = sampcnt; |
| 795 |
|
} |
| 796 |
|
|
| 797 |
|
/* Shirly-Chiu sample generator */ |
| 798 |
< |
static int |
| 798 |
> |
int |
| 799 |
|
sample_shirchiu(PARAMS *p, int b, FILE *fp) |
| 800 |
|
{ |
| 801 |
|
int n = sampcnt; |
| 824 |
|
} |
| 825 |
|
|
| 826 |
|
/* Reinhart/Tregenza sample generator */ |
| 827 |
< |
static int |
| 827 |
> |
int |
| 828 |
|
sample_reinhart(PARAMS *p, int b, FILE *fp) |
| 829 |
|
{ |
| 830 |
|
#define T_NALT 7 |
| 876 |
|
} |
| 877 |
|
|
| 878 |
|
/* Klems sample generator */ |
| 879 |
< |
static int |
| 879 |
> |
int |
| 880 |
|
sample_klems(PARAMS *p, int b, FILE *fp) |
| 881 |
|
{ |
| 882 |
|
static const char bname[4][20] = { |
| 925 |
|
} |
| 926 |
|
|
| 927 |
|
/* Prepare hemisphere basis sampler that will send rays to rcontrib */ |
| 928 |
< |
static int |
| 928 |
> |
int |
| 929 |
|
prepare_sampler(PARAMS *p) |
| 930 |
|
{ |
| 931 |
|
if (p->slist == NULL) { /* missing sample surface! */ |
| 1009 |
|
} |
| 1010 |
|
|
| 1011 |
|
/* Compute normal and area for polygon */ |
| 1012 |
< |
static int |
| 1012 |
> |
int |
| 1013 |
|
finish_polygon(SURF *p) |
| 1014 |
|
{ |
| 1015 |
|
const int nv = p->nfargs / 3; |
| 1031 |
|
} |
| 1032 |
|
|
| 1033 |
|
/* Add a surface to our current parameters */ |
| 1034 |
< |
static void |
| 1034 |
> |
void |
| 1035 |
|
add_surface(int st, const char *oname, FILE *fp) |
| 1036 |
|
{ |
| 1037 |
|
SURF *snew; |
| 1112 |
|
} |
| 1113 |
|
|
| 1114 |
|
/* Parse a receiver object (look for modifiers to add to rcontrib command) */ |
| 1115 |
< |
static int |
| 1115 |
> |
int |
| 1116 |
|
add_recv_object(FILE *fp) |
| 1117 |
|
{ |
| 1118 |
|
int st; |
| 1150 |
|
} |
| 1151 |
|
|
| 1152 |
|
/* Parse a sender object */ |
| 1153 |
< |
static int |
| 1153 |
> |
int |
| 1154 |
|
add_send_object(FILE *fp) |
| 1155 |
|
{ |
| 1156 |
|
int st; |
| 1194 |
|
} |
| 1195 |
|
|
| 1196 |
|
/* Load a Radiance scene using the given callback function for objects */ |
| 1197 |
< |
static int |
| 1197 |
> |
int |
| 1198 |
|
load_scene(const char *inspec, int (*ocb)(FILE *)) |
| 1199 |
|
{ |
| 1200 |
|
int rv = 0; |
| 1258 |
|
char *xrs=NULL, *yrs=NULL, *ldopt=NULL; |
| 1259 |
|
char *iropt = NULL; |
| 1260 |
|
char *sendfn; |
| 1261 |
< |
char sampcntbuf[32], nsbinbuf[32]; |
| 1261 |
> |
char sampcntbuf[32], nsbinbuf[32], binjitbuf[32]; |
| 1262 |
|
FILE *rcfp; |
| 1263 |
|
int nsbins; |
| 1264 |
|
int a, i; |
| 1353 |
|
na = 2; |
| 1354 |
|
break; |
| 1355 |
|
case 'b': /* special case */ |
| 1356 |
+ |
if (argv[a][2] == 'j') { |
| 1357 |
+ |
binjitter = argv[++a]; |
| 1358 |
+ |
na = 0; |
| 1359 |
+ |
continue; |
| 1360 |
+ |
} |
| 1361 |
|
if (argv[a][2] != 'v') goto userr; |
| 1362 |
|
break; |
| 1363 |
|
case 'l': /* special case */ |
| 1478 |
|
userr: |
| 1479 |
|
if (a < argc-2) |
| 1480 |
|
fprintf(stderr, "%s: unsupported option '%s'\n", progname, argv[a]); |
| 1481 |
< |
fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n", |
| 1481 |
> |
fprintf(stderr, "Usage: %s [-v][-bj frac][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n", |
| 1482 |
|
progname); |
| 1483 |
|
return(1); |
| 1484 |
|
} |