47 |
|
#define RENDER 17 /* rendering options */ |
48 |
|
#define REPORT 18 /* report frequency and errfile */ |
49 |
|
#define RESOLUTION 19 /* maximum picture resolution */ |
50 |
< |
#define SCENE 20 /* scene files */ |
51 |
< |
#define UP 21 /* view up (X, Y or Z) */ |
52 |
< |
#define VARIABILITY 22 /* level of light variability */ |
53 |
< |
#define VIEWS 23 /* view(s) for picture(s) */ |
54 |
< |
#define ZFILE 24 /* distance file root name */ |
55 |
< |
#define ZONE 25 /* simulation zone */ |
50 |
> |
#define RPICT 20 /* rpict parameters */ |
51 |
> |
#define RVU 21 /* rvu parameters */ |
52 |
> |
#define SCENE 22 /* scene files */ |
53 |
> |
#define UP 23 /* view up (X, Y or Z) */ |
54 |
> |
#define VARIABILITY 24 /* level of light variability */ |
55 |
> |
#define VIEWS 25 /* view(s) for picture(s) */ |
56 |
> |
#define ZFILE 26 /* distance file root name */ |
57 |
> |
#define ZONE 27 /* simulation zone */ |
58 |
|
/* total number of variables */ |
59 |
< |
int NVARS = 26; |
59 |
> |
int NVARS = 28; |
60 |
|
|
61 |
|
VARIABLE vv[] = { /* variable-value pairs */ |
62 |
|
{"AMBFILE", 3, 0, NULL, onevalue}, |
79 |
|
{"render", 3, 0, NULL, catvalues}, |
80 |
|
{"REPORT", 3, 0, NULL, onevalue}, |
81 |
|
{"RESOLUTION", 3, 0, NULL, onevalue}, |
82 |
+ |
{"rpict", 3, 0, NULL, catvalues}, |
83 |
+ |
{"rvu", 3, 0, NULL, catvalues}, |
84 |
|
{"scene", 3, 0, NULL, catvalues}, |
85 |
|
{"UP", 2, 0, NULL, onevalue}, |
86 |
|
{"VARIABILITY", 3, 0, NULL, qualvalue}, |
116 |
|
char *rvdevice = NULL; /* rvu output device */ |
117 |
|
char *viewselect = NULL; /* specific view only */ |
118 |
|
|
119 |
+ |
#define DEF_RPICT_PATH "rpict" /* default rpict path */ |
120 |
+ |
|
121 |
+ |
/* command paths */ |
122 |
+ |
char c_oconv[256] = "oconv"; |
123 |
+ |
char c_mkillum[256] = "mkillum"; |
124 |
+ |
char c_rvu[256] = "rvu"; |
125 |
+ |
char c_rpict[256] = DEF_RPICT_PATH; |
126 |
+ |
char c_rpiece[] = "rpiece"; |
127 |
+ |
char c_pfilt[256] = "pfilt"; |
128 |
+ |
|
129 |
|
int overture = 0; /* overture calculation needed */ |
130 |
|
|
131 |
|
int children_running = 0; /* set negative in children */ |
221 |
|
if (i >= argc) |
222 |
|
goto userr; |
223 |
|
rifname = argv[i]; |
210 |
– |
/* check command-line options */ |
211 |
– |
if ((nprocs > 1) & (viewselect != NULL)) |
212 |
– |
nprocs = 1; |
224 |
|
/* assign Radiance root file name */ |
225 |
|
rootname(radname, rifname); |
226 |
|
/* load variable values */ |
491 |
|
touch(vval(OCTREE)); |
492 |
|
else { /* build command */ |
493 |
|
if (vdef(MATERIAL)) |
494 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
495 |
< |
vval(MATERIAL), vval(SCENE), |
496 |
< |
vval(OCTREE)); |
494 |
> |
sprintf(combuf, "%s%s %s %s > %s", c_oconv, |
495 |
> |
ocopts, vval(MATERIAL), |
496 |
> |
vval(SCENE), vval(OCTREE)); |
497 |
|
else |
498 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
498 |
> |
sprintf(combuf, "%s%s %s > %s", c_oconv, ocopts, |
499 |
|
vval(SCENE), vval(OCTREE)); |
500 |
|
|
501 |
|
if (runcom(combuf)) { /* run it */ |
521 |
|
touch(oct0name); |
522 |
|
else { /* build command */ |
523 |
|
if (octreedate) |
524 |
< |
sprintf(combuf, "oconv%s -i %s %s > %s", ocopts, |
525 |
< |
vval(OCTREE), vval(ILLUM), oct0name); |
524 |
> |
sprintf(combuf, "%s%s -i %s %s > %s", c_oconv, |
525 |
> |
ocopts, vval(OCTREE), |
526 |
> |
vval(ILLUM), oct0name); |
527 |
|
else if (vdef(MATERIAL)) |
528 |
< |
sprintf(combuf, "oconv%s %s %s > %s", ocopts, |
529 |
< |
vval(MATERIAL), vval(ILLUM), oct0name); |
518 |
< |
else |
519 |
< |
sprintf(combuf, "oconv%s %s > %s", ocopts, |
528 |
> |
sprintf(combuf, "%s%s %s %s > %s", c_oconv, |
529 |
> |
ocopts, vval(MATERIAL), |
530 |
|
vval(ILLUM), oct0name); |
531 |
+ |
else |
532 |
+ |
sprintf(combuf, "%s%s %s > %s", c_oconv, |
533 |
+ |
ocopts, vval(ILLUM), oct0name); |
534 |
|
if (runcom(combuf)) { /* run it */ |
535 |
|
fprintf(stderr, |
536 |
|
"%s: error generating octree\n\t%s removed\n", |
550 |
|
else { |
551 |
|
mkillumopts(mkopts); /* build mkillum command */ |
552 |
|
mktemp(illumtmp); |
553 |
< |
sprintf(combuf, "mkillum%s %s \"<\" %s > %s", mkopts, |
553 |
> |
sprintf(combuf, "%s%s %s \"<\" %s > %s", c_mkillum, mkopts, |
554 |
|
oct0name, vval(ILLUM), illumtmp); |
555 |
|
if (runcom(combuf)) { /* run it */ |
556 |
< |
fprintf(stderr, "%s: error running mkillum\n", |
557 |
< |
progname); |
556 |
> |
fprintf(stderr, "%s: error running %s\n", |
557 |
> |
progname, c_mkillum); |
558 |
|
unlink(illumtmp); |
559 |
|
quit(1); |
560 |
|
} |
561 |
|
/* make octree1 (frozen) */ |
562 |
|
if (octreedate) |
563 |
< |
sprintf(combuf, "oconv%s -f -i %s %s > %s", ocopts, |
564 |
< |
vval(OCTREE), illumtmp, oct1name); |
563 |
> |
sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv, |
564 |
> |
ocopts, vval(OCTREE), illumtmp, oct1name); |
565 |
|
else if (vdef(MATERIAL)) |
566 |
< |
sprintf(combuf, "oconv%s -f %s %s > %s", ocopts, |
567 |
< |
vval(MATERIAL), illumtmp, oct1name); |
566 |
> |
sprintf(combuf, "%s%s -f %s %s > %s", c_oconv, |
567 |
> |
ocopts, vval(MATERIAL), illumtmp, oct1name); |
568 |
|
else |
569 |
< |
sprintf(combuf, "oconv%s -f %s > %s", ocopts, |
569 |
> |
sprintf(combuf, "%s%s -f %s > %s", c_oconv, ocopts, |
570 |
|
illumtmp, oct1name); |
571 |
|
if (runcom(combuf)) { /* run it */ |
572 |
|
fprintf(stderr, |
585 |
|
|
586 |
|
|
587 |
|
static char * |
588 |
< |
addarg( /* add argument and advance pointer */ |
588 |
> |
addarg( /* append argument and advance pointer */ |
589 |
|
register char *op, |
590 |
|
register char *arg |
591 |
|
) |
592 |
|
{ |
593 |
+ |
while (*op) |
594 |
+ |
op++; |
595 |
|
*op = ' '; |
596 |
|
while ( (*++op = *arg++) ) |
597 |
|
; |
608 |
|
|
609 |
|
*oo = '\0'; |
610 |
|
if (vdef(OCONV)) |
611 |
< |
addarg(oo, vval(OCONV)); |
611 |
> |
if (vval(OCONV)[0] != '-') { |
612 |
> |
atos(c_oconv, sizeof(c_oconv), vval(OCONV)); |
613 |
> |
oo = addarg(oo, sskip2(vval(OCONV), 1)); |
614 |
> |
} else |
615 |
> |
oo = addarg(oo, vval(OCONV)); |
616 |
|
} |
617 |
|
|
618 |
|
|
623 |
|
{ |
624 |
|
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
625 |
|
|
626 |
< |
if (nprocs > 1) { |
626 |
> |
if (nprocs > 1) |
627 |
|
sprintf(mo, " -n %d", nprocs); |
628 |
< |
while (*mo) |
610 |
< |
mo++; |
611 |
< |
} else |
628 |
> |
else |
629 |
|
*mo = '\0'; |
630 |
|
if (vdef(MKILLUM)) |
631 |
< |
addarg(mo, vval(MKILLUM)); |
631 |
> |
if (vval(MKILLUM)[0] != '-') { |
632 |
> |
atos(c_mkillum, sizeof(c_mkillum), vval(MKILLUM)); |
633 |
> |
mo = addarg(mo, sskip2(vval(MKILLUM), 1)); |
634 |
> |
} else |
635 |
> |
mo = addarg(mo, vval(MKILLUM)); |
636 |
|
} |
637 |
|
|
638 |
|
|
688 |
|
hiqopts(op, po); |
689 |
|
break; |
690 |
|
} |
691 |
+ |
if (vdef(RENDER)) |
692 |
+ |
op = addarg(op, vval(RENDER)); |
693 |
+ |
if (rvdevice != NULL) { |
694 |
+ |
if (vdef(RVU)) |
695 |
+ |
if (vval(RVU)[0] != '-') { |
696 |
+ |
atos(c_rvu, sizeof(c_rvu), vval(RVU)); |
697 |
+ |
po = addarg(po, sskip2(vval(RVU), 1)); |
698 |
+ |
} else |
699 |
+ |
po = addarg(po, vval(RVU)); |
700 |
+ |
} else { |
701 |
+ |
if (vdef(RPICT)) |
702 |
+ |
if (vval(RPICT)[0] != '-') { |
703 |
+ |
atos(c_rpict, sizeof(c_rpict), vval(RPICT)); |
704 |
+ |
po = addarg(po, sskip2(vval(RPICT), 1)); |
705 |
+ |
} else |
706 |
+ |
po = addarg(po, vval(RPICT)); |
707 |
+ |
} |
708 |
|
} |
709 |
|
|
710 |
|
|
773 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
774 |
|
op += strlen(op); |
775 |
|
op = addarg(op, "-lr 6 -lw .01"); |
738 |
– |
if (vdef(RENDER)) |
739 |
– |
op = addarg(op, vval(RENDER)); |
776 |
|
} |
777 |
|
|
778 |
|
|
823 |
|
} |
824 |
|
po = addarg(po, "-pt .08"); |
825 |
|
if (vbool(PENUMBRAS)) |
826 |
< |
op = addarg(op, "-ds .2 -dj .5"); |
826 |
> |
op = addarg(op, "-ds .2 -dj .9"); |
827 |
|
else |
828 |
|
op = addarg(op, "-ds .3"); |
829 |
|
op = addarg(op, "-dt .1 -dc .5 -dr 1 -sj .7 -st .1"); |
851 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
852 |
|
op += strlen(op); |
853 |
|
op = addarg(op, "-lr 8 -lw .002"); |
818 |
– |
if (vdef(RENDER)) |
819 |
– |
op = addarg(op, vval(RENDER)); |
854 |
|
} |
855 |
|
|
856 |
|
|
901 |
|
} |
902 |
|
po = addarg(po, "-pt .04"); |
903 |
|
if (vbool(PENUMBRAS)) |
904 |
< |
op = addarg(op, "-ds .1 -dj .65"); |
904 |
> |
op = addarg(op, "-ds .1 -dj .9"); |
905 |
|
else |
906 |
|
op = addarg(op, "-ds .2"); |
907 |
|
op = addarg(op, "-dt .05 -dc .75 -dr 3 -sj 1 -st .01"); |
927 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
928 |
|
op += strlen(op); |
929 |
|
op = addarg(op, "-lr 12 -lw .0005"); |
896 |
– |
if (vdef(RENDER)) |
897 |
– |
op = addarg(op, vval(RENDER)); |
930 |
|
} |
931 |
|
|
932 |
|
|
982 |
|
break; |
983 |
|
} |
984 |
|
if (vdef(PFILT)) |
985 |
< |
po = addarg(po, vval(PFILT)); |
985 |
> |
if (vval(PFILT)[0] != '-') { |
986 |
> |
atos(c_pfilt, sizeof(c_pfilt), vval(PFILT)); |
987 |
> |
po = addarg(po, sskip2(vval(PFILT), 1)); |
988 |
> |
} else |
989 |
> |
po = addarg(po, vval(PFILT)); |
990 |
|
} |
991 |
|
|
992 |
|
|
1048 |
|
} else if (*vs == 'z') { |
1049 |
|
zpos = -1; vs++; |
1050 |
|
} |
1051 |
< |
viewtype = 'v'; |
1052 |
< |
if((*vs == 'v') | (*vs == 'l') | (*vs == 'a') | (*vs == 'h') | (*vs == 'c')) |
1051 |
> |
switch (*vs) { |
1052 |
> |
case VT_PER: |
1053 |
> |
case VT_PAR: |
1054 |
> |
case VT_ANG: |
1055 |
> |
case VT_HEM: |
1056 |
> |
case VT_PLS: |
1057 |
> |
case VT_CYL: |
1058 |
|
viewtype = *vs++; |
1059 |
+ |
break; |
1060 |
+ |
default: |
1061 |
+ |
viewtype = VT_PER; |
1062 |
+ |
break; |
1063 |
+ |
} |
1064 |
|
cp = viewopts; |
1065 |
|
if ((!*vs || isspace(*vs)) && (xpos|ypos|zpos)) { /* got one! */ |
1066 |
|
*cp++ = '-'; *cp++ = 'v'; *cp++ = 't'; *cp++ = viewtype; |
1102 |
|
} |
1103 |
|
cp = addarg(cp, vup[upax+3]); |
1104 |
|
switch (viewtype) { |
1105 |
< |
case 'v': |
1105 |
> |
case VT_PER: |
1106 |
|
cp = addarg(cp, "-vh 45 -vv 45"); |
1107 |
|
break; |
1108 |
< |
case 'l': |
1108 |
> |
case VT_PAR: |
1109 |
|
d = sqrt(dim[0]*dim[0]+dim[1]*dim[1]+dim[2]*dim[2]); |
1110 |
|
sprintf(cp, " -vh %.2g -vv %.2g", d, d); |
1111 |
|
cp += strlen(cp); |
1112 |
|
break; |
1113 |
< |
case 'a': |
1114 |
< |
case 'h': |
1113 |
> |
case VT_ANG: |
1114 |
> |
case VT_HEM: |
1115 |
> |
case VT_PLS: |
1116 |
|
cp = addarg(cp, "-vh 180 -vv 180"); |
1117 |
|
break; |
1118 |
< |
case 'c': |
1118 |
> |
case VT_CYL: |
1119 |
|
cp = addarg(cp, "-vh 180 -vv 90"); |
1120 |
|
break; |
1121 |
|
} |
1123 |
|
while (!isspace(*vs)) /* else skip id */ |
1124 |
|
if (!*vs++) |
1125 |
|
return(NULL); |
1126 |
< |
if (upax) { /* specify up vector */ |
1126 |
> |
if (upax) { /* prepend up vector */ |
1127 |
|
strcpy(cp, vup[upax+3]); |
1128 |
|
cp += strlen(cp); |
1129 |
|
} |
1152 |
|
if (viewselect != NULL) { /* command-line selected */ |
1153 |
|
if (n) /* only do one */ |
1154 |
|
return(NULL); |
1155 |
+ |
|
1156 |
+ |
if (isint(viewselect)) { /* view number? */ |
1157 |
+ |
n = atoi(viewselect)-1; |
1158 |
+ |
goto numview; |
1159 |
+ |
} |
1160 |
|
if (viewselect[0] == '-') { /* already specified */ |
1161 |
< |
if (vn != NULL) *vn = '\0'; |
1161 |
> |
if (vn != NULL) |
1162 |
> |
strcpy(vn, "0"); |
1163 |
|
return(viewselect); |
1164 |
|
} |
1165 |
|
if (vn != NULL) { |
1168 |
|
; |
1169 |
|
*vn = '\0'; |
1170 |
|
} |
1118 |
– |
/* view number? */ |
1119 |
– |
if (isint(viewselect)) |
1120 |
– |
return(specview(nvalue(VIEWS, atoi(viewselect)-1))); |
1171 |
|
/* check list */ |
1172 |
|
while ((mv = nvalue(VIEWS, n++)) != NULL) |
1173 |
|
if (matchword(viewselect, mv)) |
1174 |
|
return(specview(mv)); |
1175 |
+ |
|
1176 |
|
return(specview(viewselect)); /* standard view? */ |
1177 |
|
} |
1178 |
+ |
numview: |
1179 |
|
mv = nvalue(VIEWS, n); /* use view n */ |
1180 |
< |
if ((vn != NULL) & (mv != NULL)) { |
1181 |
< |
register char *mv2 = mv; |
1182 |
< |
if (*mv2 != '-') |
1180 |
> |
if ((vn != NULL) & (mv != NULL)) |
1181 |
> |
if (*mv != '-') { |
1182 |
> |
register char *mv2 = mv; |
1183 |
|
while (*mv2 && !isspace(*mv2)) |
1184 |
|
*vn++ = *mv2++; |
1185 |
< |
*vn = '\0'; |
1186 |
< |
} |
1185 |
> |
*vn = '\0'; |
1186 |
> |
} else |
1187 |
> |
sprintf(vn, "%d", n+1); |
1188 |
> |
|
1189 |
|
return(specview(mv)); |
1190 |
|
} |
1191 |
|
|
1199 |
|
VIEW vwr; |
1200 |
|
char buf[128]; |
1201 |
|
register char *cp; |
1202 |
+ |
#ifdef _WIN32 |
1203 |
+ |
/* XXX Should we allow something like this for all platforms? */ |
1204 |
+ |
/* XXX Or is it still required at all? */ |
1205 |
+ |
again: |
1206 |
+ |
#endif |
1207 |
|
if (vopts == NULL) |
1208 |
|
return(-1); |
1209 |
|
#ifdef _WIN32 |
1239 |
|
return; |
1240 |
|
if (sayview) |
1241 |
|
myprintview(vw, stdout); |
1242 |
< |
sprintf(combuf, "rvu %s%s%s -R %s ", vw, po, opts, rifname); |
1242 |
> |
sprintf(combuf, "%s %s%s%s -R %s ", c_rvu, vw, opts, po, rifname); |
1243 |
> |
if (nprocs > 1) |
1244 |
> |
sprintf(combuf+strlen(combuf), "-n %d ", nprocs); |
1245 |
|
if (rvdevice != NULL) |
1246 |
|
sprintf(combuf+strlen(combuf), "-o %s ", rvdevice); |
1247 |
|
if (vdef(EXPOSURE)) |
1248 |
|
sprintf(combuf+strlen(combuf), "-pe %s ", vval(EXPOSURE)); |
1249 |
|
strcat(combuf, oct1name); |
1250 |
|
if (runcom(combuf)) { /* run it */ |
1251 |
< |
fprintf(stderr, "%s: error running rvu\n", progname); |
1251 |
> |
fprintf(stderr, "%s: error running %s\n", progname, c_rvu); |
1252 |
|
quit(1); |
1253 |
|
} |
1254 |
|
} |
1260 |
|
char *po |
1261 |
|
) |
1262 |
|
{ |
1263 |
< |
char combuf[PATH_MAX]; |
1263 |
> |
#define do_rpiece (sfile[0]!='\0') |
1264 |
> |
char combuf[4*PATH_MAX+512]; |
1265 |
|
char rawfile[PATH_MAX], picfile[PATH_MAX]; |
1266 |
|
char zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32]; |
1267 |
< |
char rppopt[128], *pfile = NULL; |
1267 |
> |
char rppopt[128], sfile[64], *pfile = NULL; |
1268 |
|
char pfopts[128]; |
1269 |
|
char vs[32], *vw; |
1270 |
|
int vn, mult; |
1311 |
|
badvalue(REPORT); |
1312 |
|
} |
1313 |
|
/* set up parallel rendering */ |
1314 |
< |
if ((nprocs > 1) & (!vdef(ZFILE))) { |
1315 |
< |
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1316 |
< |
pfile = rppopt+9; |
1317 |
< |
if (mktemp(pfile) == NULL) |
1314 |
> |
sfile[0] = '\0'; |
1315 |
> |
if ((nprocs > 1) & !touchonly & !vdef(ZFILE) && |
1316 |
> |
getview(0, vs) != NULL) { |
1317 |
> |
if (!strcmp(c_rpict, DEF_RPICT_PATH) && |
1318 |
> |
getview(1, NULL) == NULL) { |
1319 |
> |
sprintf(sfile, "rpsync_%s.txt", vs); |
1320 |
> |
strcpy(rppopt, "-PP pfXXXXXX"); |
1321 |
> |
} else { |
1322 |
> |
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1323 |
> |
} |
1324 |
> |
pfile = rppopt + strlen(rppopt) - 8; |
1325 |
> |
if (mktemp(pfile) == NULL) { |
1326 |
> |
if (do_rpiece) { |
1327 |
> |
fprintf(stderr, "%s: cannot create\n", pfile); |
1328 |
> |
quit(1); |
1329 |
> |
} |
1330 |
|
pfile = NULL; |
1331 |
+ |
} |
1332 |
|
} |
1333 |
|
vn = 0; /* do each view */ |
1334 |
|
while ((vw = getview(vn++, vs)) != NULL) { |
1335 |
|
if (sayview) |
1336 |
|
myprintview(vw, stdout); |
1337 |
< |
if (!vs[0]) |
1263 |
< |
sprintf(vs, "%d", vn); |
1264 |
< |
sprintf(picfile, "%s_%s.pic", vval(PICTURE), vs); |
1337 |
> |
sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs); |
1338 |
|
if (vdef(ZFILE)) |
1339 |
|
sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); |
1340 |
|
else |
1355 |
|
touch(picfile); |
1356 |
|
continue; |
1357 |
|
} |
1358 |
< |
if (next_process()) { /* parallel running? */ |
1358 |
> |
/* parallel running? */ |
1359 |
> |
if (do_rpiece) { |
1360 |
> |
if (rfdt < oct1date || !fdate(sfile)) { |
1361 |
> |
rfdt = 0; /* start fresh */ |
1362 |
> |
if ((fp = fopen(sfile, "w")) == NULL) { |
1363 |
> |
fprintf(stderr, "%s: cannot create\n", |
1364 |
> |
sfile); |
1365 |
> |
quit(1); |
1366 |
> |
} |
1367 |
> |
fprintf(fp, "%d %d\n", 8+nprocs/3, 8+nprocs/3); |
1368 |
> |
fclose(fp); |
1369 |
> |
} |
1370 |
> |
} else if (next_process()) { |
1371 |
|
if (pfile != NULL) |
1372 |
< |
sleep(20); |
1372 |
> |
sleep(10); |
1373 |
|
continue; |
1374 |
< |
} |
1374 |
> |
} else if (!inchild()) |
1375 |
> |
pfile = NULL; |
1376 |
|
/* XXX Remember to call finish_process() */ |
1377 |
|
/* build rpict command */ |
1378 |
< |
if (rfdt >= oct1date) { /* recover */ |
1379 |
< |
sprintf(combuf, "rpict%s%s%s%s -ro %s %s", |
1380 |
< |
rep, po, opts, zopt, rawfile, oct1name); |
1381 |
< |
if (runcom(combuf)) /* run rpict */ |
1378 |
> |
if (rfdt >= oct1date) { /* already in progress */ |
1379 |
> |
if (do_rpiece) { |
1380 |
> |
sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s", |
1381 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1382 |
> |
res, opts, po, rawfile, oct1name); |
1383 |
> |
while (children_running < nprocs-1 && |
1384 |
> |
next_process()) { |
1385 |
> |
sleep(10); |
1386 |
> |
combuf[strlen(c_rpiece)+2] = 'F'; |
1387 |
> |
} |
1388 |
> |
} else |
1389 |
> |
sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, |
1390 |
> |
rep, opts, po, zopt, rawfile, oct1name); |
1391 |
> |
if (runcom(combuf)) /* run rpict/rpiece */ |
1392 |
|
goto rperror; |
1393 |
|
} else { |
1394 |
|
if (overture) { /* run overture calculation */ |
1395 |
|
sprintf(combuf, |
1396 |
< |
"rpict%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1397 |
< |
rep, vw, opts, |
1396 |
> |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1397 |
> |
c_rpict, rep, vw, opts, |
1398 |
|
oct1name, overfile); |
1399 |
|
if (runcom(combuf)) { |
1400 |
|
fprintf(stderr, |
1406 |
|
rmfile(overfile); |
1407 |
|
#endif |
1408 |
|
} |
1409 |
< |
sprintf(combuf, "rpict%s %s %s%s%s%s %s > %s", |
1410 |
< |
rep, vw, res, po, opts, |
1411 |
< |
zopt, oct1name, rawfile); |
1412 |
< |
if (pfile != NULL && inchild()) { |
1413 |
< |
/* rpict persistent mode */ |
1409 |
> |
if (do_rpiece) { |
1410 |
> |
sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", |
1411 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1412 |
> |
res, opts, po, rawfile, oct1name); |
1413 |
> |
while (children_running < nprocs-1 && |
1414 |
> |
next_process()) |
1415 |
> |
sleep(10); |
1416 |
> |
} else { |
1417 |
> |
sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", |
1418 |
> |
c_rpict, rep, vw, res, opts, po, |
1419 |
> |
zopt, oct1name, rawfile); |
1420 |
> |
} |
1421 |
> |
if ((pfile != NULL) & !do_rpiece) { |
1422 |
|
if (!silent) |
1423 |
|
printf("\t%s\n", combuf); |
1320 |
– |
sprintf(combuf, "rpict%s %s %s%s%s %s > %s", |
1321 |
– |
rep, rppopt, res, po, opts, |
1322 |
– |
oct1name, rawfile); |
1424 |
|
fflush(stdout); |
1425 |
+ |
sprintf(combuf, "%s%s %s %s%s%s %s > %s", |
1426 |
+ |
c_rpict, rep, rppopt, res, |
1427 |
+ |
opts, po, oct1name, rawfile); |
1428 |
|
fp = popen(combuf, "w"); |
1429 |
|
if (fp == NULL) |
1430 |
|
goto rperror; |
1431 |
|
myprintview(vw, fp); |
1432 |
|
if (pclose(fp)) |
1433 |
|
goto rperror; |
1434 |
< |
} else { /* rpict normal mode */ |
1435 |
< |
if (runcom(combuf)) |
1332 |
< |
goto rperror; |
1333 |
< |
} |
1434 |
> |
} else if (runcom(combuf)) |
1435 |
> |
goto rperror; |
1436 |
|
} |
1437 |
+ |
if (do_rpiece) { /* need to finish raw, first */ |
1438 |
+ |
finish_process(); |
1439 |
+ |
wait_process(1); |
1440 |
+ |
/* XXX should check sync file to see if really done? */ |
1441 |
+ |
} |
1442 |
|
if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { |
1443 |
|
/* build pfilt command */ |
1444 |
|
if (mult > 1) |
1445 |
< |
sprintf(combuf, "pfilt%s -x /%d -y /%d %s > %s", |
1446 |
< |
pfopts, mult, mult, rawfile, picfile); |
1445 |
> |
sprintf(combuf, "%s%s -x /%d -y /%d %s > %s", |
1446 |
> |
c_pfilt, pfopts, mult, mult, |
1447 |
> |
rawfile, picfile); |
1448 |
|
else |
1449 |
< |
sprintf(combuf, "pfilt%s %s > %s", pfopts, |
1450 |
< |
rawfile, picfile); |
1449 |
> |
sprintf(combuf, "%s%s %s > %s", c_pfilt, |
1450 |
> |
pfopts, rawfile, picfile); |
1451 |
|
if (runcom(combuf)) { /* run pfilt */ |
1452 |
|
fprintf(stderr, |
1453 |
|
"%s: error filtering view %s\n\t%s removed\n", |
1458 |
|
} |
1459 |
|
/* remove/rename raw file */ |
1460 |
|
if (vdef(RAWFILE)) { |
1461 |
< |
sprintf(combuf, "%s_%s.pic", vval(RAWFILE), vs); |
1461 |
> |
sprintf(combuf, "%s_%s.hdr", vval(RAWFILE), vs); |
1462 |
|
mvfile(rawfile, combuf); |
1463 |
|
} else |
1464 |
|
rmfile(rawfile); |
1465 |
< |
finish_process(); /* exit if child */ |
1465 |
> |
if (do_rpiece) /* done with sync file */ |
1466 |
> |
rmfile(sfile); |
1467 |
> |
else |
1468 |
> |
finish_process(); /* exit if child */ |
1469 |
|
} |
1470 |
|
wait_process(1); /* wait for children to finish */ |
1471 |
< |
if (pfile != NULL) { /* clean up rpict persistent mode */ |
1472 |
< |
int pid; |
1471 |
> |
if (pfile != NULL) { /* clean up persistent rpict */ |
1472 |
> |
RT_PID pid; |
1473 |
|
fp = fopen(pfile, "r"); |
1474 |
|
if (fp != NULL) { |
1475 |
|
if (fscanf(fp, "%*s %d", &pid) != 1 || |
1482 |
|
rperror: |
1483 |
|
fprintf(stderr, "%s: error rendering view %s\n", progname, vs); |
1484 |
|
quit(1); |
1485 |
+ |
#undef do_rpiece |
1486 |
|
} |
1487 |
|
|
1488 |
|
|
1495 |
|
printf("\ttouch %s\n", fn); |
1496 |
|
if (!nprocs) |
1497 |
|
return(0); |
1386 |
– |
#ifdef notused |
1387 |
– |
if (access(fn, F_OK) == -1) /* create it */ |
1388 |
– |
if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) |
1389 |
– |
return(-1); |
1390 |
– |
#endif |
1498 |
|
return(setfdate(fn, time((time_t *)NULL))); |
1499 |
|
} |
1500 |
|
|
1508 |
|
printf("\t%s\n", cs); |
1509 |
|
if (!nprocs) |
1510 |
|
return(0); |
1511 |
< |
fflush(stdout); /* flush output and pass to shell */ |
1511 |
> |
fflush(NULL); /* flush output and pass to shell */ |
1512 |
|
return(system(cs)); |
1513 |
|
} |
1514 |
|
|
1544 |
|
static int |
1545 |
|
next_process(void) /* fork the next process (max. nprocs) */ |
1546 |
|
{ |
1547 |
< |
int child_pid; |
1547 |
> |
RT_PID child_pid; |
1548 |
|
|
1549 |
|
if (nprocs <= 1) |
1550 |
|
return(0); /* it's us or no one */ |
1555 |
|
} |
1556 |
|
if (children_running >= nprocs) |
1557 |
|
wait_process(0); /* wait for someone to finish */ |
1558 |
< |
fflush(stdout); |
1558 |
> |
fflush(NULL); /* flush output */ |
1559 |
|
child_pid = fork(); /* split process */ |
1560 |
|
if (child_pid == 0) { /* we're the child */ |
1561 |
|
children_running = -1; |
1574 |
|
int all |
1575 |
|
) |
1576 |
|
{ |
1577 |
< |
int ourstatus = 0; |
1578 |
< |
int pid, status; |
1577 |
> |
int ourstatus = 0, status; |
1578 |
> |
RT_PID pid; |
1579 |
|
|
1580 |
|
if (all) |
1581 |
|
all = children_running; |
1612 |
|
} |
1613 |
|
int |
1614 |
|
kill(pid, sig) /* win|unix_process.c should also wait and kill */ |
1615 |
< |
int pid, sig; |
1615 |
> |
RT_PID pid; |
1616 |
> |
int sig; |
1617 |
|
{ |
1618 |
|
return 0; |
1619 |
|
} |