45 |
|
extern int hresolu; /* horizontal resolution */ |
46 |
|
extern int vresolu; /* vertical resolution */ |
47 |
|
|
48 |
< |
static int castonly = 0; |
48 |
> |
int castonly = 0; /* only doing ray-casting? */ |
49 |
|
|
50 |
|
#ifndef MAXTSET |
51 |
|
#define MAXTSET 8191 /* maximum number in trace set */ |
68 |
|
oputr, oputR, oputx, oputX, oputn, oputN, oputs, |
69 |
|
oputw, oputW, oputm, oputM, oputtilde; |
70 |
|
|
71 |
– |
static void setoutput(char *vs); |
71 |
|
extern void tranotify(OBJECT obj); |
72 |
+ |
static int is_fifo(FILE *fp); |
73 |
|
static void bogusray(void); |
74 |
|
static void raycast(RAY *r); |
75 |
|
static void rayirrad(RAY *r); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
< |
extern void |
120 |
> |
void |
121 |
|
rtrace( /* trace rays from file */ |
122 |
|
char *fname, |
123 |
|
int nproc |
144 |
|
if (inform != 'a') |
145 |
|
SET_FILE_BINARY(inpfp); |
146 |
|
/* set up output */ |
147 |
< |
if (imm_irrad) |
148 |
< |
castonly = 0; |
149 |
< |
else if (castonly || every_out[0] != NULL) |
147 |
> |
if (castonly || every_out[0] != NULL) |
148 |
|
nproc = 1; /* don't bother multiprocessing */ |
149 |
|
if ((nextflush > 0) & (nproc > nextflush)) { |
150 |
|
error(WARNING, "reducing number of processes to match flush interval"); |
164 |
|
if (nproc > 1) { /* start multiprocessing */ |
165 |
|
ray_popen(nproc); |
166 |
|
ray_fifo_out = printvals; |
167 |
+ |
ray_pnbatch = 1; /* optimize for throughput */ |
168 |
|
} |
169 |
|
if (hresolu > 0) { |
170 |
|
if (vresolu > 0) |
236 |
|
if (!*vs) |
237 |
|
error(USER, "empty output specification"); |
238 |
|
|
239 |
< |
castonly = 1; |
239 |
> |
castonly = 1; /* sets castonly as side-effect */ |
240 |
|
do |
241 |
|
switch (*vs) { |
242 |
|
case 'T': /* trace sources */ |
286 |
|
case 'V': /* contribution */ |
287 |
|
*table++ = oputV; |
288 |
|
ncomp += 3; |
289 |
+ |
castonly = 0; |
290 |
|
if (ambounce > 0 && (ambacc > FTINY || ambssamp > 0)) |
291 |
|
error(WARNING, |
292 |
|
"-otV accuracy depends on -aa 0 -as 0"); |
354 |
|
if (*every_out != NULL) |
355 |
|
ncomp = 0; |
356 |
|
/* compatibility */ |
357 |
+ |
if ((do_irrad | imm_irrad) && castonly) |
358 |
+ |
error(USER, "-I+ and -i+ options require some value output"); |
359 |
|
for (table = ray_out; *table != NULL; table++) { |
360 |
|
if ((*table == oputV) | (*table == oputW)) |
361 |
|
error(WARNING, "-oVW options require trace mode"); |
463 |
|
|
464 |
|
|
465 |
|
static int |
466 |
+ |
is_fifo( /* check if file pointer connected to pipe */ |
467 |
+ |
FILE *fp |
468 |
+ |
) |
469 |
+ |
{ |
470 |
+ |
#ifdef S_ISFIFO |
471 |
+ |
struct stat sbuf; |
472 |
+ |
|
473 |
+ |
if (fstat(fileno(fp), &sbuf) < 0) |
474 |
+ |
error(SYSTEM, "fstat() failed on input stream"); |
475 |
+ |
return(S_ISFIFO(sbuf.st_mode)); |
476 |
+ |
#else |
477 |
+ |
return (fp == stdin); /* just a guess, really */ |
478 |
+ |
#endif |
479 |
+ |
} |
480 |
+ |
|
481 |
+ |
|
482 |
+ |
static int |
483 |
|
getvec( /* get a vector from fp */ |
484 |
|
FVECT vec, |
485 |
|
int fmt, |
543 |
|
int rsiz = 6*20; /* conservative ascii ray size */ |
544 |
|
if (inform == 'f') rsiz = 6*sizeof(float); |
545 |
|
else if (inform == 'd') rsiz = 6*sizeof(double); |
546 |
< |
if ((inpfp == stdin) & (qlength*rsiz > 512)) /* pipe limit */ |
546 |
> |
/* check against pipe limit */ |
547 |
> |
if (qlength*rsiz > 512 && is_fifo(inpfp)) |
548 |
|
inp_queue = (FVECT *)malloc(sizeof(FVECT)*2*qlength); |
549 |
|
inp_qend = -(inp_queue == NULL); /* flag for no queue */ |
550 |
|
} |