| 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 { |
| 49 |
|
#define PENUMBRAS 20 /* shadow penumbras are desired */ |
| 50 |
|
#define VARIABILITY 21 /* level of light variability */ |
| 51 |
|
#define REPORT 22 /* report frequency and errfile */ |
| 52 |
+ |
#define RAWSAVE 23 /* save raw picture file */ |
| 53 |
|
/* total number of variables */ |
| 54 |
< |
#define NVARS 23 |
| 54 |
> |
#define NVARS 24 |
| 55 |
|
|
| 56 |
|
VARIABLE vv[NVARS] = { /* variable-value pairs */ |
| 57 |
|
{"objects", 3, 0, NULL, catvalues}, |
| 77 |
|
{"PENUMBRAS", 3, 0, NULL, boolvalue}, |
| 78 |
|
{"VARIABILITY", 3, 0, NULL, qualvalue}, |
| 79 |
|
{"REPORT", 3, 0, NULL, onevalue}, |
| 80 |
+ |
{"RAWSAVE", 3, 0, NULL, boolvalue}, |
| 81 |
|
}; |
| 82 |
|
|
| 83 |
|
VARIABLE *matchvar(); |
| 104 |
|
char overfile[] = "/dev/null"; |
| 105 |
|
#endif |
| 106 |
|
|
| 107 |
< |
extern unsigned long fdate(), time(); |
| 107 |
> |
extern time_t fdate(), time(); |
| 108 |
|
|
| 109 |
< |
unsigned long scenedate; /* date of latest scene or object file */ |
| 110 |
< |
unsigned long octreedate; /* date of octree */ |
| 111 |
< |
unsigned long matdate; /* date of latest material file */ |
| 112 |
< |
unsigned long illumdate; /* date of last illum file */ |
| 109 |
> |
time_t scenedate; /* date of latest scene or object file */ |
| 110 |
> |
time_t octreedate; /* date of octree */ |
| 111 |
> |
time_t matdate; /* date of latest material file */ |
| 112 |
> |
time_t illumdate; /* date of last illum file */ |
| 113 |
|
|
| 114 |
|
char *oct0name; /* name of pre-mkillum octree */ |
| 115 |
< |
unsigned long oct0date; /* date of pre-mkillum octree */ |
| 115 |
> |
time_t oct0date; /* date of pre-mkillum octree */ |
| 116 |
|
char *oct1name; /* name of post-mkillum octree */ |
| 117 |
< |
unsigned long oct1date; /* date of post-mkillum octree (>= matdate) */ |
| 117 |
> |
time_t oct1date; /* date of post-mkillum octree (>= matdate) */ |
| 118 |
|
|
| 119 |
+ |
int nowarn = 0; /* no warnings */ |
| 120 |
|
int explicate = 0; /* explicate variables */ |
| 121 |
|
int silent = 0; /* do work silently */ |
| 122 |
+ |
int touchonly = 0; /* touch files only */ |
| 123 |
|
int noaction = 0; /* don't do anything */ |
| 124 |
|
int sayview = 0; /* print view out */ |
| 125 |
|
char *rvdevice = NULL; /* rview output device */ |
| 138 |
|
char *argv[]; |
| 139 |
|
{ |
| 140 |
|
char ropts[512]; |
| 141 |
+ |
char popts[64]; |
| 142 |
|
int i; |
| 143 |
|
|
| 144 |
|
progname = argv[0]; |
| 151 |
|
case 'n': |
| 152 |
|
noaction++; |
| 153 |
|
break; |
| 154 |
+ |
case 't': |
| 155 |
+ |
touchonly++; |
| 156 |
+ |
break; |
| 157 |
|
case 'e': |
| 158 |
|
explicate++; |
| 159 |
|
break; |
| 166 |
|
case 'v': |
| 167 |
|
viewselect = argv[++i]; |
| 168 |
|
break; |
| 169 |
+ |
case 'w': |
| 170 |
+ |
nowarn++; |
| 171 |
+ |
break; |
| 172 |
|
default: |
| 173 |
|
goto userr; |
| 174 |
|
} |
| 196 |
|
/* check date on ambient file */ |
| 197 |
|
checkambfile(); |
| 198 |
|
/* run simulation */ |
| 199 |
< |
renderopts(ropts); |
| 199 |
> |
renderopts(ropts, popts); |
| 200 |
|
xferopts(ropts); |
| 201 |
|
if (rvdevice != NULL) |
| 202 |
< |
rview(ropts); |
| 202 |
> |
rview(ropts, popts); |
| 203 |
|
else |
| 204 |
< |
rpict(ropts); |
| 204 |
> |
rpict(ropts, popts); |
| 205 |
|
exit(0); |
| 206 |
|
userr: |
| 207 |
|
fprintf(stderr, |
| 208 |
< |
"Usage: %s [-s][-n][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
| 208 |
> |
"Usage: %s [-s][-n][-t][-e][-V][-v view][-o dev] rfile [VAR=value ..]\n", |
| 209 |
|
progname); |
| 210 |
|
exit(1); |
| 211 |
|
} |
| 264 |
|
register char *ass; |
| 265 |
|
{ |
| 266 |
|
char varname[32]; |
| 255 |
– |
char varval[512]; |
| 267 |
|
int n; |
| 268 |
|
register char *cp; |
| 269 |
|
register VARIABLE *vp; |
| 284 |
|
for (n = strlen(ass); n > 0; n--) |
| 285 |
|
if (!isspace(ass[n-1])) |
| 286 |
|
break; |
| 287 |
< |
if (!n) { |
| 287 |
> |
if (!n && !nowarn) { |
| 288 |
|
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
| 289 |
|
progname, varname); |
| 290 |
|
return; |
| 370 |
|
{ |
| 371 |
|
if (vp->nass < 2) |
| 372 |
|
return; |
| 373 |
< |
fprintf(stderr, "%s: warning - multiple assignment of variable '%s'\n", |
| 373 |
> |
if (!nowarn) |
| 374 |
> |
fprintf(stderr, |
| 375 |
> |
"%s: warning - multiple assignment of variable '%s'\n", |
| 376 |
|
progname, vp->name); |
| 377 |
|
do |
| 378 |
|
vp->value += strlen(vp->value)+1; |
| 473 |
|
} |
| 474 |
|
|
| 475 |
|
|
| 476 |
< |
unsigned long |
| 476 |
> |
time_t |
| 477 |
|
checklast(fnames) /* check files and find most recent */ |
| 478 |
|
register char *fnames; |
| 479 |
|
{ |
| 480 |
|
char thisfile[MAXPATH]; |
| 481 |
< |
unsigned long thisdate, lastdate = 0; |
| 481 |
> |
time_t thisdate, lastdate = 0; |
| 482 |
|
register char *cp; |
| 483 |
|
|
| 484 |
|
if (fnames == NULL) |
| 526 |
|
|
| 527 |
|
checkfiles() /* check for existence and modified times */ |
| 528 |
|
{ |
| 529 |
< |
unsigned long objdate; |
| 529 |
> |
time_t objdate; |
| 530 |
|
|
| 531 |
|
if (!vdef(OCTREE)) { |
| 532 |
|
if ((vval(OCTREE) = bmalloc(strlen(radname)+5)) == NULL) |
| 649 |
|
vval(VARIABILITY) = "L"; |
| 650 |
|
vdef(VARIABILITY)++; |
| 651 |
|
} |
| 652 |
+ |
if (!vdef(RAWSAVE)) { |
| 653 |
+ |
vval(RAWSAVE) = "F"; |
| 654 |
+ |
vdef(RAWSAVE)++; |
| 655 |
+ |
} |
| 656 |
|
} |
| 657 |
|
|
| 658 |
|
|
| 659 |
|
printvals() /* print variable values */ |
| 660 |
|
{ |
| 661 |
< |
register int i, j; |
| 661 |
> |
int i, j, clipline; |
| 662 |
> |
register char *cp; |
| 663 |
> |
register int k; |
| 664 |
|
|
| 665 |
< |
for (i = 0; i < NVARS; i++) |
| 666 |
< |
for (j = 0; j < vdef(i); j++) |
| 667 |
< |
printf("%s= %s\n", vnam(i), nvalue(vv+i, j)); |
| 665 |
> |
for (i = 0; i < NVARS; i++) /* print each variable */ |
| 666 |
> |
for (j = 0; j < vdef(i); j++) { /* print each assignment */ |
| 667 |
> |
fputs(vnam(i), stdout); |
| 668 |
> |
fputs("= ", stdout); |
| 669 |
> |
k = clipline = ( vv[i].fixval == catvalues ? 64 : 320 ) |
| 670 |
> |
- strlen(vnam(i)) ; |
| 671 |
> |
cp = nvalue(vv+i, j); |
| 672 |
> |
while (*cp) { |
| 673 |
> |
putchar(*cp++); |
| 674 |
> |
if (--k <= 0) { /* line too long */ |
| 675 |
> |
while (*cp && !isspace(*cp)) |
| 676 |
> |
putchar(*cp++); /* finish this word */ |
| 677 |
> |
if (*cp) { /* start new line */ |
| 678 |
> |
putchar('\n'); |
| 679 |
> |
fputs(vnam(i), stdout); |
| 680 |
> |
putchar('='); |
| 681 |
> |
k = clipline; |
| 682 |
> |
} |
| 683 |
> |
} |
| 684 |
> |
} |
| 685 |
> |
putchar('\n'); |
| 686 |
> |
} |
| 687 |
|
fflush(stdout); |
| 688 |
|
} |
| 689 |
|
|
| 695 |
|
|
| 696 |
|
oconvopts(ocopts); /* get options */ |
| 697 |
|
if (octreedate < scenedate) { /* check date on original octree */ |
| 698 |
< |
/* build command */ |
| 699 |
< |
if (vdef(MATERIAL)) |
| 700 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
| 701 |
< |
vval(MATERIAL), vval(SCENE), vval(OCTREE)); |
| 702 |
< |
else |
| 703 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
| 704 |
< |
vval(SCENE), vval(OCTREE)); |
| 705 |
< |
|
| 706 |
< |
if (runcom(combuf)) { /* run it */ |
| 707 |
< |
fprintf(stderr, |
| 698 |
> |
if (touchonly && octreedate) |
| 699 |
> |
touch(vval(OCTREE)); |
| 700 |
> |
else { /* build command */ |
| 701 |
> |
if (vdef(MATERIAL)) |
| 702 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
| 703 |
> |
vval(MATERIAL), vval(SCENE), |
| 704 |
> |
vval(OCTREE)); |
| 705 |
> |
else |
| 706 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
| 707 |
> |
vval(SCENE), vval(OCTREE)); |
| 708 |
> |
|
| 709 |
> |
if (runcom(combuf)) { /* run it */ |
| 710 |
> |
fprintf(stderr, |
| 711 |
|
"%s: error generating octree\n\t%s removed\n", |
| 712 |
< |
progname, vval(OCTREE)); |
| 713 |
< |
unlink(vval(OCTREE)); |
| 714 |
< |
exit(1); |
| 712 |
> |
progname, vval(OCTREE)); |
| 713 |
> |
unlink(vval(OCTREE)); |
| 714 |
> |
exit(1); |
| 715 |
> |
} |
| 716 |
|
} |
| 717 |
< |
octreedate = time(0); |
| 717 |
> |
octreedate = time((time_t *)NULL); |
| 718 |
> |
if (octreedate < scenedate) /* in case clock is off */ |
| 719 |
> |
octreedate = scenedate; |
| 720 |
|
} |
| 721 |
|
if (oct1name == vval(OCTREE)) /* no mkillum? */ |
| 722 |
|
oct1date = octreedate > matdate ? octreedate : matdate; |
| 725 |
|
return; |
| 726 |
|
/* make octree0 */ |
| 727 |
|
if (oct0date < scenedate | oct0date < illumdate) { |
| 728 |
< |
/* build command */ |
| 728 |
> |
if (touchonly && oct0date) |
| 729 |
> |
touch(oct0name); |
| 730 |
> |
else { /* build command */ |
| 731 |
> |
if (octreedate) |
| 732 |
> |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
| 733 |
> |
vval(OCTREE), vval(ILLUM), oct0name); |
| 734 |
> |
else if (vdef(MATERIAL)) |
| 735 |
> |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
| 736 |
> |
vval(MATERIAL), vval(ILLUM), oct0name); |
| 737 |
> |
else |
| 738 |
> |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
| 739 |
> |
vval(ILLUM), oct0name); |
| 740 |
> |
if (runcom(combuf)) { /* run it */ |
| 741 |
> |
fprintf(stderr, |
| 742 |
> |
"%s: error generating octree\n\t%s removed\n", |
| 743 |
> |
progname, oct0name); |
| 744 |
> |
unlink(oct0name); |
| 745 |
> |
exit(1); |
| 746 |
> |
} |
| 747 |
> |
} |
| 748 |
> |
oct0date = time((time_t *)NULL); |
| 749 |
> |
if (oct0date < octreedate) /* in case clock is off */ |
| 750 |
> |
oct0date = octreedate; |
| 751 |
> |
if (oct0date < illumdate) /* ditto */ |
| 752 |
> |
oct0date = illumdate; |
| 753 |
> |
} |
| 754 |
> |
if (touchonly && oct1date) |
| 755 |
> |
touch(oct1name); |
| 756 |
> |
else { |
| 757 |
> |
mkillumopts(mkopts); /* build mkillum command */ |
| 758 |
> |
mktemp(illumtmp); |
| 759 |
> |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
| 760 |
> |
oct0name, vval(ILLUM), illumtmp); |
| 761 |
> |
if (runcom(combuf)) { /* run it */ |
| 762 |
> |
fprintf(stderr, "%s: error running mkillum\n", |
| 763 |
> |
progname); |
| 764 |
> |
unlink(illumtmp); |
| 765 |
> |
exit(1); |
| 766 |
> |
} |
| 767 |
> |
/* make octree1 (frozen) */ |
| 768 |
|
if (octreedate) |
| 769 |
< |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
| 770 |
< |
vval(OCTREE), vval(ILLUM), oct0name); |
| 769 |
> |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
| 770 |
> |
vval(OCTREE), illumtmp, oct1name); |
| 771 |
|
else if (vdef(MATERIAL)) |
| 772 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
| 773 |
< |
vval(MATERIAL), vval(ILLUM), oct0name); |
| 772 |
> |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
| 773 |
> |
vval(MATERIAL), illumtmp, oct1name); |
| 774 |
|
else |
| 775 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
| 776 |
< |
vval(ILLUM), oct0name); |
| 775 |
> |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
| 776 |
> |
illumtmp, oct1name); |
| 777 |
|
if (runcom(combuf)) { /* run it */ |
| 778 |
|
fprintf(stderr, |
| 779 |
|
"%s: error generating octree\n\t%s removed\n", |
| 780 |
< |
progname, oct0name); |
| 781 |
< |
unlink(oct0name); |
| 780 |
> |
progname, oct1name); |
| 781 |
> |
unlink(oct1name); |
| 782 |
|
exit(1); |
| 783 |
|
} |
| 784 |
< |
oct0date = time(0); |
| 784 |
> |
rmfile(illumtmp); |
| 785 |
|
} |
| 786 |
< |
mkillumopts(mkopts); /* build mkillum command */ |
| 787 |
< |
mktemp(illumtmp); |
| 788 |
< |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
| 706 |
< |
oct0name, vval(ILLUM), illumtmp); |
| 707 |
< |
if (runcom(combuf)) { /* run it */ |
| 708 |
< |
fprintf(stderr, "%s: error running mkillum\n", progname); |
| 709 |
< |
unlink(illumtmp); |
| 710 |
< |
exit(1); |
| 711 |
< |
} |
| 712 |
< |
/* make octree1 (frozen) */ |
| 713 |
< |
if (octreedate) |
| 714 |
< |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
| 715 |
< |
vval(OCTREE), illumtmp, oct1name); |
| 716 |
< |
else if (vdef(MATERIAL)) |
| 717 |
< |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
| 718 |
< |
vval(MATERIAL), illumtmp, oct1name); |
| 719 |
< |
else |
| 720 |
< |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
| 721 |
< |
illumtmp, oct1name); |
| 722 |
< |
if (runcom(combuf)) { /* run it */ |
| 723 |
< |
fprintf(stderr, |
| 724 |
< |
"%s: error generating octree\n\t%s removed\n", |
| 725 |
< |
progname, oct1name); |
| 726 |
< |
unlink(oct1name); |
| 727 |
< |
exit(1); |
| 728 |
< |
} |
| 729 |
< |
oct1date = time(0); |
| 730 |
< |
rmfile(illumtmp); |
| 786 |
> |
oct1date = time((time_t *)NULL); |
| 787 |
> |
if (oct1date < oct0date) /* in case clock is off */ |
| 788 |
> |
oct1date = oct0date; |
| 789 |
|
} |
| 790 |
|
|
| 791 |
|
|
| 824 |
|
|
| 825 |
|
checkambfile() /* check date on ambient file */ |
| 826 |
|
{ |
| 827 |
< |
unsigned long afdate; |
| 827 |
> |
time_t afdate; |
| 828 |
|
|
| 829 |
|
if (!vdef(AMBFILE)) |
| 830 |
|
return; |
| 831 |
|
if (!(afdate = fdate(vval(AMBFILE)))) |
| 832 |
|
return; |
| 833 |
|
if (oct1date > afdate) |
| 834 |
< |
rmfile(vval(AMBFILE)); |
| 834 |
> |
if (touchonly) |
| 835 |
> |
touch(vval(AMBFILE)); |
| 836 |
> |
else |
| 837 |
> |
rmfile(vval(AMBFILE)); |
| 838 |
|
} |
| 839 |
|
|
| 840 |
|
|
| 854 |
|
} |
| 855 |
|
|
| 856 |
|
|
| 857 |
< |
renderopts(op) /* set rendering options */ |
| 858 |
< |
char *op; |
| 857 |
> |
renderopts(op, po) /* set rendering options */ |
| 858 |
> |
char *op, *po; |
| 859 |
|
{ |
| 860 |
|
switch(vscale(QUALITY)) { |
| 861 |
|
case LOW: |
| 862 |
< |
lowqopts(op); |
| 862 |
> |
lowqopts(op, po); |
| 863 |
|
break; |
| 864 |
|
case MEDIUM: |
| 865 |
< |
medqopts(op); |
| 865 |
> |
medqopts(op, po); |
| 866 |
|
break; |
| 867 |
|
case HIGH: |
| 868 |
< |
hiqopts(op); |
| 868 |
> |
hiqopts(op, po); |
| 869 |
|
break; |
| 870 |
|
} |
| 871 |
|
} |
| 872 |
|
|
| 873 |
|
|
| 874 |
< |
lowqopts(op) /* low quality rendering options */ |
| 874 |
> |
lowqopts(op, po) /* low quality rendering options */ |
| 875 |
|
register char *op; |
| 876 |
+ |
char *po; |
| 877 |
|
{ |
| 878 |
|
double d, org[3], siz[3]; |
| 879 |
|
|
| 880 |
|
*op = '\0'; |
| 881 |
+ |
*po = '\0'; |
| 882 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
| 883 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
| 884 |
|
badvalue(ZONE); |
| 885 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
| 886 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
| 887 |
+ |
badvalue(ZONE); |
| 888 |
|
getoctcube(org, &d); |
| 889 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
| 890 |
|
switch (vscale(DETAIL)) { |
| 891 |
|
case LOW: |
| 892 |
< |
op = addarg(op, "-ps 16 -dp 64"); |
| 892 |
> |
po = addarg(po, "-ps 16"); |
| 893 |
> |
op = addarg(op, "-dp 64"); |
| 894 |
|
sprintf(op, " -ar %d", (int)(4*d)); |
| 895 |
|
op += strlen(op); |
| 896 |
|
break; |
| 897 |
|
case MEDIUM: |
| 898 |
< |
op = addarg(op, "-ps 8 -dp 128"); |
| 898 |
> |
po = addarg(po, "-ps 8"); |
| 899 |
> |
op = addarg(op, "-dp 128"); |
| 900 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
| 901 |
|
op += strlen(op); |
| 902 |
|
break; |
| 903 |
|
case HIGH: |
| 904 |
< |
op = addarg(op, "-ps 4 -dp 256"); |
| 904 |
> |
po = addarg(po, "-ps 4"); |
| 905 |
> |
op = addarg(op, "-dp 256"); |
| 906 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
| 907 |
|
op += strlen(op); |
| 908 |
|
break; |
| 909 |
|
} |
| 910 |
< |
op = addarg(op, "-pt .16"); |
| 910 |
> |
po = addarg(po, "-pt .16"); |
| 911 |
|
if (vbool(PENUMBRAS)) |
| 912 |
|
op = addarg(op, "-ds .4"); |
| 913 |
|
else |
| 939 |
|
} |
| 940 |
|
|
| 941 |
|
|
| 942 |
< |
medqopts(op) /* medium quality rendering options */ |
| 942 |
> |
medqopts(op, po) /* medium quality rendering options */ |
| 943 |
|
register char *op; |
| 944 |
+ |
char *po; |
| 945 |
|
{ |
| 946 |
|
double d, org[3], siz[3]; |
| 947 |
|
|
| 948 |
|
*op = '\0'; |
| 949 |
+ |
*po = '\0'; |
| 950 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
| 951 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
| 952 |
|
badvalue(ZONE); |
| 953 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
| 954 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
| 955 |
+ |
badvalue(ZONE); |
| 956 |
|
getoctcube(org, &d); |
| 957 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
| 958 |
|
switch (vscale(DETAIL)) { |
| 959 |
|
case LOW: |
| 960 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
| 960 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 4" : "-ps 8"); |
| 961 |
|
op = addarg(op, "-dp 256"); |
| 962 |
|
sprintf(op, " -ar %d", (int)(8*d)); |
| 963 |
|
op += strlen(op); |
| 964 |
|
break; |
| 965 |
|
case MEDIUM: |
| 966 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
| 966 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 3" : "-ps 6"); |
| 967 |
|
op = addarg(op, "-dp 512"); |
| 968 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
| 969 |
|
op += strlen(op); |
| 970 |
|
break; |
| 971 |
|
case HIGH: |
| 972 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
| 972 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 2" : "-ps 4"); |
| 973 |
|
op = addarg(op, "-dp 1024"); |
| 974 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
| 975 |
|
op += strlen(op); |
| 976 |
|
break; |
| 977 |
|
} |
| 978 |
< |
op = addarg(op, "-pt .08"); |
| 978 |
> |
po = addarg(po, "-pt .08"); |
| 979 |
|
if (vbool(PENUMBRAS)) |
| 980 |
|
op = addarg(op, "-ds .2 -dj .5"); |
| 981 |
|
else |
| 1010 |
|
} |
| 1011 |
|
|
| 1012 |
|
|
| 1013 |
< |
hiqopts(op) /* high quality rendering options */ |
| 1013 |
> |
hiqopts(op, po) /* high quality rendering options */ |
| 1014 |
|
register char *op; |
| 1015 |
+ |
char *po; |
| 1016 |
|
{ |
| 1017 |
|
double d, org[3], siz[3]; |
| 1018 |
|
|
| 1019 |
|
*op = '\0'; |
| 1020 |
+ |
*po = '\0'; |
| 1021 |
|
if (sscanf(vval(ZONE), "%*s %lf %lf %lf %lf %lf %lf", &org[0], |
| 1022 |
|
&siz[0], &org[1], &siz[1], &org[2], &siz[2]) != 6) |
| 1023 |
|
badvalue(ZONE); |
| 1024 |
|
siz[0] -= org[0]; siz[1] -= org[1]; siz[2] -= org[2]; |
| 1025 |
+ |
if (siz[0] <= FTINY | siz[1] <= FTINY | siz[2] <= FTINY) |
| 1026 |
+ |
badvalue(ZONE); |
| 1027 |
|
getoctcube(org, &d); |
| 1028 |
|
d *= 3./(siz[0]+siz[1]+siz[2]); |
| 1029 |
|
switch (vscale(DETAIL)) { |
| 1030 |
|
case LOW: |
| 1031 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
| 1031 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 8"); |
| 1032 |
|
op = addarg(op, "-dp 1024"); |
| 1033 |
|
sprintf(op, " -ar %d", (int)(16*d)); |
| 1034 |
|
op += strlen(op); |
| 1035 |
|
break; |
| 1036 |
|
case MEDIUM: |
| 1037 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
| 1037 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 5"); |
| 1038 |
|
op = addarg(op, "-dp 2048"); |
| 1039 |
|
sprintf(op, " -ar %d", (int)(32*d)); |
| 1040 |
|
op += strlen(op); |
| 1041 |
|
break; |
| 1042 |
|
case HIGH: |
| 1043 |
< |
op = addarg(op, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
| 1043 |
> |
po = addarg(po, vbool(PENUMBRAS) ? "-ps 1" : "-ps 3"); |
| 1044 |
|
op = addarg(op, "-dp 4096"); |
| 1045 |
|
sprintf(op, " -ar %d", (int)(64*d)); |
| 1046 |
|
op += strlen(op); |
| 1047 |
|
break; |
| 1048 |
|
} |
| 1049 |
< |
op = addarg(op, "-pt .04"); |
| 1049 |
> |
po = addarg(po, "-pt .04"); |
| 1050 |
|
if (vbool(PENUMBRAS)) |
| 1051 |
< |
op = addarg(op, "-ds .1 -dj .7"); |
| 1051 |
> |
op = addarg(op, "-ds .1 -dj .65"); |
| 1052 |
|
else |
| 1053 |
|
op = addarg(op, "-ds .2"); |
| 1054 |
|
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
| 1185 |
|
zpos = -1; vs++; |
| 1186 |
|
} |
| 1187 |
|
viewtype = 'v'; |
| 1188 |
< |
if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h') |
| 1188 |
> |
if (*vs == 'v' | *vs == 'l' | *vs == 'a' | *vs == 'h' | *vs == 'c') |
| 1189 |
|
viewtype = *vs++; |
| 1190 |
|
cp = viewopts; |
| 1191 |
|
if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ |
| 1196 |
|
badvalue(ZONE); |
| 1197 |
|
for (i = 0; i < 3; i++) { |
| 1198 |
|
dim[i] -= cent[i]; |
| 1199 |
+ |
if (dim[i] <= FTINY) |
| 1200 |
+ |
badvalue(ZONE); |
| 1201 |
|
cent[i] += .5*dim[i]; |
| 1202 |
|
} |
| 1203 |
|
mult = vlet(ZONE)=='E' ? 2. : .45 ; |
| 1240 |
|
case 'h': |
| 1241 |
|
cp = addarg(cp, "-vh 180 -vv 180"); |
| 1242 |
|
break; |
| 1243 |
+ |
case 'c': |
| 1244 |
+ |
cp = addarg(cp, "-vh 180 -vv 90"); |
| 1245 |
+ |
break; |
| 1246 |
|
} |
| 1247 |
|
} else { |
| 1248 |
|
while (!isspace(*vs)) /* else skip id */ |
| 1364 |
|
} |
| 1365 |
|
|
| 1366 |
|
|
| 1367 |
< |
rview(opts) /* run rview with first view */ |
| 1368 |
< |
char *opts; |
| 1367 |
> |
rview(opts, po) /* run rview with first view */ |
| 1368 |
> |
char *opts, *po; |
| 1369 |
|
{ |
| 1370 |
|
char *vw; |
| 1371 |
|
char combuf[512]; |
| 1372 |
|
/* build command */ |
| 1373 |
< |
if ((vw = getview(0, NULL)) == NULL) |
| 1373 |
> |
if (touchonly || (vw = getview(0, NULL)) == NULL) |
| 1374 |
|
return; |
| 1375 |
|
if (sayview) |
| 1376 |
|
printview(vw); |
| 1377 |
< |
sprintf(combuf, "rview %s%s -R %s ", vw, opts, rifname); |
| 1377 |
> |
sprintf(combuf, "rview %s%s%s -R %s ", vw, po, opts, rifname); |
| 1378 |
|
if (rvdevice != NULL) |
| 1379 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
| 1380 |
|
if (vdef(EXPOSURE)) |
| 1387 |
|
} |
| 1388 |
|
|
| 1389 |
|
|
| 1390 |
< |
rpict(opts) /* run rpict and pfilt for each view */ |
| 1391 |
< |
char *opts; |
| 1390 |
> |
rpict(opts, po) /* run rpict and pfilt for each view */ |
| 1391 |
> |
char *opts, *po; |
| 1392 |
|
{ |
| 1393 |
|
char combuf[1024]; |
| 1394 |
|
char rawfile[MAXPATH], picfile[MAXPATH], rep[MAXPATH+16], res[32]; |
| 1395 |
|
char pfopts[128]; |
| 1396 |
|
char vs[32], *vw; |
| 1397 |
|
int vn, mult; |
| 1398 |
+ |
time_t rfdt, pfdt; |
| 1399 |
|
/* get pfilt options */ |
| 1400 |
|
pfiltopts(pfopts); |
| 1401 |
|
/* get resolution, reporting */ |
| 1445 |
|
sprintf(vs, "%d", vn); |
| 1446 |
|
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
| 1447 |
|
/* check date on picture */ |
| 1448 |
< |
if (fdate(picfile) >= oct1date) |
| 1448 |
> |
pfdt = fdate(picfile); |
| 1449 |
> |
if (pfdt >= oct1date) |
| 1450 |
|
continue; |
| 1451 |
< |
/* build rpict command */ |
| 1451 |
> |
/* get raw file name */ |
| 1452 |
|
sprintf(rawfile, "%s_%s.raw", vval(PICTURE), vs); |
| 1453 |
< |
if (fdate(rawfile) >= oct1date) /* recover */ |
| 1454 |
< |
sprintf(combuf, "rpict%s%s -ro %s %s", |
| 1455 |
< |
rep, opts, rawfile, oct1name); |
| 1453 |
> |
rfdt = fdate(rawfile); |
| 1454 |
> |
if (touchonly) { /* update times only */ |
| 1455 |
> |
if (rfdt) { |
| 1456 |
> |
if (rfdt < oct1date) |
| 1457 |
> |
touch(rawfile); |
| 1458 |
> |
} else if (pfdt && pfdt < oct1date) |
| 1459 |
> |
touch(picfile); |
| 1460 |
> |
continue; |
| 1461 |
> |
} |
| 1462 |
> |
/* build rpict command */ |
| 1463 |
> |
if (rfdt >= oct1date) /* recover */ |
| 1464 |
> |
sprintf(combuf, "rpict%s%s%s -ro %s %s", |
| 1465 |
> |
rep, po, opts, rawfile, oct1name); |
| 1466 |
|
else { |
| 1467 |
|
if (overture) { /* run overture calculation */ |
| 1468 |
|
sprintf(combuf, |
| 1479 |
|
rmfile(overfile); |
| 1480 |
|
#endif |
| 1481 |
|
} |
| 1482 |
< |
sprintf(combuf, "rpict%s %s %s%s %s > %s", |
| 1483 |
< |
rep, vw, res, opts, |
| 1482 |
> |
sprintf(combuf, "rpict%s %s %s%s%s %s > %s", |
| 1483 |
> |
rep, vw, res, po, opts, |
| 1484 |
|
oct1name, rawfile); |
| 1485 |
|
} |
| 1486 |
|
if (runcom(combuf)) { /* run rpict */ |
| 1502 |
|
unlink(picfile); |
| 1503 |
|
exit(1); |
| 1504 |
|
} |
| 1505 |
< |
/* remove raw file */ |
| 1506 |
< |
rmfile(rawfile); |
| 1505 |
> |
/* remove/rename raw file */ |
| 1506 |
> |
if (vbool(RAWSAVE)) { |
| 1507 |
> |
sprintf(combuf, "%s_%s.rwp", vval(PICTURE), vs); |
| 1508 |
> |
mvfile(rawfile, combuf); |
| 1509 |
> |
} else |
| 1510 |
> |
rmfile(rawfile); |
| 1511 |
|
} |
| 1512 |
|
} |
| 1513 |
|
|
| 1514 |
|
|
| 1515 |
+ |
touch(fn) /* update a file */ |
| 1516 |
+ |
char *fn; |
| 1517 |
+ |
{ |
| 1518 |
+ |
if (!silent) |
| 1519 |
+ |
printf("\ttouch %s\n", fn); |
| 1520 |
+ |
if (noaction) |
| 1521 |
+ |
return(0); |
| 1522 |
+ |
#ifdef notused |
| 1523 |
+ |
if (access(fn, F_OK) == -1) /* create it */ |
| 1524 |
+ |
if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) |
| 1525 |
+ |
return(-1); |
| 1526 |
+ |
#endif |
| 1527 |
+ |
return(setfdate(fn, time((time_t *)NULL))); |
| 1528 |
+ |
} |
| 1529 |
+ |
|
| 1530 |
+ |
|
| 1531 |
|
runcom(cs) /* run command */ |
| 1532 |
|
char *cs; |
| 1533 |
|
{ |
| 1552 |
|
if (noaction) |
| 1553 |
|
return(0); |
| 1554 |
|
return(unlink(fn)); |
| 1555 |
+ |
} |
| 1556 |
+ |
|
| 1557 |
+ |
|
| 1558 |
+ |
mvfile(fold, fnew) /* move a file */ |
| 1559 |
+ |
char *fold, *fnew; |
| 1560 |
+ |
{ |
| 1561 |
+ |
if (!silent) |
| 1562 |
+ |
#ifdef MSDOS |
| 1563 |
+ |
printf("\trename %s %s\n", fold, fnew); |
| 1564 |
+ |
#else |
| 1565 |
+ |
printf("\tmv %s %s\n", fold, fnew); |
| 1566 |
+ |
#endif |
| 1567 |
+ |
if (noaction) |
| 1568 |
+ |
return(0); |
| 1569 |
+ |
return(rename(fold, fnew)); |
| 1570 |
|
} |
| 1571 |
|
|
| 1572 |
|
|