11 |
|
#include <stdlib.h> |
12 |
|
#include "rtio.h" |
13 |
|
#include "rtmath.h" |
14 |
+ |
#include "rtprocess.h" |
15 |
|
#include "bsdf.h" |
16 |
|
#include "bsdf_m.h" |
17 |
|
#include "random.h" |
36 |
|
|
37 |
|
char *progname; /* global argv[0] */ |
38 |
|
|
39 |
< |
int verbose = 0; /* verbose mode? */ |
39 |
> |
int verbose = 0; /* verbose mode (< 0 no warnings) */ |
40 |
|
|
41 |
|
char *rcarg[MAXRCARG+1] = {"rcontrib", "-fo+"}; |
42 |
|
int nrcargs = 2; |
145 |
|
static char * |
146 |
|
oconv_command(int ac, char *av[]) |
147 |
|
{ |
148 |
< |
static char oconvbuf[2048] = "!oconv -f"; |
149 |
< |
char *cp = oconvbuf + 9; |
150 |
< |
|
148 |
> |
static char oconvbuf[2048] = "!oconv -f "; |
149 |
> |
char *cp = oconvbuf + 10; |
150 |
> |
char *recv = *av++; |
151 |
> |
|
152 |
> |
if (ac-- <= 0) |
153 |
> |
return(NULL); |
154 |
|
while (ac-- > 0) { |
155 |
+ |
strcpy(cp, *av++); |
156 |
+ |
while (*cp) cp++; |
157 |
+ |
*cp++ = ' '; |
158 |
|
if (cp >= oconvbuf+(sizeof(oconvbuf)-32)) { |
159 |
|
fputs(progname, stderr); |
160 |
|
fputs(": too many file arguments!\n", stderr); |
161 |
|
exit(1); |
162 |
|
} |
156 |
– |
*cp++ = ' '; |
157 |
– |
strcpy(cp, *av++); |
158 |
– |
while (*cp) cp++; |
163 |
|
} |
164 |
< |
*cp = '\0'; |
164 |
> |
strcpy(cp, recv); /* receiver goes last */ |
165 |
|
return(oconvbuf); |
166 |
|
} |
167 |
|
|
226 |
|
fputs(": command line too long in popen_arglist()\n", stderr); |
227 |
|
return(NULL); |
228 |
|
} |
229 |
< |
if (verbose) |
229 |
> |
if (verbose > 0) |
230 |
|
fprintf(stderr, "%s: opening pipe %s: %s\n", |
231 |
|
progname, (*mode=='w') ? "to" : "from", cmd); |
232 |
|
return(popen(cmd, mode)); |
244 |
|
fputs(": command line too long in my_exec()\n", stderr); |
245 |
|
return(1); |
246 |
|
} |
247 |
< |
if (verbose) |
247 |
> |
if (verbose > 0) |
248 |
|
fprintf(stderr, "%s: running: %s\n", progname, cmd); |
249 |
|
return(system(cmd)); |
250 |
|
} |
259 |
|
fprintf(stderr, "%s: cannot locate %s\n", progname, av[0]); |
260 |
|
return(1); |
261 |
|
} |
262 |
< |
if (verbose) { |
262 |
> |
if (verbose > 0) { |
263 |
|
char cmd[4096]; |
264 |
|
if (!convert_commandline(cmd, sizeof(cmd), av)) |
265 |
|
strcpy(cmd, "COMMAND TOO LONG TO SHOW"); |
319 |
|
int nparams = 0; |
320 |
|
int i; |
321 |
|
|
322 |
< |
for ( ; ; ) |
322 |
> |
for ( ; ; ) { |
323 |
|
switch (*cp++) { |
324 |
|
case 'h': |
325 |
|
if (*cp++ != '=') |
342 |
|
break; |
343 |
|
if (!get_direction(p->vup, cp)) |
344 |
|
break; |
345 |
+ |
while (*cp && !isspace(*cp++)) |
346 |
+ |
; |
347 |
|
++nparams; |
348 |
|
continue; |
349 |
|
case 'o': |
362 |
|
case ' ': |
363 |
|
case '\t': |
364 |
|
case '\r': |
359 |
– |
case '\n': |
365 |
|
continue; |
366 |
+ |
case '\n': |
367 |
|
case '\0': |
368 |
|
return(nparams); |
369 |
|
default: |
370 |
|
break; |
371 |
|
} |
372 |
< |
fprintf(stderr, "%s: bad parameter string '%s'\n", progname, pargs); |
372 |
> |
break; |
373 |
> |
} |
374 |
> |
fprintf(stderr, "%s: bad parameter string: %s", progname, pargs); |
375 |
|
exit(1); |
376 |
|
return(-1); /* pro forma return */ |
377 |
|
} |
844 |
|
|
845 |
|
while (n--) { /* stratified sampling */ |
846 |
|
SDmultiSamp(samp2, 2, (n+frandom())/sampcnt); |
847 |
< |
if (!bo_getvec(duvw, b+samp2[1], kbasis[bi])) |
847 |
> |
if (!bi_getvec(duvw, b+samp2[1], kbasis[bi])) |
848 |
|
return(0); |
849 |
|
for (i = 3; i--; ) |
850 |
|
orig_dir[1][i] = duvw[0]*p->udir[i] + |
867 |
|
fputs(": no sender surface!\n", stderr); |
868 |
|
return(-1); |
869 |
|
} |
870 |
< |
if (curparams.outfn != NULL) /* misplaced output file spec. */ |
870 |
> |
/* misplaced output file spec. */ |
871 |
> |
if ((curparams.outfn != NULL) & (verbose >= 0)) |
872 |
|
fprintf(stderr, "%s: warning - ignoring output file in sender ('%s')\n", |
873 |
|
progname, curparams.outfn); |
874 |
|
/* check/set basis hemisphere */ |
1019 |
|
snew->area *= PI*snew->area; |
1020 |
|
break; |
1021 |
|
} |
1022 |
< |
if (snew->area <= FTINY) { |
1022 |
> |
if ((snew->area <= FTINY) & (verbose >= 0)) { |
1023 |
|
fprintf(stderr, "%s: warning - zero area for surface '%s'\n", |
1024 |
|
progname, oname); |
1025 |
|
free(snew); |
1191 |
|
int a, i; |
1192 |
|
/* screen rcontrib options */ |
1193 |
|
progname = argv[0]; |
1194 |
< |
for (a = 1; a < argc-2 && argv[a][0] == '-'; a++) { |
1195 |
< |
int na = 1; /* !! Keep consistent !! */ |
1196 |
< |
switch (argv[a][1]) { |
1194 |
> |
for (a = 1; a < argc-2; a++) { |
1195 |
> |
int na; |
1196 |
> |
/* check for argument expansion */ |
1197 |
> |
while ((na = expandarg(&argc, &argv, a)) > 0) |
1198 |
> |
; |
1199 |
> |
if (na < 0) { |
1200 |
> |
fprintf(stderr, "%s: cannot expand '%s'\n", |
1201 |
> |
progname, argv[a]); |
1202 |
> |
return(1); |
1203 |
> |
} |
1204 |
> |
if (argv[a][0] != '-' || !argv[a][1]) |
1205 |
> |
break; |
1206 |
> |
na = 1; |
1207 |
> |
switch (argv[a][1]) { /* !! Keep consistent !! */ |
1208 |
|
case 'v': /* verbose mode */ |
1209 |
< |
verbose = !verbose; |
1209 |
> |
verbose = 1; |
1210 |
|
na = 0; |
1211 |
|
continue; |
1212 |
|
case 'f': /* special case for -fo, -ff, etc. */ |
1247 |
|
iropt = argv[a]; |
1248 |
|
na = 0; |
1249 |
|
continue; |
1250 |
< |
case 'V': /* options without arguments */ |
1251 |
< |
case 'w': |
1250 |
> |
case 'w': /* options without arguments */ |
1251 |
> |
if (argv[a][2] != '+') verbose = -1; |
1252 |
> |
case 'V': |
1253 |
|
case 'u': |
1254 |
|
case 'h': |
1255 |
|
case 'r': |
1280 |
|
if (!argv[a][2]) goto userr; |
1281 |
|
na = (argv[a][2] == 'e') | (argv[a][2] == 'a') ? 4 : 2; |
1282 |
|
break; |
1262 |
– |
case '\0': /* pass-through mode */ |
1263 |
– |
goto done_opts; |
1283 |
|
default: /* anything else is verbotten */ |
1284 |
|
goto userr; |
1285 |
|
} |
1289 |
|
while (--na) /* + arguments if any */ |
1290 |
|
rcarg[nrcargs++] = argv[++a]; |
1291 |
|
} |
1273 |
– |
done_opts: |
1292 |
|
if (a > argc-2) |
1293 |
|
goto userr; /* check at end of options */ |
1294 |
|
sendfn = argv[a++]; /* assign sender & receiver inputs */ |
1370 |
|
userr: |
1371 |
|
if (a < argc-2) |
1372 |
|
fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]); |
1373 |
< |
fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n", |
1373 |
> |
fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [-i system.oct] [system.rad ..]\n", |
1374 |
|
progname); |
1375 |
|
return(1); |
1376 |
|
} |