1 |
< |
/* Copyright (c) 1993 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1994 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
11 |
|
#include "standard.h" |
12 |
|
#include "paths.h" |
13 |
|
#include <ctype.h> |
14 |
+ |
#include <sys/types.h> |
15 |
|
|
16 |
|
|
17 |
|
typedef struct { |
22 |
|
int (*fixval)(); /* assignment checking function */ |
23 |
|
} VARIABLE; |
24 |
|
|
25 |
< |
int onevalue(), catvalues(); |
25 |
> |
int onevalue(), catvalues(), boolvalue(), |
26 |
> |
qualvalue(), fltvalue(), intvalue(); |
27 |
|
|
28 |
|
/* variables */ |
29 |
|
#define OBJECT 0 /* object files */ |
63 |
|
{"pfilt", 2, 0, NULL, catvalues}, |
64 |
|
{"view", 2, 0, NULL, NULL}, |
65 |
|
{"ZONE", 2, 0, NULL, onevalue}, |
66 |
< |
{"QUALITY", 3, 0, NULL, onevalue}, |
66 |
> |
{"QUALITY", 3, 0, NULL, qualvalue}, |
67 |
|
{"OCTREE", 3, 0, NULL, onevalue}, |
68 |
|
{"PICTURE", 3, 0, NULL, onevalue}, |
69 |
|
{"AMBFILE", 3, 0, NULL, onevalue}, |
70 |
|
{"OPTFILE", 3, 0, NULL, onevalue}, |
71 |
< |
{"EXPOSURE", 3, 0, NULL, onevalue}, |
71 |
> |
{"EXPOSURE", 3, 0, NULL, fltvalue}, |
72 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
73 |
|
{"UP", 2, 0, NULL, onevalue}, |
74 |
< |
{"INDIRECT", 3, 0, NULL, onevalue}, |
75 |
< |
{"DETAIL", 3, 0, NULL, onevalue}, |
76 |
< |
{"PENUMBRAS", 3, 0, NULL, onevalue}, |
77 |
< |
{"VARIABILITY", 3, 0, NULL, onevalue}, |
74 |
> |
{"INDIRECT", 3, 0, NULL, intvalue}, |
75 |
> |
{"DETAIL", 3, 0, NULL, qualvalue}, |
76 |
> |
{"PENUMBRAS", 3, 0, NULL, boolvalue}, |
77 |
> |
{"VARIABILITY", 3, 0, NULL, qualvalue}, |
78 |
|
{"REPORT", 3, 0, NULL, onevalue}, |
79 |
|
}; |
80 |
|
|
81 |
|
VARIABLE *matchvar(); |
82 |
|
char *nvalue(); |
81 |
– |
int vscale(); |
83 |
|
|
84 |
|
#define UPPER(c) ((c)&~0x20) /* ASCII trick */ |
85 |
|
|
88 |
|
#define vval(vc) (vv[vc].value) |
89 |
|
#define vint(vc) atoi(vval(vc)) |
90 |
|
#define vlet(vc) UPPER(vval(vc)[0]) |
91 |
+ |
#define vscale vlet |
92 |
|
#define vbool(vc) (vlet(vc)=='T') |
93 |
|
|
94 |
< |
#define HIGH 2 |
95 |
< |
#define MEDIUM 1 |
96 |
< |
#define LOW 0 |
94 |
> |
#define HIGH 'H' |
95 |
> |
#define MEDIUM 'M' |
96 |
> |
#define LOW 'L' |
97 |
|
|
96 |
– |
int lowqopts(), medqopts(), hiqopts(); |
97 |
– |
int (*setqopts[3])() = {lowqopts, medqopts, hiqopts}; |
98 |
– |
|
99 |
– |
#define renderopts (*setqopts[vscale(QUALITY)]) |
100 |
– |
|
98 |
|
/* overture calculation file */ |
99 |
|
#ifdef NIX |
100 |
|
char overfile[] = "overture.raw"; |
102 |
|
char overfile[] = "/dev/null"; |
103 |
|
#endif |
104 |
|
|
105 |
< |
extern unsigned long fdate(), time(); |
105 |
> |
extern time_t fdate(), time(); |
106 |
|
|
107 |
< |
unsigned long scenedate; /* date of latest scene or object file */ |
108 |
< |
unsigned long octreedate; /* date of octree */ |
109 |
< |
unsigned long matdate; /* date of latest material file */ |
110 |
< |
unsigned long illumdate; /* date of last illum file */ |
107 |
> |
time_t scenedate; /* date of latest scene or object file */ |
108 |
> |
time_t octreedate; /* date of octree */ |
109 |
> |
time_t matdate; /* date of latest material file */ |
110 |
> |
time_t illumdate; /* date of last illum file */ |
111 |
|
|
112 |
|
char *oct0name; /* name of pre-mkillum octree */ |
113 |
< |
unsigned long oct0date; /* date of pre-mkillum octree */ |
113 |
> |
time_t oct0date; /* date of pre-mkillum octree */ |
114 |
|
char *oct1name; /* name of post-mkillum octree */ |
115 |
< |
unsigned long oct1date; /* date of post-mkillum octree (>= matdate) */ |
115 |
> |
time_t oct1date; /* date of post-mkillum octree (>= matdate) */ |
116 |
|
|
117 |
+ |
int nowarn = 0; /* no warnings */ |
118 |
|
int explicate = 0; /* explicate variables */ |
119 |
|
int silent = 0; /* do work silently */ |
120 |
+ |
int touchonly = 0; /* touch files only */ |
121 |
|
int noaction = 0; /* don't do anything */ |
122 |
|
int sayview = 0; /* print view out */ |
123 |
|
char *rvdevice = NULL; /* rview output device */ |
136 |
|
char *argv[]; |
137 |
|
{ |
138 |
|
char ropts[512]; |
139 |
+ |
char popts[64]; |
140 |
|
int i; |
141 |
|
|
142 |
|
progname = argv[0]; |
149 |
|
case 'n': |
150 |
|
noaction++; |
151 |
|
break; |
152 |
+ |
case 't': |
153 |
+ |
touchonly++; |
154 |
+ |
break; |
155 |
|
case 'e': |
156 |
|
explicate++; |
157 |
|
break; |
164 |
|
case 'v': |
165 |
|
viewselect = argv[++i]; |
166 |
|
break; |
167 |
+ |
case 'w': |
168 |
+ |
nowarn++; |
169 |
+ |
break; |
170 |
|
default: |
171 |
|
goto userr; |
172 |
|
} |
194 |
|
/* check date on ambient file */ |
195 |
|
checkambfile(); |
196 |
|
/* run simulation */ |
197 |
< |
renderopts(ropts); |
197 |
> |
renderopts(ropts, popts); |
198 |
|
xferopts(ropts); |
199 |
|
if (rvdevice != NULL) |
200 |
< |
rview(ropts); |
200 |
> |
rview(ropts, popts); |
201 |
|
else |
202 |
< |
rpict(ropts); |
202 |
> |
rpict(ropts, popts); |
203 |
|
exit(0); |
204 |
|
userr: |
205 |
|
fprintf(stderr, |
206 |
< |
"Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
206 |
> |
"Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
207 |
|
progname); |
208 |
|
exit(1); |
209 |
|
} |
262 |
|
register char *ass; |
263 |
|
{ |
264 |
|
char varname[32]; |
259 |
– |
char varval[512]; |
265 |
|
int n; |
266 |
|
register char *cp; |
267 |
|
register VARIABLE *vp; |
282 |
|
for (n = strlen(ass); n > 0; n--) |
283 |
|
if (!isspace(ass[n-1])) |
284 |
|
break; |
285 |
< |
if (!n) { |
285 |
> |
if (!n && !nowarn) { |
286 |
|
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
287 |
|
progname, varname); |
288 |
|
return; |
353 |
|
} |
354 |
|
|
355 |
|
|
351 |
– |
int |
352 |
– |
vscale(vc) /* return scale for variable vc */ |
353 |
– |
int vc; |
354 |
– |
{ |
355 |
– |
switch(vlet(vc)) { |
356 |
– |
case 'H': |
357 |
– |
return(HIGH); |
358 |
– |
case 'M': |
359 |
– |
return(MEDIUM); |
360 |
– |
case 'L': |
361 |
– |
return(LOW); |
362 |
– |
} |
363 |
– |
badvalue(vc); |
364 |
– |
} |
365 |
– |
|
366 |
– |
|
356 |
|
checkvalues() /* check assignments */ |
357 |
|
{ |
358 |
|
register int i; |
368 |
|
{ |
369 |
|
if (vp->nass < 2) |
370 |
|
return; |
371 |
< |
fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n", |
371 |
> |
if (!nowarn) |
372 |
> |
fprintf(stderr, |
373 |
> |
"%s: warning - multiple assignment of variable '%s'\n", |
374 |
|
progname, vp->name); |
375 |
|
do |
376 |
|
vp->value += strlen(vp->value)+1; |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
< |
unsigned long |
396 |
> |
int |
397 |
> |
badmatch(tv, cv) /* case insensitive truncated comparison */ |
398 |
> |
register char *tv, *cv; |
399 |
> |
{ |
400 |
> |
if (!*tv) return(1); /* null string cannot match */ |
401 |
> |
do |
402 |
> |
if (UPPER(*tv) != *cv++) |
403 |
> |
return(1); |
404 |
> |
while (*++tv); |
405 |
> |
return(0); /* OK */ |
406 |
> |
} |
407 |
> |
|
408 |
> |
|
409 |
> |
boolvalue(vp) /* check boolean for legal values */ |
410 |
> |
register VARIABLE *vp; |
411 |
> |
{ |
412 |
> |
if (!vp->nass) return; |
413 |
> |
onevalue(vp); |
414 |
> |
switch (UPPER(vp->value[0])) { |
415 |
> |
case 'T': |
416 |
> |
if (badmatch(vp->value, "TRUE")) break; |
417 |
> |
return; |
418 |
> |
case 'F': |
419 |
> |
if (badmatch(vp->value, "FALSE")) break; |
420 |
> |
return; |
421 |
> |
} |
422 |
> |
fprintf(stderr, "%s: illegal value for boolean variable '%s'\n", |
423 |
> |
progname, vp->name); |
424 |
> |
exit(1); |
425 |
> |
} |
426 |
> |
|
427 |
> |
|
428 |
> |
qualvalue(vp) /* check qualitative var. for legal values */ |
429 |
> |
register VARIABLE *vp; |
430 |
> |
{ |
431 |
> |
if (!vp->nass) return; |
432 |
> |
onevalue(vp); |
433 |
> |
switch (UPPER(vp->value[0])) { |
434 |
> |
case 'L': |
435 |
> |
if (badmatch(vp->value, "LOW")) break; |
436 |
> |
return; |
437 |
> |
case 'M': |
438 |
> |
if (badmatch(vp->value, "MEDIUM")) break; |
439 |
> |
return; |
440 |
> |
case 'H': |
441 |
> |
if (badmatch(vp->value, "HIGH")) break; |
442 |
> |
return; |
443 |
> |
} |
444 |
> |
fprintf(stderr, "%s: illegal value for qualitative variable '%s'\n", |
445 |
> |
progname, vp->name); |
446 |
> |
exit(1); |
447 |
> |
} |
448 |
> |
|
449 |
> |
|
450 |
> |
intvalue(vp) /* check integer variable for legal values */ |
451 |
> |
register VARIABLE *vp; |
452 |
> |
{ |
453 |
> |
if (!vp->nass) return; |
454 |
> |
onevalue(vp); |
455 |
> |
if (isint(vp->value)) return; |
456 |
> |
fprintf(stderr, "%s: illegal value for integer variable '%s'\n", |
457 |
> |
progname, vp->name); |
458 |
> |
exit(1); |
459 |
> |
} |
460 |
> |
|
461 |
> |
|
462 |
> |
fltvalue(vp) /* check float variable for legal values */ |
463 |
> |
register VARIABLE *vp; |
464 |
> |
{ |
465 |
> |
if (!vp->nass) return; |
466 |
> |
onevalue(vp); |
467 |
> |
if (isflt(vp->value)) return; |
468 |
> |
fprintf(stderr, "%s: illegal value for real variable '%s'\n", |
469 |
> |
progname, vp->name); |
470 |
> |
exit(1); |
471 |
> |
} |
472 |
> |
|
473 |
> |
|
474 |
> |
time_t |
475 |
|
checklast(fnames) /* check files and find most recent */ |
476 |
|
register char *fnames; |
477 |
|
{ |
478 |
|
char thisfile[MAXPATH]; |
479 |
< |
unsigned long thisdate, lastdate = 0; |
479 |
> |
time_t thisdate, lastdate = 0; |
480 |
|
register char *cp; |
481 |
|
|
482 |
|
if (fnames == NULL) |
524 |
|
|
525 |
|
checkfiles() /* check for existence and modified times */ |
526 |
|
{ |
527 |
< |
unsigned long objdate; |
527 |
> |
time_t objdate; |
528 |
|
|
529 |
|
if (!vdef(OCTREE)) { |
530 |
|
if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL) |
652 |
|
|
653 |
|
printvals() /* print variable values */ |
654 |
|
{ |
655 |
< |
register int i, j; |
655 |
> |
int i, j, clipline; |
656 |
> |
register char *cp; |
657 |
> |
register int k; |
658 |
|
|
659 |
< |
for (i = 0; i < NVARS; i++) |
660 |
< |
for (j = 0; j < vdef(i); j++) |
661 |
< |
printf("%s= %s\n", vnam(i), nvalue(vv+i, j)); |
659 |
> |
for (i = 0; i < NVARS; i++) /* print each variable */ |
660 |
> |
for (j = 0; j < vdef(i); j++) { /* print each assignment */ |
661 |
> |
fputs(vnam(i), stdout); |
662 |
> |
fputs("= ", stdout); |
663 |
> |
k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 ) |
664 |
> |
- strlen(vnam(i)) ; |
665 |
> |
cp = nvalue(vv+i, j); |
666 |
> |
while (*cp) { |
667 |
> |
putchar(*cp++); |
668 |
> |
if (--k <= 0) { /* line too long */ |
669 |
> |
while (*cp && !isspace(*cp)) |
670 |
> |
putchar(*cp++); /* finish this word */ |
671 |
> |
if (*cp) { /* start new line */ |
672 |
> |
putchar('\n'); |
673 |
> |
fputs(vnam(i), stdout); |
674 |
> |
putchar('='); |
675 |
> |
k = clipline; |
676 |
> |
} |
677 |
> |
} |
678 |
> |
} |
679 |
> |
putchar('\n'); |
680 |
> |
} |
681 |
|
fflush(stdout); |
682 |
|
} |
683 |
|
|
689 |
|
|
690 |
|
oconvopts(ocopts); /* get options */ |
691 |
|
if (octreedate < scenedate) { /* check date on original octree */ |
692 |
< |
/* build command */ |
693 |
< |
if (vdef(MATERIAL)) |
694 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
695 |
< |
vval(MATERIAL), vval(SCENE), vval(OCTREE)); |
696 |
< |
else |
697 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
698 |
< |
vval(SCENE), vval(OCTREE)); |
699 |
< |
|
700 |
< |
if (runcom(combuf)) { /* run it */ |
701 |
< |
fprintf(stderr, |
692 |
> |
if (touchonly && octreedate) |
693 |
> |
touch(vval(OCTREE)); |
694 |
> |
else { /* build command */ |
695 |
> |
if (vdef(MATERIAL)) |
696 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
697 |
> |
vval(MATERIAL), vval(SCENE), |
698 |
> |
vval(OCTREE)); |
699 |
> |
else |
700 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
701 |
> |
vval(SCENE), vval(OCTREE)); |
702 |
> |
|
703 |
> |
if (runcom(combuf)) { /* run it */ |
704 |
> |
fprintf(stderr, |
705 |
|
"%s: error generating octree\n\t%s removed\n", |
706 |
< |
progname, vval(OCTREE)); |
707 |
< |
unlink(vval(OCTREE)); |
708 |
< |
exit(1); |
706 |
> |
progname, vval(OCTREE)); |
707 |
> |
unlink(vval(OCTREE)); |
708 |
> |
exit(1); |
709 |
> |
} |
710 |
|
} |
711 |
< |
octreedate = time(0); |
711 |
> |
octreedate = time((time_t *)NULL); |
712 |
> |
if (octreedate < scenedate) /* in case clock is off */ |
713 |
> |
octreedate = scenedate; |
714 |
|
} |
715 |
|
if (oct1name == vval(OCTREE)) /* no mkillum? */ |
716 |
|
oct1date = octreedate > matdate ? octreedate : matdate; |
719 |
|
return; |
720 |
|
/* make octree0 */ |
721 |
|
if (oct0date < scenedate | oct0date < illumdate) { |
722 |
< |
/* build command */ |
722 |
> |
if (touchonly && oct0date) |
723 |
> |
touch(oct0name); |
724 |
> |
else { /* build command */ |
725 |
> |
if (octreedate) |
726 |
> |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
727 |
> |
vval(OCTREE), vval(ILLUM), oct0name); |
728 |
> |
else if (vdef(MATERIAL)) |
729 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
730 |
> |
vval(MATERIAL), vval(ILLUM), oct0name); |
731 |
> |
else |
732 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
733 |
> |
vval(ILLUM), oct0name); |
734 |
> |
if (runcom(combuf)) { /* run it */ |
735 |
> |
fprintf(stderr, |
736 |
> |
"%s: error generating octree\n\t%s removed\n", |
737 |
> |
progname, oct0name); |
738 |
> |
unlink(oct0name); |
739 |
> |
exit(1); |
740 |
> |
} |
741 |
> |
} |
742 |
> |
oct0date = time((time_t *)NULL); |
743 |
> |
if (oct0date < octreedate) /* in case clock is off */ |
744 |
> |
oct0date = octreedate; |
745 |
> |
if (oct0date < illumdate) /* ditto */ |
746 |
> |
oct0date = illumdate; |
747 |
> |
} |
748 |
> |
if (touchonly && oct1date) |
749 |
> |
touch(oct1name); |
750 |
> |
else { |
751 |
> |
mkillumopts(mkopts); /* build mkillum command */ |
752 |
> |
mktemp(illumtmp); |
753 |
> |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
754 |
> |
oct0name, vval(ILLUM), illumtmp); |
755 |
> |
if (runcom(combuf)) { /* run it */ |
756 |
> |
fprintf(stderr, "%s: error running mkillum\n", |
757 |
> |
progname); |
758 |
> |
unlink(illumtmp); |
759 |
> |
exit(1); |
760 |
> |
} |
761 |
> |
/* make octree1 (frozen) */ |
762 |
|
if (octreedate) |
763 |
< |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
764 |
< |
vval(OCTREE), vval(ILLUM), oct0name); |
763 |
> |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
764 |
> |
vval(OCTREE), illumtmp, oct1name); |
765 |
|
else if (vdef(MATERIAL)) |
766 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
767 |
< |
vval(MATERIAL), vval(ILLUM), oct0name); |
766 |
> |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
767 |
> |
vval(MATERIAL), illumtmp, oct1name); |
768 |
|
else |
769 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
770 |
< |
vval(ILLUM), oct0name); |
769 |
> |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
770 |
> |
illumtmp, oct1name); |
771 |
|
if (runcom(combuf)) { /* run it */ |
772 |
|
fprintf(stderr, |
773 |
|
"%s: error generating octree\n\t%s removed\n", |
774 |
< |
progname, oct0name); |
775 |
< |
unlink(oct0name); |
774 |
> |
progname, oct1name); |
775 |
> |
unlink(oct1name); |
776 |
|
exit(1); |
777 |
|
} |
778 |
< |
oct0date = time(0); |
778 |
> |
rmfile(illumtmp); |
779 |
|
} |
780 |
< |
mkillumopts(mkopts); /* build mkillum command */ |
781 |
< |
mktemp(illumtmp); |
782 |
< |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
648 |
< |
oct0name, vval(ILLUM), illumtmp); |
649 |
< |
if (runcom(combuf)) { /* run it */ |
650 |
< |
fprintf(stderr, "%s: error running mkillum\n", progname); |
651 |
< |
unlink(illumtmp); |
652 |
< |
exit(1); |
653 |
< |
} |
654 |
< |
/* make octree1 (frozen) */ |
655 |
< |
if (octreedate) |
656 |
< |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
657 |
< |
vval(OCTREE), illumtmp, oct1name); |
658 |
< |
else if (vdef(MATERIAL)) |
659 |
< |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
660 |
< |
vval(MATERIAL), illumtmp, oct1name); |
661 |
< |
else |
662 |
< |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
663 |
< |
illumtmp, oct1name); |
664 |
< |
if (runcom(combuf)) { /* run it */ |
665 |
< |
fprintf(stderr, |
666 |
< |
"%s: error generating octree\n\t%s removed\n", |
667 |
< |
progname, oct1name); |
668 |
< |
unlink(oct1name); |
669 |
< |
exit(1); |
670 |
< |
} |
671 |
< |
oct1date = time(0); |
672 |
< |
rmfile(illumtmp); |
780 |
> |
oct1date = time((time_t *)NULL); |
781 |
> |
if (oct1date < oct0date) /* in case clock is off */ |
782 |
> |
oct1date = oct0date; |
783 |
|
} |
784 |
|
|
785 |
|
|
818 |
|
|
819 |
|
checkambfile() /* check date on ambient file */ |
820 |
|
{ |
821 |
< |
unsigned long afdate; |
821 |
> |
time_t afdate; |
822 |
|
|
823 |
|
if (!vdef(AMBFILE)) |
824 |
|
return; |
825 |
|
if (!(afdate = fdate(vval(AMBFILE)))) |
826 |
|
return; |
827 |
|
if (oct1date > afdate) |
828 |
< |
rmfile(vval(AMBFILE)); |
828 |
> |
if (touchonly) |
829 |
> |
touch(vval(AMBFILE)); |
830 |
> |
else |
831 |
> |
rmfile(vval(AMBFILE)); |
832 |
|
} |
833 |
|
|
834 |
|
|
836 |
|
ambval() /* compute ambient value */ |
837 |
|
{ |
838 |
|
if (vdef(EXPOSURE)) { |
726 |
– |
if (!isflt(vval(EXPOSURE))) |
727 |
– |
badvalue(EXPOSURE); |
839 |
|
if (vval(EXPOSURE)[0] == '+' || vval(EXPOSURE)[0] == '-') |
840 |
|
return(.5/pow(2.,atof(vval(EXPOSURE)))); |
841 |
|
return(.5/atof(vval(EXPOSURE))); |
848 |
|
} |
849 |
|
|
850 |
|
|
851 |
< |
lowqopts(op) /* low quality rendering options */ |
851 |
> |
renderopts(op, po) /* set rendering options */ |
852 |
> |
char *op, *po; |
853 |
> |
{ |
854 |
> |
switch(vscale(QUALITY)) { |
855 |
> |
case LOW: |
856 |
> |
lowqopts(op, po); |
857 |
> |
break; |
858 |
> |
case MEDIUM: |
859 |
> |
medqopts(op, po); |
860 |
> |
break; |
861 |
> |
case HIGH: |
862 |
> |
hiqopts(op, po); |
863 |
> |
break; |
864 |
> |
} |
865 |
> |
} |
866 |
> |
|
867 |
> |
|
868 |
> |
lowqopts(op, po) /* low quality rendering options */ |
869 |
|
register char *op; |
870 |
+ |
char *po; |
871 |
|
{ |
872 |
|
double d, org[3], siz[3]; |
873 |
|
|
874 |
|
*op = '\0'; |
875 |
+ |
*po = '\0'; |
876 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
877 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
878 |
|
badvalue(ZONE); |
879 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
880 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
881 |
+ |
badvalue(ZONE); |
882 |
|
getoctcube(org, &d); |
883 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
884 |
|
switch (vscale(DETAIL)) { |
885 |
|
case LOW: |
886 |
< |
op = addarg(op, "-ps 16 -dp 64"); |
886 |
> |
po = addarg(po, "-ps 16"); |
887 |
> |
op = addarg(op, "-dp 64"); |
888 |
|
sprintf(op, " -ar %d", (int)(4*d)); |
889 |
|
op += strlen(op); |
890 |
|
break; |
891 |
|
case MEDIUM: |
892 |
< |
op = addarg(op, "-ps 8 -dp 128"); |
892 |
> |
po = addarg(po, "-ps 8"); |
893 |
> |
op = addarg(op, "-dp 128"); |
894 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
895 |
|
op += strlen(op); |
896 |
|
break; |
897 |
|
case HIGH: |
898 |
< |
op = addarg(op, "-ps 4 -dp 256"); |
898 |
> |
po = addarg(po, "-ps 4"); |
899 |
> |
op = addarg(op, "-dp 256"); |
900 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
901 |
|
op += strlen(op); |
902 |
|
break; |
903 |
|
} |
904 |
< |
op = addarg(op, "-pt .16"); |
904 |
> |
po = addarg(po, "-pt .16"); |
905 |
|
if (vbool(PENUMBRAS)) |
906 |
|
op = addarg(op, "-ds .4"); |
907 |
|
else |
933 |
|
} |
934 |
|
|
935 |
|
|
936 |
< |
medqopts(op) /* medium quality rendering options */ |
936 |
> |
medqopts(op, po) /* medium quality rendering options */ |
937 |
|
register char *op; |
938 |
+ |
char *po; |
939 |
|
{ |
940 |
|
double d, org[3], siz[3]; |
941 |
|
|
942 |
|
*op = '\0'; |
943 |
+ |
*po = '\0'; |
944 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
945 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
946 |
|
badvalue(ZONE); |
947 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
948 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
949 |
+ |
badvalue(ZONE); |
950 |
|
getoctcube(org, &d); |
951 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
952 |
|
switch (vscale(DETAIL)) { |
953 |
|
case LOW: |
954 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
954 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
955 |
|
op = addarg(op, "-dp 256"); |
956 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
957 |
|
op += strlen(op); |
958 |
|
break; |
959 |
|
case MEDIUM: |
960 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
960 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
961 |
|
op = addarg(op, "-dp 512"); |
962 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
963 |
|
op += strlen(op); |
964 |
|
break; |
965 |
|
case HIGH: |
966 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
966 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
967 |
|
op = addarg(op, "-dp 1024"); |
968 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
969 |
|
op += strlen(op); |
970 |
|
break; |
971 |
|
} |
972 |
< |
op = addarg(op, "-pt .08"); |
972 |
> |
po = addarg(po, "-pt .08"); |
973 |
|
if (vbool(PENUMBRAS)) |
974 |
< |
op = addarg(op, "-ds .2 -dj .35"); |
974 |
> |
op = addarg(op, "-ds .2 -dj .5"); |
975 |
|
else |
976 |
|
op = addarg(op, "-ds .3"); |
977 |
|
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
1004 |
|
} |
1005 |
|
|
1006 |
|
|
1007 |
< |
hiqopts(op) /* high quality rendering options */ |
1007 |
> |
hiqopts(op, po) /* high quality rendering options */ |
1008 |
|
register char *op; |
1009 |
+ |
char *po; |
1010 |
|
{ |
1011 |
|
double d, org[3], siz[3]; |
1012 |
|
|
1013 |
|
*op = '\0'; |
1014 |
+ |
*po = '\0'; |
1015 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
1016 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
1017 |
|
badvalue(ZONE); |
1018 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
1019 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
1020 |
+ |
badvalue(ZONE); |
1021 |
|
getoctcube(org, &d); |
1022 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
1023 |
|
switch (vscale(DETAIL)) { |
1024 |
|
case LOW: |
1025 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
1025 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
1026 |
|
op = addarg(op, "-dp 1024"); |
1027 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
1028 |
|
op += strlen(op); |
1029 |
|
break; |
1030 |
|
case MEDIUM: |
1031 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
1031 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
1032 |
|
op = addarg(op, "-dp 2048"); |
1033 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
1034 |
|
op += strlen(op); |
1035 |
|
break; |
1036 |
|
case HIGH: |
1037 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
1037 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
1038 |
|
op = addarg(op, "-dp 4096"); |
1039 |
|
sprintf(op, " -ar %d", (int)(64*d)); |
1040 |
|
op += strlen(op); |
1041 |
|
break; |
1042 |
|
} |
1043 |
< |
op = addarg(op, "-pt .04"); |
1043 |
> |
po = addarg(po, "-pt .04"); |
1044 |
|
if (vbool(PENUMBRAS)) |
1045 |
|
op = addarg(op, "-ds .1 -dj .7"); |
1046 |
|
else |
1190 |
|
badvalue(ZONE); |
1191 |
|
for (i = 0; i < 3; i++) { |
1192 |
|
dim[i] -= cent[i]; |
1193 |
+ |
if (dim[i] <= FTINY) |
1194 |
+ |
badvalue(ZONE); |
1195 |
|
cent[i] += .5*dim[i]; |
1196 |
|
} |
1197 |
|
mult = vlet(ZONE)=='E' ? 2. : .45 ; |
1355 |
|
} |
1356 |
|
|
1357 |
|
|
1358 |
< |
rview(opts) /* run rview with first view */ |
1359 |
< |
char *opts; |
1358 |
> |
rview(opts, po) /* run rview with first view */ |
1359 |
> |
char *opts, *po; |
1360 |
|
{ |
1361 |
|
char *vw; |
1362 |
|
char combuf[512]; |
1363 |
|
/* build command */ |
1364 |
< |
if ((vw = getview(0, NULL)) == NULL) |
1364 |
> |
if (touchonly || (vw = getview(0, NULL)) == NULL) |
1365 |
|
return; |
1366 |
|
if (sayview) |
1367 |
|
printview(vw); |
1368 |
< |
sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname); |
1368 |
> |
sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname); |
1369 |
|
if (rvdevice != NULL) |
1370 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
1371 |
+ |
if (vdef(EXPOSURE)) |
1372 |
+ |
sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); |
1373 |
|
strcat(combuf, oct1name); |
1374 |
|
if (runcom(combuf)) { /* run it */ |
1375 |
|
fprintf(stderr, "%s: error running rview\n", progname); |
1378 |
|
} |
1379 |
|
|
1380 |
|
|
1381 |
< |
rpict(opts) /* run rpict and pfilt for each view */ |
1382 |
< |
char *opts; |
1381 |
> |
rpict(opts, po) /* run rpict and pfilt for each view */ |
1382 |
> |
char *opts, *po; |
1383 |
|
{ |
1384 |
|
char combuf[1024]; |
1385 |
|
char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32]; |
1386 |
|
char pfopts[128]; |
1387 |
|
char vs[32], *vw; |
1388 |
|
int vn, mult; |
1389 |
+ |
time_t rfdt, pfdt; |
1390 |
|
/* get pfilt options */ |
1391 |
|
pfiltopts(pfopts); |
1392 |
|
/* get resolution, reporting */ |
1393 |
< |
mult = vscale(QUALITY)+1; |
1393 |
> |
switch (vscale(QUALITY)) { |
1394 |
> |
case LOW: |
1395 |
> |
mult = 1; |
1396 |
> |
break; |
1397 |
> |
case MEDIUM: |
1398 |
> |
mult = 2; |
1399 |
> |
break; |
1400 |
> |
case HIGH: |
1401 |
> |
mult = 3; |
1402 |
> |
break; |
1403 |
> |
} |
1404 |
|
{ |
1405 |
|
int xres, yres; |
1406 |
|
double aspect; |
1436 |
|
sprintf(vs, "%d", vn); |
1437 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1438 |
|
/* check date on picture */ |
1439 |
< |
if (fdate(picfile) >= oct1date) |
1439 |
> |
pfdt = fdate(picfile); |
1440 |
> |
if (pfdt >= oct1date) |
1441 |
|
continue; |
1442 |
< |
/* build rpict command */ |
1442 |
> |
/* get raw file name */ |
1443 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
1444 |
< |
if (fdate(rawfile) >= oct1date) /* recover */ |
1445 |
< |
sprintf(combuf, "rpict%s%s -ro %s %s", |
1446 |
< |
rep, opts, rawfile, oct1name); |
1444 |
> |
rfdt = fdate(rawfile); |
1445 |
> |
if (touchonly) { /* update times only */ |
1446 |
> |
if (rfdt) { |
1447 |
> |
if (rfdt < oct1date) |
1448 |
> |
touch(rawfile); |
1449 |
> |
} else if (pfdt && pfdt < oct1date) |
1450 |
> |
touch(picfile); |
1451 |
> |
continue; |
1452 |
> |
} |
1453 |
> |
/* build rpict command */ |
1454 |
> |
if (rfdt >= oct1date) /* recover */ |
1455 |
> |
sprintf(combuf, "rpict%s%s%s -ro %s %s", |
1456 |
> |
rep, po, opts, rawfile, oct1name); |
1457 |
|
else { |
1458 |
|
if (overture) { /* run overture calculation */ |
1459 |
|
sprintf(combuf, |
1470 |
|
rmfile(overfile); |
1471 |
|
#endif |
1472 |
|
} |
1473 |
< |
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
1474 |
< |
rep, vw, res, opts, |
1475 |
< |
oct1name, rawfile); |
1473 |
> |
sprintf(combuf, "rpict%s %s %s%s%s %s > %s", |
1474 |
> |
rep, vw, res, po, opts, |
1475 |
> |
oct1name, rawfile); |
1476 |
|
} |
1477 |
|
if (runcom(combuf)) { /* run rpict */ |
1478 |
|
fprintf(stderr, "%s: error rendering view %s\n", |
1496 |
|
/* remove raw file */ |
1497 |
|
rmfile(rawfile); |
1498 |
|
} |
1499 |
+ |
} |
1500 |
+ |
|
1501 |
+ |
|
1502 |
+ |
touch(fn) /* update a file */ |
1503 |
+ |
char *fn; |
1504 |
+ |
{ |
1505 |
+ |
if (!silent) |
1506 |
+ |
printf("\ttouch %s\n", fn); |
1507 |
+ |
if (noaction) |
1508 |
+ |
return(0); |
1509 |
+ |
#ifdef notused |
1510 |
+ |
if (access(fn, F_OK) == -1) /* create it */ |
1511 |
+ |
if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) |
1512 |
+ |
return(-1); |
1513 |
+ |
#endif |
1514 |
+ |
return(setfdate(fn, time((time_t *)NULL))); |
1515 |
|
} |
1516 |
|
|
1517 |
|
|