27 |
|
#define OBJECT 0 /* object files */ |
28 |
|
#define SCENE 1 /* scene files */ |
29 |
|
#define MATERIAL 2 /* material files */ |
30 |
< |
#define RENDER 3 /* rendering options */ |
31 |
< |
#define OCONV 4 /* oconv options */ |
32 |
< |
#define PFILT 5 /* pfilt options */ |
33 |
< |
#define VIEW 6 /* view(s) for picture(s) */ |
34 |
< |
#define ZONE 7 /* simulation zone */ |
35 |
< |
#define QUALITY 8 /* desired rendering quality */ |
36 |
< |
#define OCTREE 9 /* octree file name */ |
37 |
< |
#define PICTURE 10 /* picture file name */ |
38 |
< |
#define AMBFILE 11 /* ambient file name */ |
39 |
< |
#define OPTFILE 12 /* rendering options file */ |
40 |
< |
#define EXPOSURE 13 /* picture exposure setting */ |
41 |
< |
#define RESOLUTION 14 /* maximum picture resolution */ |
42 |
< |
#define UP 15 /* view up (X, Y or Z) */ |
43 |
< |
#define INDIRECT 16 /* indirection in lighting */ |
44 |
< |
#define DETAIL 17 /* level of scene detail */ |
45 |
< |
#define PENUMBRAS 18 /* shadow penumbras are desired */ |
46 |
< |
#define VARIABILITY 19 /* level of light variability */ |
47 |
< |
#define REPORT 20 /* report frequency and errfile */ |
30 |
> |
#define ILLUM 3 /* mkillum input files */ |
31 |
> |
#define MKILLUM 4 /* mkillum options */ |
32 |
> |
#define RENDER 5 /* rendering options */ |
33 |
> |
#define OCONV 6 /* oconv options */ |
34 |
> |
#define PFILT 7 /* pfilt options */ |
35 |
> |
#define VIEW 8 /* view(s) for picture(s) */ |
36 |
> |
#define ZONE 9 /* simulation zone */ |
37 |
> |
#define QUALITY 10 /* desired rendering quality */ |
38 |
> |
#define OCTREE 11 /* octree file name */ |
39 |
> |
#define PICTURE 12 /* picture file name */ |
40 |
> |
#define AMBFILE 13 /* ambient file name */ |
41 |
> |
#define OPTFILE 14 /* rendering options file */ |
42 |
> |
#define EXPOSURE 15 /* picture exposure setting */ |
43 |
> |
#define RESOLUTION 16 /* maximum picture resolution */ |
44 |
> |
#define UP 17 /* view up (X, Y or Z) */ |
45 |
> |
#define INDIRECT 18 /* indirection in lighting */ |
46 |
> |
#define DETAIL 19 /* level of scene detail */ |
47 |
> |
#define PENUMBRAS 20 /* shadow penumbras are desired */ |
48 |
> |
#define VARIABILITY 21 /* level of light variability */ |
49 |
> |
#define REPORT 22 /* report frequency and errfile */ |
50 |
|
/* total number of variables */ |
51 |
< |
#define NVARS 21 |
51 |
> |
#define NVARS 23 |
52 |
|
|
53 |
|
VARIABLE vv[NVARS] = { /* variable-value pairs */ |
54 |
|
{"objects", 3, 0, NULL, catvalues}, |
55 |
|
{"scene", 3, 0, NULL, catvalues}, |
56 |
|
{"materials", 3, 0, NULL, catvalues}, |
57 |
+ |
{"illum", 3, 0, NULL, catvalues}, |
58 |
+ |
{"mkillum", 3, 0, NULL, catvalues}, |
59 |
|
{"render", 3, 0, NULL, catvalues}, |
60 |
|
{"oconv", 3, 0, NULL, catvalues}, |
61 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
98 |
|
|
99 |
|
#define renderopts (*setqopts[vscale(QUALITY)]) |
100 |
|
|
101 |
< |
extern long fdate(), time(); |
101 |
> |
/* overture calculation file */ |
102 |
> |
#ifdef NIX |
103 |
> |
char overfile[] = "overture.raw"; |
104 |
> |
#else |
105 |
> |
char overfile[] = "/dev/null"; |
106 |
> |
#endif |
107 |
|
|
108 |
< |
long scenedate; /* date of latest scene or object file */ |
100 |
< |
long octreedate; /* date of octree */ |
108 |
> |
extern unsigned long fdate(), time(); |
109 |
|
|
110 |
+ |
unsigned long scenedate; /* date of latest scene or object file */ |
111 |
+ |
unsigned long octreedate; /* date of octree */ |
112 |
+ |
unsigned long matdate; /* date of latest material file */ |
113 |
+ |
unsigned long illumdate; /* date of last illum file */ |
114 |
+ |
|
115 |
+ |
char *oct0name; /* name of pre-mkillum octree */ |
116 |
+ |
unsigned long oct0date; /* date of pre-mkillum octree */ |
117 |
+ |
char *oct1name; /* name of post-mkillum octree */ |
118 |
+ |
unsigned long oct1date; /* date of post-mkillum octree (>= matdate) */ |
119 |
+ |
|
120 |
|
int explicate = 0; /* explicate variables */ |
121 |
|
int silent = 0; /* do work silently */ |
122 |
|
int noaction = 0; /* don't do anything */ |
123 |
+ |
int sayview = 0; /* print view out */ |
124 |
|
char *rvdevice = NULL; /* rview output device */ |
125 |
|
char *viewselect = NULL; /* specific view only */ |
126 |
|
|
127 |
|
int overture = 0; /* overture calculation needed */ |
128 |
|
|
129 |
|
char *progname; /* global argv[0] */ |
130 |
+ |
char *rifname; /* global rad input file name */ |
131 |
|
|
132 |
|
char radname[MAXPATH]; /* root Radiance file name */ |
133 |
|
|
155 |
|
case 'o': |
156 |
|
rvdevice = argv[++i]; |
157 |
|
break; |
158 |
+ |
case 'V': |
159 |
+ |
sayview++; |
160 |
+ |
break; |
161 |
|
case 'v': |
162 |
|
viewselect = argv[++i]; |
163 |
|
break; |
166 |
|
} |
167 |
|
if (i >= argc) |
168 |
|
goto userr; |
169 |
+ |
rifname = argv[i]; |
170 |
|
/* assign Radiance root file name */ |
171 |
< |
rootname(radname, argv[i]); |
171 |
> |
rootname(radname, rifname); |
172 |
|
/* load variable values */ |
173 |
< |
load(argv[i]); |
173 |
> |
load(rifname); |
174 |
|
/* get any additional assignments */ |
175 |
|
for (i++; i < argc; i++) |
176 |
|
setvariable(argv[i]); |
183 |
|
/* print all values if requested */ |
184 |
|
if (explicate) |
185 |
|
printvals(); |
186 |
< |
/* run simulation */ |
186 |
> |
/* build octree (and run mkillum) */ |
187 |
|
oconv(); |
188 |
+ |
/* check date on ambient file */ |
189 |
+ |
checkambfile(); |
190 |
+ |
/* run simulation */ |
191 |
|
renderopts(ropts); |
192 |
|
xferopts(ropts); |
193 |
|
if (rvdevice != NULL) |
197 |
|
exit(0); |
198 |
|
userr: |
199 |
|
fprintf(stderr, |
200 |
< |
"Usage: %s [-s][-n][-e][-v view][-o dev] rfile [VAR=value ..]\n", |
200 |
> |
"Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
201 |
|
progname); |
202 |
|
exit(1); |
203 |
|
} |
218 |
|
} |
219 |
|
|
220 |
|
|
221 |
+ |
#define NOCHAR 127 /* constant for character to delete */ |
222 |
+ |
|
223 |
+ |
|
224 |
|
load(rfname) /* load Radiance simulation file */ |
225 |
|
char *rfname; |
226 |
|
{ |
227 |
|
FILE *fp; |
228 |
< |
char buf[256]; |
228 |
> |
char buf[512]; |
229 |
|
register char *cp; |
230 |
|
|
231 |
|
if (rfname == NULL) |
236 |
|
for (cp = buf; *cp; cp++) { |
237 |
|
switch (*cp) { |
238 |
|
case '\\': |
239 |
< |
case '\n': |
210 |
< |
*cp = ' '; |
239 |
> |
*cp++ = NOCHAR; |
240 |
|
continue; |
241 |
|
case '#': |
242 |
|
*cp = '\0'; |
243 |
|
break; |
244 |
+ |
default: |
245 |
+ |
continue; |
246 |
|
} |
247 |
|
break; |
248 |
|
} |
256 |
|
register char *ass; |
257 |
|
{ |
258 |
|
char varname[32]; |
259 |
+ |
char varval[512]; |
260 |
+ |
int n; |
261 |
|
register char *cp; |
262 |
|
register VARIABLE *vp; |
263 |
|
register int i; |
231 |
– |
int n; |
264 |
|
|
265 |
|
while (isspace(*ass)) /* skip leading space */ |
266 |
|
ass++; |
274 |
|
/* trim value */ |
275 |
|
while (isspace(*ass) || *ass == '=') |
276 |
|
ass++; |
277 |
< |
cp = ass + strlen(ass); |
278 |
< |
do |
279 |
< |
*cp-- = '\0'; |
248 |
< |
while (cp >= ass && isspace(*cp)); |
249 |
< |
n = cp - ass + 1; |
277 |
> |
for (n = strlen(ass); n > 0; n--) |
278 |
> |
if (!isspace(ass[n-1])) |
279 |
> |
break; |
280 |
|
if (!n) { |
281 |
|
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
282 |
|
progname, varname); |
290 |
|
exit(1); |
291 |
|
} |
292 |
|
/* assign new value */ |
293 |
< |
cp = vp->value; i = vp->nass; |
294 |
< |
while (i--) |
295 |
< |
while (*cp++) |
296 |
< |
; |
297 |
< |
i = cp - vp->value; |
298 |
< |
vp->value = realloc(vp->value, i+n+1); |
293 |
> |
if (i = vp->nass) { |
294 |
> |
cp = vp->value; |
295 |
> |
while (i--) |
296 |
> |
while (*cp++) |
297 |
> |
; |
298 |
> |
i = cp - vp->value; |
299 |
> |
vp->value = realloc(vp->value, i+n+1); |
300 |
> |
} else |
301 |
> |
vp->value = malloc(n+1); |
302 |
|
if (vp->value == NULL) |
303 |
|
syserr(progname); |
304 |
< |
strcpy(vp->value+i, ass); |
304 |
> |
cp = vp->value+i; /* copy value, squeezing spaces */ |
305 |
> |
*cp = *ass; |
306 |
> |
for (i = 1; i <= n; i++) { |
307 |
> |
if (ass[i] == NOCHAR) |
308 |
> |
continue; |
309 |
> |
if (isspace(*cp)) |
310 |
> |
while (isspace(ass[i])) |
311 |
> |
i++; |
312 |
> |
*++cp = ass[i]; |
313 |
> |
} |
314 |
> |
if (isspace(*cp)) /* remove trailing space */ |
315 |
> |
*cp = '\0'; |
316 |
|
vp->nass++; |
317 |
|
} |
318 |
|
|
338 |
|
{ |
339 |
|
register char *cp; |
340 |
|
|
341 |
< |
if (vp == NULL || n < 0 || n >= vp->nass) |
341 |
> |
if (vp == NULL | n < 0 | n >= vp->nass) |
342 |
|
return(NULL); |
343 |
|
cp = vp->value; |
344 |
|
while (n--) |
402 |
|
} |
403 |
|
|
404 |
|
|
405 |
< |
long |
405 |
> |
unsigned long |
406 |
|
checklast(fnames) /* check files and find most recent */ |
407 |
|
register char *fnames; |
408 |
|
{ |
409 |
|
char thisfile[MAXPATH]; |
410 |
< |
long thisdate, lastdate = -1; |
410 |
> |
unsigned long thisdate, lastdate = 0; |
411 |
|
register char *cp; |
412 |
|
|
413 |
+ |
if (fnames == NULL) |
414 |
+ |
return(0); |
415 |
|
while (*fnames) { |
416 |
|
while (isspace(*fnames)) fnames++; |
417 |
|
cp = thisfile; |
418 |
< |
while (*fnames && !isspace(*fnames)) *cp++ = *fnames++; |
418 |
> |
while (*fnames && !isspace(*fnames)) |
419 |
> |
*cp++ = *fnames++; |
420 |
|
*cp = '\0'; |
421 |
< |
if ((thisdate = fdate(thisfile)) < 0) |
421 |
> |
if (!(thisdate = fdate(thisfile))) |
422 |
|
syserr(thisfile); |
423 |
|
if (thisdate > lastdate) |
424 |
|
lastdate = thisdate; |
427 |
|
} |
428 |
|
|
429 |
|
|
430 |
+ |
char * |
431 |
+ |
newfname(orig, pred) /* create modified file name */ |
432 |
+ |
char *orig; |
433 |
+ |
int pred; |
434 |
+ |
{ |
435 |
+ |
extern char *rindex(); |
436 |
+ |
register char *cp; |
437 |
+ |
register int n; |
438 |
+ |
int suffix; |
439 |
+ |
|
440 |
+ |
suffix = n = strlen(orig); /* find start of suffix */ |
441 |
+ |
if ((cp = rindex(orig, '.')) != NULL) |
442 |
+ |
suffix = cp - orig; |
443 |
+ |
if ((cp = bmalloc(n+2)) == NULL) |
444 |
+ |
syserr(progname); |
445 |
+ |
strncpy(cp, orig, suffix); |
446 |
+ |
cp[suffix] = pred; /* root name + pred + suffix */ |
447 |
+ |
strcpy(cp+suffix+1, orig+suffix); |
448 |
+ |
return(cp); |
449 |
+ |
} |
450 |
+ |
|
451 |
+ |
|
452 |
|
checkfiles() /* check for existence and modified times */ |
453 |
|
{ |
454 |
< |
char *cp; |
386 |
< |
long objdate; |
454 |
> |
unsigned long objdate; |
455 |
|
|
456 |
|
if (!vdef(OCTREE)) { |
457 |
< |
if ((cp = bmalloc(strlen(radname)+5)) == NULL) |
457 |
> |
if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL) |
458 |
|
syserr(progname); |
459 |
< |
sprintf(cp, "%s.oct", radname); |
392 |
< |
vval(OCTREE) = cp; |
459 |
> |
sprintf(vval(OCTREE), "%s.oct", radname); |
460 |
|
vdef(OCTREE)++; |
461 |
|
} |
462 |
|
octreedate = fdate(vval(OCTREE)); |
463 |
< |
scenedate = -1; |
464 |
< |
if (vdef(SCENE)) { |
465 |
< |
scenedate = checklast(vval(SCENE)); |
466 |
< |
if (vdef(OBJECT)) { |
467 |
< |
objdate = checklast(vval(OBJECT)); |
468 |
< |
if (objdate > scenedate) |
469 |
< |
scenedate = objdate; |
470 |
< |
} |
471 |
< |
} |
472 |
< |
if (octreedate < 0 & scenedate < 0) { |
473 |
< |
fprintf(stderr, "%s: need '%s' or '%s'\n", progname, |
474 |
< |
vnam(OCTREE), vnam(SCENE)); |
463 |
> |
if (vdef(ILLUM)) { /* illum requires secondary octrees */ |
464 |
> |
oct0name = newfname(vval(OCTREE), '0'); |
465 |
> |
oct1name = newfname(vval(OCTREE), '1'); |
466 |
> |
oct0date = fdate(oct0name); |
467 |
> |
oct1date = fdate(oct1name); |
468 |
> |
} else |
469 |
> |
oct0name = oct1name = vval(OCTREE); |
470 |
> |
if ((scenedate = checklast(vval(SCENE))) && |
471 |
> |
(objdate = checklast(vval(OBJECT))) > scenedate) |
472 |
> |
scenedate = objdate; |
473 |
> |
illumdate = checklast(vval(ILLUM)); |
474 |
> |
if (!octreedate & !scenedate & !illumdate) { |
475 |
> |
fprintf(stderr, "%s: need '%s' or '%s' or '%s'\n", progname, |
476 |
> |
vnam(OCTREE), vnam(SCENE), vnam(ILLUM)); |
477 |
|
exit(1); |
478 |
|
} |
479 |
+ |
matdate = checklast(vval(MATERIAL)); |
480 |
|
} |
481 |
|
|
482 |
|
|
485 |
|
{ |
486 |
|
extern FILE *popen(); |
487 |
|
static double oorg[3], osiz = 0.; |
488 |
< |
char buf[MAXPATH+16]; |
488 |
> |
double min[3], max[3]; |
489 |
> |
char buf[512]; |
490 |
|
FILE *fp; |
491 |
+ |
register int i; |
492 |
|
|
493 |
< |
if (osiz <= FTINY) { |
494 |
< |
oconv(); /* does nothing if done already */ |
495 |
< |
sprintf(buf, "getinfo -d < %s", vval(OCTREE)); |
496 |
< |
if ((fp = popen(buf, "r")) == NULL) |
497 |
< |
syserr("getinfo"); |
498 |
< |
if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1], |
499 |
< |
&oorg[2], &osiz) != 4) { |
500 |
< |
fprintf(stderr, |
493 |
> |
if (osiz <= FTINY) |
494 |
> |
if (noaction && fdate(oct1name) < |
495 |
> |
(scenedate>illumdate?scenedate:illumdate)) { |
496 |
> |
/* run getbbox */ |
497 |
> |
sprintf(buf, "getbbox -w -h %s", |
498 |
> |
vdef(SCENE) ? vval(SCENE) : vval(ILLUM)); |
499 |
> |
if ((fp = popen(buf, "r")) == NULL) |
500 |
> |
syserr("getbbox"); |
501 |
> |
if (fscanf(fp, "%lf %lf %lf %lf %lf %lf", |
502 |
> |
&min[0], &max[0], &min[1], &max[1], |
503 |
> |
&min[2], &max[2]) != 6) { |
504 |
> |
fprintf(stderr, |
505 |
> |
"%s: error reading bounding box from getbbox\n", |
506 |
> |
progname); |
507 |
> |
exit(1); |
508 |
> |
} |
509 |
> |
for (i = 0; i < 3; i++) |
510 |
> |
if (max[i] - min[i] > osiz) |
511 |
> |
osiz = max[i] - min[i]; |
512 |
> |
for (i = 0; i < 3; i++) |
513 |
> |
oorg[i] = (max[i]+min[i]-osiz)*.5; |
514 |
> |
pclose(fp); |
515 |
> |
} else { /* from octree */ |
516 |
> |
oconv(); /* does nothing if done already */ |
517 |
> |
sprintf(buf, "getinfo -d < %s", oct1name); |
518 |
> |
if ((fp = popen(buf, "r")) == NULL) |
519 |
> |
syserr("getinfo"); |
520 |
> |
if (fscanf(fp, "%lf %lf %lf %lf", &oorg[0], &oorg[1], |
521 |
> |
&oorg[2], &osiz) != 4) { |
522 |
> |
fprintf(stderr, |
523 |
|
"%s: error reading bounding cube from getinfo\n", |
524 |
< |
progname); |
525 |
< |
exit(1); |
524 |
> |
progname); |
525 |
> |
exit(1); |
526 |
> |
} |
527 |
> |
pclose(fp); |
528 |
|
} |
433 |
– |
pclose(fp); |
434 |
– |
} |
529 |
|
org[0] = oorg[0]; org[1] = oorg[1]; org[2] = oorg[2]; *sizp = osiz; |
530 |
|
} |
531 |
|
|
582 |
|
register int i, j; |
583 |
|
|
584 |
|
for (i = 0; i < NVARS; i++) |
585 |
< |
for (j = 0; j < vv[i].nass; j++) |
586 |
< |
printf("%s= %s\n", vv[i].name, nvalue(vv+i, j)); |
585 |
> |
for (j = 0; j < vdef(i); j++) |
586 |
> |
printf("%s= %s\n", vnam(i), nvalue(vv+i, j)); |
587 |
|
fflush(stdout); |
588 |
|
} |
589 |
|
|
590 |
|
|
591 |
< |
oconv() /* run oconv if necessary */ |
591 |
> |
oconv() /* run oconv and mkillum if necessary */ |
592 |
|
{ |
593 |
< |
char combuf[512], ocopts[64]; |
593 |
> |
static char illumtmp[] = "ilXXXXXX"; |
594 |
> |
char combuf[512], ocopts[64], mkopts[64]; |
595 |
|
|
596 |
< |
if (octreedate >= scenedate) /* check dates */ |
597 |
< |
return; |
598 |
< |
/* build command */ |
599 |
< |
oconvopts(ocopts); |
600 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
601 |
< |
vdef(MATERIAL) ? vval(MATERIAL) : "", |
602 |
< |
vval(SCENE), vval(OCTREE)); |
603 |
< |
if (!silent) { /* echo it */ |
604 |
< |
printf("\t%s\n", combuf); |
605 |
< |
fflush(stdout); |
596 |
> |
oconvopts(ocopts); /* get options */ |
597 |
> |
if (octreedate < scenedate) { /* check date on original octree */ |
598 |
> |
/* build command */ |
599 |
> |
if (vdef(MATERIAL)) |
600 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
601 |
> |
vval(MATERIAL), vval(SCENE), vval(OCTREE)); |
602 |
> |
else |
603 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
604 |
> |
vval(SCENE), vval(OCTREE)); |
605 |
> |
|
606 |
> |
if (runcom(combuf)) { /* run it */ |
607 |
> |
fprintf(stderr, |
608 |
> |
"%s: error generating octree\n\t%s removed\n", |
609 |
> |
progname, vval(OCTREE)); |
610 |
> |
unlink(vval(OCTREE)); |
611 |
> |
exit(1); |
612 |
> |
} |
613 |
> |
octreedate = time(0); |
614 |
|
} |
615 |
< |
if (noaction) |
615 |
> |
if (oct1name == vval(OCTREE)) /* no mkillum? */ |
616 |
> |
oct1date = octreedate > matdate ? octreedate : matdate; |
617 |
> |
if (oct1date >= octreedate & oct1date >= matdate |
618 |
> |
& oct1date >= illumdate) /* all done */ |
619 |
|
return; |
620 |
< |
if (system(combuf)) { /* run it */ |
621 |
< |
fprintf(stderr, "%s: error generating octree\n\t%s removed\n", |
622 |
< |
progname, vval(OCTREE)); |
623 |
< |
unlink(vval(OCTREE)); |
620 |
> |
/* make octree0 */ |
621 |
> |
if (oct0date < scenedate | oct0date < illumdate) { |
622 |
> |
/* build command */ |
623 |
> |
if (octreedate) |
624 |
> |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
625 |
> |
vval(OCTREE), vval(ILLUM), oct0name); |
626 |
> |
else if (vdef(MATERIAL)) |
627 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
628 |
> |
vval(MATERIAL), vval(ILLUM), oct0name); |
629 |
> |
else |
630 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
631 |
> |
vval(ILLUM), oct0name); |
632 |
> |
if (runcom(combuf)) { /* run it */ |
633 |
> |
fprintf(stderr, |
634 |
> |
"%s: error generating octree\n\t%s removed\n", |
635 |
> |
progname, oct0name); |
636 |
> |
unlink(oct0name); |
637 |
> |
exit(1); |
638 |
> |
} |
639 |
> |
oct0date = time(0); |
640 |
> |
} |
641 |
> |
mkillumopts(mkopts); /* build mkillum command */ |
642 |
> |
mktemp(illumtmp); |
643 |
> |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
644 |
> |
oct0name, vval(ILLUM), illumtmp); |
645 |
> |
if (runcom(combuf)) { /* run it */ |
646 |
> |
fprintf(stderr, "%s: error running mkillum\n", progname); |
647 |
> |
unlink(illumtmp); |
648 |
|
exit(1); |
649 |
|
} |
650 |
< |
octreedate = time(0); |
650 |
> |
/* make octree1 (frozen) */ |
651 |
> |
if (octreedate) |
652 |
> |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
653 |
> |
vval(OCTREE), illumtmp, oct1name); |
654 |
> |
else if (vdef(MATERIAL)) |
655 |
> |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
656 |
> |
vval(MATERIAL), illumtmp, oct1name); |
657 |
> |
else |
658 |
> |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
659 |
> |
illumtmp, oct1name); |
660 |
> |
if (runcom(combuf)) { /* run it */ |
661 |
> |
fprintf(stderr, |
662 |
> |
"%s: error generating octree\n\t%s removed\n", |
663 |
> |
progname, oct1name); |
664 |
> |
unlink(oct1name); |
665 |
> |
exit(1); |
666 |
> |
} |
667 |
> |
oct1date = time(0); |
668 |
> |
rmfile(illumtmp); |
669 |
|
} |
670 |
|
|
671 |
|
|
691 |
|
} |
692 |
|
|
693 |
|
|
694 |
+ |
mkillumopts(mo) /* get mkillum options */ |
695 |
+ |
register char *mo; |
696 |
+ |
{ |
697 |
+ |
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
698 |
+ |
|
699 |
+ |
*mo = '\0'; |
700 |
+ |
if (vdef(MKILLUM)) |
701 |
+ |
addarg(mo, vval(MKILLUM)); |
702 |
+ |
} |
703 |
+ |
|
704 |
+ |
|
705 |
+ |
checkambfile() /* check date on ambient file */ |
706 |
+ |
{ |
707 |
+ |
unsigned long afdate; |
708 |
+ |
|
709 |
+ |
if (!vdef(AMBFILE)) |
710 |
+ |
return; |
711 |
+ |
if (!(afdate = fdate(vval(AMBFILE)))) |
712 |
+ |
return; |
713 |
+ |
if (oct1date > afdate) |
714 |
+ |
rmfile(vval(AMBFILE)); |
715 |
+ |
} |
716 |
+ |
|
717 |
+ |
|
718 |
|
double |
719 |
|
ambval() /* compute ambient value */ |
720 |
|
{ |
721 |
|
if (vdef(EXPOSURE)) { |
722 |
+ |
if (!isflt(vval(EXPOSURE))) |
723 |
+ |
badvalue(EXPOSURE); |
724 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
725 |
|
return(.5/pow(2.,atof(vval(EXPOSURE)))); |
726 |
< |
if (isdigit(vval(EXPOSURE)[0]) || vval(EXPOSURE)[0] == '.') |
553 |
< |
return(.5/atof(vval(EXPOSURE))); |
554 |
< |
badvalue(EXPOSURE); |
726 |
> |
return(.5/atof(vval(EXPOSURE))); |
727 |
|
} |
728 |
|
if (vlet(ZONE) == 'E') |
729 |
|
return(10.); |
747 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
748 |
|
switch (vscale(DETAIL)) { |
749 |
|
case LOW: |
750 |
< |
op = addarg(op, "-ps 16"); |
579 |
< |
op = addarg(op, "-dp 16"); |
750 |
> |
op = addarg(op, "-ps 16 -dp 64"); |
751 |
|
sprintf(op, " -ar %d", (int)(4*d)); |
752 |
|
op += strlen(op); |
753 |
|
break; |
754 |
|
case MEDIUM: |
755 |
< |
op = addarg(op, "-ps 8"); |
585 |
< |
op = addarg(op, "-dp 32"); |
755 |
> |
op = addarg(op, "-ps 8 -dp 128"); |
756 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
757 |
|
op += strlen(op); |
758 |
|
break; |
759 |
|
case HIGH: |
760 |
< |
op = addarg(op, "-ps 4"); |
591 |
< |
op = addarg(op, "-dp 64"); |
760 |
> |
op = addarg(op, "-ps 4 -dp 256"); |
761 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
762 |
|
op += strlen(op); |
763 |
|
break; |
765 |
|
op = addarg(op, "-pt .16"); |
766 |
|
if (vbool(PENUMBRAS)) |
767 |
|
op = addarg(op, "-ds .4"); |
768 |
< |
op = addarg(op, "-dt .2"); |
769 |
< |
op = addarg(op, "-dc .25"); |
770 |
< |
op = addarg(op, "-dr 0"); |
602 |
< |
op = addarg(op, "-sj 0"); |
603 |
< |
op = addarg(op, "-st .7"); |
604 |
< |
op = addarg(op, "-ab 0"); |
768 |
> |
else |
769 |
> |
op = addarg(op, "-ds 0"); |
770 |
> |
op = addarg(op, "-dt .2 -dc .25 -dr 0 -sj 0 -st .5"); |
771 |
|
if (vdef(AMBFILE)) { |
772 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
773 |
|
op += strlen(op); |
775 |
|
overture = 0; |
776 |
|
switch (vscale(VARIABILITY)) { |
777 |
|
case LOW: |
778 |
< |
op = addarg(op, "-aa .4"); |
613 |
< |
op = addarg(op, "-ad 32"); |
778 |
> |
op = addarg(op, "-aa .4 -ad 64"); |
779 |
|
break; |
780 |
|
case MEDIUM: |
781 |
< |
op = addarg(op, "-aa .3"); |
617 |
< |
op = addarg(op, "-ad 64"); |
781 |
> |
op = addarg(op, "-aa .3 -ad 128"); |
782 |
|
break; |
783 |
|
case HIGH: |
784 |
< |
op = addarg(op, "-aa .25"); |
621 |
< |
op = addarg(op, "-ad 128"); |
784 |
> |
op = addarg(op, "-aa .25 -ad 256"); |
785 |
|
break; |
786 |
|
} |
787 |
|
op = addarg(op, "-as 0"); |
788 |
|
d = ambval(); |
789 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
790 |
|
op += strlen(op); |
791 |
< |
op = addarg(op, "-lr 3"); |
629 |
< |
op = addarg(op, "-lw .02"); |
791 |
> |
op = addarg(op, "-lr 3 -lw .02"); |
792 |
|
if (vdef(RENDER)) |
793 |
|
op = addarg(op, vval(RENDER)); |
794 |
|
} |
809 |
|
switch (vscale(DETAIL)) { |
810 |
|
case LOW: |
811 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
812 |
< |
op = addarg(op, "-dp 64"); |
812 |
> |
op = addarg(op, "-dp 256"); |
813 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
814 |
|
op += strlen(op); |
815 |
|
break; |
816 |
|
case MEDIUM: |
817 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
818 |
< |
op = addarg(op, "-dp 128"); |
818 |
> |
op = addarg(op, "-dp 512"); |
819 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
820 |
|
op += strlen(op); |
821 |
|
break; |
822 |
|
case HIGH: |
823 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
824 |
< |
op = addarg(op, "-dp 256"); |
824 |
> |
op = addarg(op, "-dp 1024"); |
825 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
826 |
|
op += strlen(op); |
827 |
|
break; |
828 |
|
} |
829 |
|
op = addarg(op, "-pt .08"); |
830 |
< |
if (vbool(PENUMBRAS)) { |
831 |
< |
op = addarg(op, "-ds .2"); |
832 |
< |
op = addarg(op, "-dj .35"); |
671 |
< |
} else |
830 |
> |
if (vbool(PENUMBRAS)) |
831 |
> |
op = addarg(op, "-ds .2 -dj .35"); |
832 |
> |
else |
833 |
|
op = addarg(op, "-ds .3"); |
834 |
< |
op = addarg(op, "-dt .1"); |
835 |
< |
op = addarg(op, "-dc .5"); |
836 |
< |
op = addarg(op, "-dr 1"); |
837 |
< |
op = addarg(op, "-sj .7"); |
838 |
< |
op = addarg(op, "-st .15"); |
678 |
< |
sprintf(op, " -ab %d", overture=vint(INDIRECT)); |
679 |
< |
op += strlen(op); |
834 |
> |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
835 |
> |
if (overture = vint(INDIRECT)) { |
836 |
> |
sprintf(op, " -ab %d", overture); |
837 |
> |
op += strlen(op); |
838 |
> |
} |
839 |
|
if (vdef(AMBFILE)) { |
840 |
|
sprintf(op, " -af %s", vval(AMBFILE)); |
841 |
|
op += strlen(op); |
843 |
|
overture = 0; |
844 |
|
switch (vscale(VARIABILITY)) { |
845 |
|
case LOW: |
846 |
< |
op = addarg(op, "-aa .25"); |
688 |
< |
op = addarg(op, "-ad 128"); |
689 |
< |
op = addarg(op, "-as 0"); |
846 |
> |
op = addarg(op, "-aa .25 -ad 196 -as 0"); |
847 |
|
break; |
848 |
|
case MEDIUM: |
849 |
< |
op = addarg(op, "-aa .2"); |
693 |
< |
op = addarg(op, "-ad 300"); |
694 |
< |
op = addarg(op, "-as 64"); |
849 |
> |
op = addarg(op, "-aa .2 -ad 400 -as 64"); |
850 |
|
break; |
851 |
|
case HIGH: |
852 |
< |
op = addarg(op, "-aa .15"); |
698 |
< |
op = addarg(op, "-ad 500"); |
699 |
< |
op = addarg(op, "-as 128"); |
852 |
> |
op = addarg(op, "-aa .15 -ad 768 -as 196"); |
853 |
|
break; |
854 |
|
} |
855 |
|
d = ambval(); |
856 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
857 |
|
op += strlen(op); |
858 |
< |
op = addarg(op, "-lr 6"); |
706 |
< |
op = addarg(op, "-lw .002"); |
858 |
> |
op = addarg(op, "-lr 6 -lw .002"); |
859 |
|
if (vdef(RENDER)) |
860 |
|
op = addarg(op, vval(RENDER)); |
861 |
|
} |
876 |
|
switch (vscale(DETAIL)) { |
877 |
|
case LOW: |
878 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
879 |
< |
op = addarg(op, "-dp 256"); |
879 |
> |
op = addarg(op, "-dp 1024"); |
880 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
881 |
|
op += strlen(op); |
882 |
|
break; |
883 |
|
case MEDIUM: |
884 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
885 |
< |
op = addarg(op, "-dp 512"); |
885 |
> |
op = addarg(op, "-dp 2048"); |
886 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
887 |
|
op += strlen(op); |
888 |
|
break; |
889 |
|
case HIGH: |
890 |
|
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
891 |
< |
op = addarg(op, "-dp 1024"); |
891 |
> |
op = addarg(op, "-dp 4096"); |
892 |
|
sprintf(op, " -ar %d", (int)(64*d)); |
893 |
|
op += strlen(op); |
894 |
|
break; |
895 |
|
} |
896 |
|
op = addarg(op, "-pt .04"); |
897 |
< |
if (vbool(PENUMBRAS)) { |
898 |
< |
op = addarg(op, "-ds .1"); |
899 |
< |
op = addarg(op, "-dj .7"); |
748 |
< |
} else |
897 |
> |
if (vbool(PENUMBRAS)) |
898 |
> |
op = addarg(op, "-ds .1 -dj .7"); |
899 |
> |
else |
900 |
|
op = addarg(op, "-ds .2"); |
901 |
< |
op = addarg(op, "-dt .05"); |
751 |
< |
op = addarg(op, "-dc .75"); |
752 |
< |
op = addarg(op, "-dr 3"); |
753 |
< |
op = addarg(op, "-sj 1"); |
754 |
< |
op = addarg(op, "-st .03"); |
901 |
> |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
902 |
|
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); |
903 |
|
op += strlen(op); |
904 |
|
if (vdef(AMBFILE)) { |
908 |
|
overture = 0; |
909 |
|
switch (vscale(VARIABILITY)) { |
910 |
|
case LOW: |
911 |
< |
op = addarg(op, "-aa .15"); |
765 |
< |
op = addarg(op, "-ad 200"); |
766 |
< |
op = addarg(op, "-as 0"); |
911 |
> |
op = addarg(op, "-aa .15 -ad 256 -as 0"); |
912 |
|
break; |
913 |
|
case MEDIUM: |
914 |
< |
op = addarg(op, "-aa .125"); |
770 |
< |
op = addarg(op, "-ad 512"); |
771 |
< |
op = addarg(op, "-as 128"); |
914 |
> |
op = addarg(op, "-aa .125 -ad 512 -as 256"); |
915 |
|
break; |
916 |
|
case HIGH: |
917 |
< |
op = addarg(op, "-aa .08"); |
775 |
< |
op = addarg(op, "-ad 850"); |
776 |
< |
op = addarg(op, "-as 256"); |
917 |
> |
op = addarg(op, "-aa .08 -ad 1024 -as 512"); |
918 |
|
break; |
919 |
|
} |
920 |
|
d = ambval(); |
921 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
922 |
|
op += strlen(op); |
923 |
< |
op = addarg(op, "-lr 12"); |
783 |
< |
op = addarg(op, "-lw .0005"); |
923 |
> |
op = addarg(op, "-lr 12 -lw .0005"); |
924 |
|
if (vdef(RENDER)) |
925 |
|
op = addarg(op, vval(RENDER)); |
926 |
|
} |
930 |
|
char *ro; |
931 |
|
{ |
932 |
|
int fd, n; |
933 |
+ |
register char *cp; |
934 |
|
|
935 |
|
n = strlen(ro); |
936 |
|
if (n < 2) |
937 |
|
return; |
938 |
|
if (vdef(OPTFILE)) { |
939 |
< |
if ((fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
939 |
> |
for (cp = ro; cp[1]; cp++) |
940 |
> |
if (isspace(cp[1]) && cp[2] == '-' && isalpha(cp[3])) |
941 |
> |
*cp = '\n'; |
942 |
> |
else |
943 |
> |
*cp = cp[1]; |
944 |
> |
*cp = '\n'; |
945 |
> |
fd = open(vval(OPTFILE), O_WRONLY|O_CREAT|O_TRUNC, 0666); |
946 |
> |
if (fd < 0 || write(fd, ro, n) != n || close(fd) < 0) |
947 |
|
syserr(vval(OPTFILE)); |
948 |
< |
if (write(fd, ro+1, n-1) != n-1) |
801 |
< |
syserr(vval(OPTFILE)); |
802 |
< |
write(fd, "\n", 1); |
803 |
< |
close(fd); |
804 |
< |
ro[0] = ' '; |
805 |
< |
ro[1] = '^'; |
806 |
< |
strcpy(ro+2, vval(OPTFILE)); |
948 |
> |
sprintf(ro, " @%s", vval(OPTFILE)); |
949 |
|
} |
950 |
|
#ifdef MSDOS |
951 |
|
else if (n > 50) { |
952 |
< |
register char *evp = bmalloc(n+6); |
811 |
< |
if (evp == NULL) |
812 |
< |
syserr(progname); |
813 |
< |
strcpy(evp, "ROPT="); |
814 |
< |
strcat(evp, ro); |
815 |
< |
if (putenv(evp) != 0) { |
816 |
< |
fprintf(stderr, "%s: out of environment space\n", |
817 |
< |
progname); |
818 |
< |
exit(1); |
819 |
< |
} |
952 |
> |
setenv("ROPT", ro+1); |
953 |
|
strcpy(ro, " $ROPT"); |
954 |
|
} |
955 |
|
#endif |
964 |
|
po = addarg(po, "-1 -e"); |
965 |
|
po = addarg(po, vval(EXPOSURE)); |
966 |
|
} |
967 |
< |
if (vscale(QUALITY) == HIGH) |
968 |
< |
po = addarg(po, "-r .65"); |
967 |
> |
switch (vscale(QUALITY)) { |
968 |
> |
case MEDIUM: |
969 |
> |
po = addarg(po, "-r 1"); |
970 |
> |
break; |
971 |
> |
case HIGH: |
972 |
> |
po = addarg(po, "-m .25"); |
973 |
> |
break; |
974 |
> |
} |
975 |
|
if (vdef(PFILT)) |
976 |
|
po = addarg(po, vval(PFILT)); |
977 |
|
} |
1087 |
|
break; |
1088 |
|
} |
1089 |
|
} else { |
1090 |
< |
while (*vs && !isspace(*vs)) /* else skip id */ |
1091 |
< |
vs++; |
1090 |
> |
while (!isspace(*vs)) /* else skip id */ |
1091 |
> |
if (!*vs++) |
1092 |
> |
return(NULL); |
1093 |
|
if (upax) { /* specify up vector */ |
1094 |
|
strcpy(cp, vup[upax+3]); |
1095 |
|
cp += strlen(cp); |
1096 |
|
} |
1097 |
|
} |
1098 |
< |
/* append any additional options */ |
1098 |
> |
if (cp == viewopts) /* append any additional options */ |
1099 |
> |
vs++; /* skip prefixed space if unneeded */ |
1100 |
|
strcpy(cp, vs); |
1101 |
+ |
#ifdef MSDOS |
1102 |
+ |
if (strlen(viewopts) > 40) { |
1103 |
+ |
setenv("VIEW", viewopts); |
1104 |
+ |
return("$VIEW"); |
1105 |
+ |
} |
1106 |
+ |
#endif |
1107 |
|
return(viewopts); |
1108 |
|
} |
1109 |
|
|
1111 |
|
char * |
1112 |
|
getview(n, vn) /* get view n, or NULL if none */ |
1113 |
|
int n; |
1114 |
< |
char *vn; |
1114 |
> |
char *vn; /* returned view name */ |
1115 |
|
{ |
1116 |
|
register char *mv; |
1117 |
|
|
1118 |
< |
if (viewselect != NULL) { |
1118 |
> |
if (viewselect != NULL) { /* command-line selected */ |
1119 |
|
if (n) /* only do one */ |
1120 |
|
return(NULL); |
1121 |
|
if (viewselect[0] == '-') { /* already specified */ |
1128 |
|
; |
1129 |
|
*vn = '\0'; |
1130 |
|
} |
1131 |
+ |
/* view number? */ |
1132 |
+ |
if (isint(viewselect)) |
1133 |
+ |
return(specview(nvalue(vv+VIEW, atoi(viewselect)-1))); |
1134 |
|
/* check list */ |
1135 |
|
while ((mv = nvalue(vv+VIEW, n++)) != NULL) |
1136 |
|
if (matchword(viewselect, mv)) |
1137 |
|
return(specview(mv)); |
1138 |
|
return(specview(viewselect)); /* standard view? */ |
1139 |
|
} |
1140 |
< |
if (vn != NULL && (mv = nvalue(vv+VIEW, n)) != NULL) { |
1141 |
< |
if (*mv != '-') |
1142 |
< |
while (*mv && !isspace(*mv)) |
1143 |
< |
*vn++ = *mv++; |
1140 |
> |
mv = nvalue(vv+VIEW, n); /* use view n */ |
1141 |
> |
if (vn != NULL & mv != NULL) { |
1142 |
> |
register char *mv2 = mv; |
1143 |
> |
if (*mv2 != '-') |
1144 |
> |
while (*mv2 && !isspace(*mv2)) |
1145 |
> |
*vn++ = *mv2++; |
1146 |
|
*vn = '\0'; |
1147 |
|
} |
1148 |
< |
return(specview(nvalue(vv+VIEW, n))); /* use view n */ |
1148 |
> |
return(specview(mv)); |
1149 |
|
} |
1150 |
|
|
1151 |
|
|
1152 |
+ |
printview(vopts) /* print out selected view */ |
1153 |
+ |
register char *vopts; |
1154 |
+ |
{ |
1155 |
+ |
extern char *atos(), *getenv(); |
1156 |
+ |
char buf[256]; |
1157 |
+ |
FILE *fp; |
1158 |
+ |
register char *cp; |
1159 |
+ |
|
1160 |
+ |
if (vopts == NULL) |
1161 |
+ |
return(-1); |
1162 |
+ |
fputs("VIEW=", stdout); |
1163 |
+ |
do { |
1164 |
+ |
if (matchword(vopts, "-vf")) { /* expand view file */ |
1165 |
+ |
vopts = sskip(vopts); |
1166 |
+ |
if (!*atos(buf, sizeof(buf), vopts)) |
1167 |
+ |
return(-1); |
1168 |
+ |
if ((fp = fopen(buf, "r")) == NULL) |
1169 |
+ |
return(-1); |
1170 |
+ |
for (buf[sizeof(buf)-2] = '\n'; |
1171 |
+ |
fgets(buf, sizeof(buf), fp) != NULL && |
1172 |
+ |
buf[0] != '\n'; |
1173 |
+ |
buf[sizeof(buf)-2] = '\n') { |
1174 |
+ |
if (buf[sizeof(buf)-2] != '\n') { |
1175 |
+ |
ungetc(buf[sizeof(buf)-2], fp); |
1176 |
+ |
buf[sizeof(buf)-2] = '\0'; |
1177 |
+ |
} |
1178 |
+ |
if (matchword(buf, "VIEW=") || |
1179 |
+ |
matchword(buf, "rview")) { |
1180 |
+ |
for (cp = sskip(buf); *cp && *cp != '\n'; cp++) |
1181 |
+ |
putchar(*cp); |
1182 |
+ |
} |
1183 |
+ |
} |
1184 |
+ |
fclose(fp); |
1185 |
+ |
vopts = sskip(vopts); |
1186 |
+ |
} else { |
1187 |
+ |
while (isspace(*vopts)) |
1188 |
+ |
vopts++; |
1189 |
+ |
putchar(' '); |
1190 |
+ |
#ifdef MSDOS |
1191 |
+ |
if (*vopts == '$') { /* expand env. var. */ |
1192 |
+ |
if (!*atos(buf, sizeof(buf), vopts+1)) |
1193 |
+ |
return(-1); |
1194 |
+ |
if ((cp = getenv(buf)) == NULL) |
1195 |
+ |
return(-1); |
1196 |
+ |
fputs(cp, stdout); |
1197 |
+ |
vopts = sskip(vopts); |
1198 |
+ |
} else |
1199 |
+ |
#endif |
1200 |
+ |
while (*vopts && !isspace(*vopts)) |
1201 |
+ |
putchar(*vopts++); |
1202 |
+ |
} |
1203 |
+ |
} while (*vopts++); |
1204 |
+ |
putchar('\n'); |
1205 |
+ |
return(0); |
1206 |
+ |
} |
1207 |
+ |
|
1208 |
+ |
|
1209 |
|
rview(opts) /* run rview with first view */ |
1210 |
|
char *opts; |
1211 |
|
{ |
1212 |
+ |
char *vw; |
1213 |
|
char combuf[512]; |
1214 |
|
/* build command */ |
1215 |
< |
sprintf(combuf, "rview %s%s ", getview(0, NULL), opts); |
1215 |
> |
if ((vw = getview(0, NULL)) == NULL) |
1216 |
> |
return; |
1217 |
> |
if (sayview) |
1218 |
> |
printview(vw); |
1219 |
> |
sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname); |
1220 |
|
if (rvdevice != NULL) |
1221 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
1222 |
< |
strcat(combuf, vval(OCTREE)); |
1223 |
< |
if (!silent) { /* echo it */ |
1010 |
< |
printf("\t%s\n", combuf); |
1011 |
< |
fflush(stdout); |
1012 |
< |
} |
1013 |
< |
if (noaction) |
1014 |
< |
return; |
1015 |
< |
if (system(combuf)) { /* run it */ |
1222 |
> |
strcat(combuf, oct1name); |
1223 |
> |
if (runcom(combuf)) { /* run it */ |
1224 |
|
fprintf(stderr, "%s: error running rview\n", progname); |
1225 |
|
exit(1); |
1226 |
|
} |
1265 |
|
else |
1266 |
|
badvalue(REPORT); |
1267 |
|
} |
1060 |
– |
/* check date on ambient file */ |
1061 |
– |
if (vdef(AMBFILE)) { |
1062 |
– |
long afdate = fdate(vval(AMBFILE)); |
1063 |
– |
if (afdate >= 0 & octreedate > afdate) { |
1064 |
– |
if (!silent) |
1065 |
– |
#ifdef MSDOS |
1066 |
– |
printf("\tdel %s\n", vval(AMBFILE)); |
1067 |
– |
#else |
1068 |
– |
printf("\trm %s\n", vval(AMBFILE)); |
1069 |
– |
#endif |
1070 |
– |
if (!noaction) |
1071 |
– |
unlink(vval(AMBFILE)); |
1072 |
– |
} |
1073 |
– |
} |
1268 |
|
/* do each view */ |
1269 |
|
vn = 0; |
1270 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1271 |
+ |
if (sayview) |
1272 |
+ |
printview(vw); |
1273 |
|
if (!vs[0]) |
1274 |
|
sprintf(vs, "%d", vn); |
1275 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1276 |
|
/* check date on picture */ |
1277 |
< |
if (fdate(picfile) > octreedate) |
1277 |
> |
if (fdate(picfile) >= oct1date) |
1278 |
|
continue; |
1279 |
|
/* build rpict command */ |
1280 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
1281 |
< |
if (fdate(rawfile) > octreedate) /* recover */ |
1281 |
> |
if (fdate(rawfile) >= oct1date) /* recover */ |
1282 |
|
sprintf(combuf, "rpict%s%s -ro %s %s", |
1283 |
< |
rep, opts, rawfile, vval(OCTREE)); |
1283 |
> |
rep, opts, rawfile, oct1name); |
1284 |
|
else { |
1285 |
|
if (overture) { /* run overture calculation */ |
1286 |
|
sprintf(combuf, |
1287 |
|
"rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1288 |
|
rep, vw, opts, |
1289 |
< |
vval(OCTREE), rawfile); |
1290 |
< |
if (!silent) { |
1095 |
< |
printf("\t%s\n", combuf); |
1096 |
< |
fflush(stdout); |
1097 |
< |
} |
1098 |
< |
if (!noaction && system(combuf)) { |
1289 |
> |
oct1name, overfile); |
1290 |
> |
if (runcom(combuf)) { |
1291 |
|
fprintf(stderr, |
1292 |
< |
"%s: error in overture for view %s\n\t%s removed\n", |
1293 |
< |
progname, vs, rawfile); |
1102 |
< |
unlink(rawfile); |
1292 |
> |
"%s: error in overture for view %s\n", |
1293 |
> |
progname, vs); |
1294 |
|
exit(1); |
1295 |
|
} |
1296 |
+ |
#ifdef NIX |
1297 |
+ |
rmfile(overfile); |
1298 |
+ |
#endif |
1299 |
|
} |
1300 |
|
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
1301 |
|
rep, vw, res, opts, |
1302 |
< |
vval(OCTREE), rawfile); |
1302 |
> |
oct1name, rawfile); |
1303 |
|
} |
1304 |
< |
if (!silent) { /* echo rpict command */ |
1111 |
< |
printf("\t%s\n", combuf); |
1112 |
< |
fflush(stdout); |
1113 |
< |
} |
1114 |
< |
if (!noaction && system(combuf)) { /* run rpict */ |
1304 |
> |
if (runcom(combuf)) { /* run rpict */ |
1305 |
|
fprintf(stderr, "%s: error rendering view %s\n", |
1306 |
|
progname, vs); |
1307 |
|
exit(1); |
1313 |
|
else |
1314 |
|
sprintf(combuf, "pfilt%s %s > %s", pfopts, |
1315 |
|
rawfile, picfile); |
1316 |
< |
if (!silent) { /* echo pfilt command */ |
1127 |
< |
printf("\t%s\n", combuf); |
1128 |
< |
fflush(stdout); |
1129 |
< |
} |
1130 |
< |
if (!noaction && system(combuf)) { /* run pfilt */ |
1316 |
> |
if (runcom(combuf)) { /* run pfilt */ |
1317 |
|
fprintf(stderr, |
1318 |
|
"%s: error filtering view %s\n\t%s removed\n", |
1319 |
|
progname, vs, picfile); |
1321 |
|
exit(1); |
1322 |
|
} |
1323 |
|
/* remove raw file */ |
1324 |
< |
if (!silent) |
1324 |
> |
rmfile(rawfile); |
1325 |
> |
} |
1326 |
> |
} |
1327 |
> |
|
1328 |
> |
|
1329 |
> |
runcom(cs) /* run command */ |
1330 |
> |
char *cs; |
1331 |
> |
{ |
1332 |
> |
if (!silent) /* echo it */ |
1333 |
> |
printf("\t%s\n", cs); |
1334 |
> |
if (noaction) |
1335 |
> |
return(0); |
1336 |
> |
fflush(stdout); /* flush output and pass to shell */ |
1337 |
> |
return(system(cs)); |
1338 |
> |
} |
1339 |
> |
|
1340 |
> |
|
1341 |
> |
rmfile(fn) /* remove a file */ |
1342 |
> |
char *fn; |
1343 |
> |
{ |
1344 |
> |
if (!silent) |
1345 |
|
#ifdef MSDOS |
1346 |
< |
printf("\tdel %s\n", rawfile); |
1346 |
> |
printf("\tdel %s\n", fn); |
1347 |
|
#else |
1348 |
< |
printf("\trm %s\n", rawfile); |
1348 |
> |
printf("\trm -f %s\n", fn); |
1349 |
|
#endif |
1350 |
< |
if (!noaction) |
1351 |
< |
unlink(rawfile); |
1350 |
> |
if (noaction) |
1351 |
> |
return(0); |
1352 |
> |
return(unlink(fn)); |
1353 |
> |
} |
1354 |
> |
|
1355 |
> |
|
1356 |
> |
#ifdef MSDOS |
1357 |
> |
setenv(vname, value) /* set an environment variable */ |
1358 |
> |
char *vname, *value; |
1359 |
> |
{ |
1360 |
> |
register char *evp; |
1361 |
> |
|
1362 |
> |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1363 |
> |
if (evp == NULL) |
1364 |
> |
syserr(progname); |
1365 |
> |
sprintf(evp, "%s=%s", vname, value); |
1366 |
> |
if (putenv(evp) != 0) { |
1367 |
> |
fprintf(stderr, "%s: out of environment space\n", progname); |
1368 |
> |
exit(1); |
1369 |
|
} |
1370 |
+ |
if (!silent) |
1371 |
+ |
printf("set %s\n", evp); |
1372 |
|
} |
1373 |
+ |
#endif |
1374 |
|
|
1375 |
|
|
1376 |
|
badvalue(vc) /* report bad variable value and exit */ |