264 |
|
|
265 |
|
static void |
266 |
|
rootname( /* remove tail from end of fn */ |
267 |
< |
register char *rn, |
268 |
< |
register char *fn |
267 |
> |
char *rn, |
268 |
> |
char *fn |
269 |
|
) |
270 |
|
{ |
271 |
|
char *tp, *dp; |
282 |
|
|
283 |
|
static time_t |
284 |
|
checklast( /* check files and find most recent */ |
285 |
< |
register char *fnames |
285 |
> |
char *fnames |
286 |
|
) |
287 |
|
{ |
288 |
|
char thisfile[PATH_MAX]; |
312 |
|
int pred |
313 |
|
) |
314 |
|
{ |
315 |
< |
register char *cp; |
316 |
< |
register int n; |
315 |
> |
char *cp; |
316 |
> |
int n; |
317 |
|
int suffix; |
318 |
|
|
319 |
|
n = 0; cp = orig; suffix = -1; /* suffix position, length */ |
378 |
|
double min[3], max[3]; |
379 |
|
char buf[1024]; |
380 |
|
FILE *fp; |
381 |
< |
register int i; |
381 |
> |
int i; |
382 |
|
|
383 |
|
if (osiz <= FTINY) { |
384 |
|
if (!nprocs && fdate(oct1name) < |
558 |
|
unlink(illumtmp); |
559 |
|
quit(1); |
560 |
|
} |
561 |
+ |
rmfile(oct0name); |
562 |
|
/* make octree1 (frozen) */ |
563 |
|
if (octreedate) |
564 |
|
sprintf(combuf, "%s%s -f -i %s %s > %s", c_oconv, |
587 |
|
|
588 |
|
static char * |
589 |
|
addarg( /* append argument and advance pointer */ |
590 |
< |
register char *op, |
591 |
< |
register char *arg |
590 |
> |
char *op, |
591 |
> |
char *arg |
592 |
|
) |
593 |
|
{ |
594 |
|
while (*op) |
602 |
|
|
603 |
|
static void |
604 |
|
oconvopts( /* get oconv options */ |
605 |
< |
register char *oo |
605 |
> |
char *oo |
606 |
|
) |
607 |
|
{ |
608 |
|
/* BEWARE: This may be called via setdefaults(), so no assumptions */ |
711 |
|
|
712 |
|
static void |
713 |
|
lowqopts( /* low quality rendering options */ |
714 |
< |
register char *op, |
714 |
> |
char *op, |
715 |
|
char *po |
716 |
|
) |
717 |
|
{ |
773 |
|
d = ambval(); |
774 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
775 |
|
op += strlen(op); |
776 |
< |
op = addarg(op, "-lr 6 -lw .01"); |
776 |
> |
op = addarg(op, "-lr 6 -lw .003"); |
777 |
|
} |
778 |
|
|
779 |
|
|
780 |
|
static void |
781 |
|
medqopts( /* medium quality rendering options */ |
782 |
< |
register char *op, |
782 |
> |
char *op, |
783 |
|
char *po |
784 |
|
) |
785 |
|
{ |
827 |
|
op = addarg(op, "-ds .2 -dj .9"); |
828 |
|
else |
829 |
|
op = addarg(op, "-ds .3"); |
830 |
< |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss .7 -st .1"); |
830 |
> |
op = addarg(op, "-dt .1 -dc .5 -dr 1 -ss 1 -st .1"); |
831 |
|
if ( (overture = vint(INDIRECT)) ) { |
832 |
|
sprintf(op, " -ab %d", overture); |
833 |
|
op += strlen(op); |
851 |
|
d = ambval(); |
852 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
853 |
|
op += strlen(op); |
854 |
< |
op = addarg(op, "-lr 8 -lw .002"); |
854 |
> |
op = addarg(op, "-lr 8 -lw 1e-4"); |
855 |
|
} |
856 |
|
|
857 |
|
|
858 |
|
static void |
859 |
|
hiqopts( /* high quality rendering options */ |
860 |
< |
register char *op, |
860 |
> |
char *op, |
861 |
|
char *po |
862 |
|
) |
863 |
|
{ |
905 |
|
op = addarg(op, "-ds .1 -dj .9"); |
906 |
|
else |
907 |
|
op = addarg(op, "-ds .2"); |
908 |
< |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 1 -st .01"); |
908 |
> |
op = addarg(op, "-dt .05 -dc .75 -dr 3 -ss 16 -st .01"); |
909 |
|
sprintf(op, " -ab %d", overture=vint(INDIRECT)+1); |
910 |
|
op += strlen(op); |
911 |
|
if (vdef(AMBFILE)) { |
927 |
|
d = ambval(); |
928 |
|
sprintf(op, " -av %.2g %.2g %.2g", d, d, d); |
929 |
|
op += strlen(op); |
930 |
< |
op = addarg(op, "-lr 12 -lw .0005"); |
930 |
> |
op = addarg(op, "-lr 12 -lw 1e-5"); |
931 |
|
} |
932 |
|
|
933 |
|
|
934 |
+ |
#ifdef _WIN32 |
935 |
|
static void |
936 |
+ |
setenv( /* set an environment variable */ |
937 |
+ |
char *vname, |
938 |
+ |
char *value |
939 |
+ |
) |
940 |
+ |
{ |
941 |
+ |
char *evp; |
942 |
+ |
|
943 |
+ |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
944 |
+ |
if (evp == NULL) |
945 |
+ |
syserr(progname); |
946 |
+ |
sprintf(evp, "%s=%s", vname, value); |
947 |
+ |
if (putenv(evp) != 0) { |
948 |
+ |
fprintf(stderr, "%s: out of environment space\n", progname); |
949 |
+ |
quit(1); |
950 |
+ |
} |
951 |
+ |
if (!silent) |
952 |
+ |
printf("set %s\n", evp); |
953 |
+ |
} |
954 |
+ |
#endif |
955 |
+ |
|
956 |
+ |
|
957 |
+ |
static void |
958 |
|
xferopts( /* transfer options if indicated */ |
959 |
|
char *ro |
960 |
|
) |
961 |
|
{ |
962 |
|
int fd, n; |
963 |
< |
register char *cp; |
963 |
> |
char *cp; |
964 |
|
|
965 |
|
n = strlen(ro); |
966 |
|
if (n < 2) |
989 |
|
|
990 |
|
static void |
991 |
|
pfiltopts( /* get pfilt options */ |
992 |
< |
register char *po |
992 |
> |
char *po |
993 |
|
) |
994 |
|
{ |
995 |
|
*po = '\0'; |
1016 |
|
|
1017 |
|
static int |
1018 |
|
matchword( /* match white-delimited words */ |
1019 |
< |
register char *s1, |
1020 |
< |
register char *s2 |
1019 |
> |
char *s1, |
1020 |
> |
char *s2 |
1021 |
|
) |
1022 |
|
{ |
1023 |
|
while (isspace(*s1)) s1++; |
1031 |
|
|
1032 |
|
static char * |
1033 |
|
specview( /* get proper view spec from vs */ |
1034 |
< |
register char *vs |
1034 |
> |
char *vs |
1035 |
|
) |
1036 |
|
{ |
1037 |
|
static char vup[7][12] = {"-vu 0 0 -1","-vu 0 -1 0","-vu -1 0 0", |
1038 |
|
"-vu 0 0 1", "-vu 1 0 0","-vu 0 1 0","-vu 0 0 1"}; |
1039 |
|
static char viewopts[128]; |
1040 |
< |
register char *cp; |
1040 |
> |
char *cp; |
1041 |
|
int xpos, ypos, zpos, viewtype, upax; |
1042 |
< |
register int i; |
1042 |
> |
int i; |
1043 |
|
double cent[3], dim[3], mult, d; |
1044 |
|
|
1045 |
|
if (vs == NULL || *vs == '-') |
1171 |
|
char *vn /* returned view name */ |
1172 |
|
) |
1173 |
|
{ |
1174 |
< |
register char *mv; |
1174 |
> |
char *mv; |
1175 |
|
|
1176 |
|
if (viewselect != NULL) { /* command-line selected */ |
1177 |
|
if (n) /* only do one */ |
1203 |
|
mv = nvalue(VIEWS, n); /* use view n */ |
1204 |
|
if ((vn != NULL) & (mv != NULL)) |
1205 |
|
if (*mv != '-') { |
1206 |
< |
register char *mv2 = mv; |
1206 |
> |
char *mv2 = mv; |
1207 |
|
while (*mv2 && !isspace(*mv2)) |
1208 |
|
*vn++ = *mv2++; |
1209 |
|
*vn = '\0'; |
1216 |
|
|
1217 |
|
static int |
1218 |
|
myprintview( /* print out selected view */ |
1219 |
< |
register char *vopts, |
1219 |
> |
char *vopts, |
1220 |
|
FILE *fp |
1221 |
|
) |
1222 |
|
{ |
1223 |
|
VIEW vwr; |
1224 |
|
char buf[128]; |
1225 |
< |
register char *cp; |
1225 |
> |
char *cp; |
1226 |
|
#ifdef _WIN32 |
1227 |
|
/* XXX Should we allow something like this for all platforms? */ |
1228 |
|
/* XXX Or is it still required at all? */ |
1278 |
|
} |
1279 |
|
|
1280 |
|
|
1281 |
+ |
static int |
1282 |
+ |
syncf_done( /* check if an rpiece sync file is complete */ |
1283 |
+ |
char *sfname |
1284 |
+ |
) |
1285 |
+ |
{ |
1286 |
+ |
FILE *fp = fopen(sfname, "r"); |
1287 |
+ |
int todo = 1; |
1288 |
+ |
int x, y; |
1289 |
+ |
|
1290 |
+ |
if (fp == NULL) |
1291 |
+ |
return(0); |
1292 |
+ |
if (fscanf(fp, "%d %d", &x, &y) != 2) |
1293 |
+ |
goto checked; |
1294 |
+ |
todo = x*y; /* total number of tiles */ |
1295 |
+ |
if (fscanf(fp, "%d %d", &x, &y) != 2 || (x != 0) | (y != 0)) |
1296 |
+ |
goto checked; |
1297 |
+ |
/* XXX assume no redundant tiles */ |
1298 |
+ |
while (fscanf(fp, "%d %d", &x, &y) == 2) |
1299 |
+ |
if (!--todo) |
1300 |
+ |
break; |
1301 |
+ |
checked: |
1302 |
+ |
fclose(fp); |
1303 |
+ |
return(!todo); |
1304 |
+ |
} |
1305 |
+ |
|
1306 |
+ |
|
1307 |
|
static void |
1308 |
|
rpict( /* run rpict and pfilt for each view */ |
1309 |
|
char *opts, |
1311 |
|
) |
1312 |
|
{ |
1313 |
|
#define do_rpiece (sfile[0]!='\0') |
1314 |
< |
char combuf[4*PATH_MAX+512]; |
1314 |
> |
char combuf[5*PATH_MAX+512]; |
1315 |
|
char rawfile[PATH_MAX], picfile[PATH_MAX]; |
1316 |
|
char zopt[PATH_MAX+4], rep[PATH_MAX+16], res[32]; |
1317 |
< |
char rppopt[128], sfile[64], *pfile = NULL; |
1317 |
> |
char rppopt[32], sfile[PATH_MAX], *pfile = NULL; |
1318 |
|
char pfopts[128]; |
1319 |
|
char vs[32], *vw; |
1320 |
|
int vn, mult; |
1321 |
|
FILE *fp; |
1322 |
|
time_t rfdt, pfdt; |
1323 |
+ |
int xres, yres; |
1324 |
+ |
double aspect; |
1325 |
+ |
int n; |
1326 |
|
/* get pfilt options */ |
1327 |
|
pfiltopts(pfopts); |
1328 |
|
/* get resolution, reporting */ |
1337 |
|
mult = 3; |
1338 |
|
break; |
1339 |
|
} |
1340 |
< |
{ |
1341 |
< |
int xres, yres; |
1342 |
< |
double aspect; |
1343 |
< |
int n; |
1344 |
< |
n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); |
1345 |
< |
if (n == 3) |
1346 |
< |
sprintf(res, "-x %d -y %d -pa %.3f", |
1347 |
< |
mult*xres, mult*yres, aspect); |
1348 |
< |
else if (n) { |
1349 |
< |
if (n == 1) yres = xres; |
1297 |
< |
sprintf(res, "-x %d -y %d", mult*xres, mult*yres); |
1298 |
< |
} else |
1299 |
< |
badvalue(RESOLUTION); |
1300 |
< |
} |
1340 |
> |
n = sscanf(vval(RESOLUTION), "%d %d %lf", &xres, &yres, &aspect); |
1341 |
> |
if (n == 3) |
1342 |
> |
sprintf(res, "-x %d -y %d -pa %.3f", |
1343 |
> |
mult*xres, mult*yres, aspect); |
1344 |
> |
else if (n) { |
1345 |
> |
aspect = 1.; |
1346 |
> |
if (n == 1) yres = xres; |
1347 |
> |
sprintf(res, "-x %d -y %d", mult*xres, mult*yres); |
1348 |
> |
} else |
1349 |
> |
badvalue(RESOLUTION); |
1350 |
|
rep[0] = '\0'; |
1351 |
|
if (vdef(REPORT)) { |
1352 |
|
double minutes; |
1304 |
– |
int n; |
1353 |
|
n = sscanf(vval(REPORT), "%lf %s", &minutes, rawfile); |
1354 |
|
if (n == 2) |
1355 |
|
sprintf(rep, " -t %d -e %s", (int)(minutes*60), rawfile); |
1364 |
|
getview(0, vs) != NULL) { |
1365 |
|
if (!strcmp(c_rpict, DEF_RPICT_PATH) && |
1366 |
|
getview(1, NULL) == NULL) { |
1367 |
< |
sprintf(sfile, "rpsync_%s.txt", vs); |
1367 |
> |
sprintf(sfile, "%s_%s_rpsync.txt", |
1368 |
> |
vdef(RAWFILE) ? vval(RAWFILE) : vval(PICTURE), |
1369 |
> |
vs); |
1370 |
|
strcpy(rppopt, "-PP pfXXXXXX"); |
1371 |
|
} else { |
1372 |
|
strcpy(rppopt, "-S 1 -PP pfXXXXXX"); |
1409 |
|
if (do_rpiece) { |
1410 |
|
if (rfdt < oct1date || !fdate(sfile)) { |
1411 |
|
int xdiv = 8+nprocs/3, ydiv = 8+nprocs/3; |
1412 |
< |
rfdt = 0; /* start fresh */ |
1412 |
> |
if (rfdt >= oct1date) { |
1413 |
> |
fprintf(stderr, |
1414 |
> |
"%s: partial output not created with %s\n", rawfile, c_rpiece); |
1415 |
> |
quit(1); |
1416 |
> |
} |
1417 |
> |
if (rfdt) { /* start fresh */ |
1418 |
> |
rmfile(rawfile); |
1419 |
> |
rfdt = 0; |
1420 |
> |
} |
1421 |
|
if (!silent) |
1422 |
|
printf("\techo %d %d > %s\n", |
1423 |
|
xdiv, ydiv, sfile); |
1454 |
|
} else { |
1455 |
|
if (overture) { /* run overture calculation */ |
1456 |
|
sprintf(combuf, |
1457 |
< |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1457 |
> |
"%s%s %s%s -x 64 -y 64 -ps 1 %s > %s", |
1458 |
|
c_rpict, rep, vw, opts, |
1459 |
|
oct1name, overfile); |
1460 |
< |
if (do_rpiece) |
1461 |
< |
while (next_process(1)) |
1462 |
< |
sleep(5); |
1405 |
< |
if (runcom(combuf)) { |
1406 |
< |
fprintf(stderr, |
1460 |
> |
if (!do_rpiece || !next_process(0)) { |
1461 |
> |
if (runcom(combuf)) { |
1462 |
> |
fprintf(stderr, |
1463 |
|
"%s: error in overture for view %s\n", |
1464 |
< |
progname, vs); |
1465 |
< |
quit(1); |
1466 |
< |
} |
1411 |
< |
if (do_rpiece) { |
1412 |
< |
finish_process(); |
1413 |
< |
wait_process(1); |
1414 |
< |
} |
1464 |
> |
progname, vs); |
1465 |
> |
quit(1); |
1466 |
> |
} |
1467 |
|
#ifndef NULL_DEVICE |
1468 |
< |
rmfile(overfile); |
1468 |
> |
rmfile(overfile); |
1469 |
|
#endif |
1470 |
+ |
} else if (do_rpiece) |
1471 |
+ |
sleep(20); |
1472 |
|
} |
1473 |
|
if (do_rpiece) { |
1474 |
|
sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", |
1500 |
|
if (do_rpiece) { /* need to finish raw, first */ |
1501 |
|
finish_process(); |
1502 |
|
wait_process(1); |
1503 |
< |
/* XXX should check sync file to see if really done? */ |
1503 |
> |
if (!syncf_done(sfile)) { |
1504 |
> |
fprintf(stderr, |
1505 |
> |
"%s: %s did not complete rendering of view %s\n", |
1506 |
> |
progname, c_rpiece, vs); |
1507 |
> |
quit(1); |
1508 |
> |
} |
1509 |
|
} |
1510 |
|
if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { |
1511 |
|
/* build pfilt command */ |
1512 |
< |
if (mult > 1) |
1512 |
> |
if (do_rpiece) |
1513 |
> |
sprintf(combuf, |
1514 |
> |
"%s%s -x %d -y %d -p %.3f %s > %s", |
1515 |
> |
c_pfilt, pfopts, xres, yres, aspect, |
1516 |
> |
rawfile, picfile); |
1517 |
> |
else if (mult > 1) |
1518 |
|
sprintf(combuf, "%s%s -x /%d -y /%d %s > %s", |
1519 |
|
c_pfilt, pfopts, mult, mult, |
1520 |
|
rawfile, picfile); |
1634 |
|
child_pid = fork(); /* split process */ |
1635 |
|
if (child_pid == 0) { /* we're the child */ |
1636 |
|
children_running = -1; |
1637 |
+ |
nprocs = 1; |
1638 |
|
return(0); |
1639 |
|
} |
1640 |
|
if (child_pid > 0) { /* we're the parent */ |
1702 |
|
return; /* in parent -- noop */ |
1703 |
|
exit(0); |
1704 |
|
} |
1640 |
– |
|
1641 |
– |
#ifdef _WIN32 |
1642 |
– |
setenv(vname, value) /* set an environment variable */ |
1643 |
– |
char *vname, *value; |
1644 |
– |
{ |
1645 |
– |
register char *evp; |
1646 |
– |
|
1647 |
– |
evp = bmalloc(strlen(vname)+strlen(value)+2); |
1648 |
– |
if (evp == NULL) |
1649 |
– |
syserr(progname); |
1650 |
– |
sprintf(evp, "%s=%s", vname, value); |
1651 |
– |
if (putenv(evp) != 0) { |
1652 |
– |
fprintf(stderr, "%s: out of environment space\n", progname); |
1653 |
– |
quit(1); |
1654 |
– |
} |
1655 |
– |
if (!silent) |
1656 |
– |
printf("set %s\n", evp); |
1657 |
– |
} |
1658 |
– |
#endif |
1705 |
|
|
1706 |
|
|
1707 |
|
static void |