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] = "rpict"; |
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 */ |
221 |
|
if (i >= argc) |
222 |
|
goto userr; |
223 |
|
rifname = argv[i]; |
221 |
– |
/* check command-line options */ |
222 |
– |
if ((nprocs > 1) & (viewselect != NULL) & (rvdevice == NULL)) |
223 |
– |
nprocs = 1; |
224 |
|
/* assign Radiance root file name */ |
225 |
|
rootname(radname, rifname); |
226 |
|
/* load variable values */ |
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) { |
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); |
1322 |
– |
if (!vs[0]) |
1323 |
– |
sprintf(vs, "%d", vn); |
1337 |
|
sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs); |
1338 |
|
if (vdef(ZFILE)) |
1339 |
|
sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs); |
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 |
> |
int xdiv = 8+nprocs/3, ydiv = 8+nprocs/3; |
1362 |
> |
rfdt = 0; /* start fresh */ |
1363 |
> |
if (!silent) |
1364 |
> |
printf("echo %d %d > %s\n", |
1365 |
> |
xdiv, ydiv, sfile); |
1366 |
> |
if ((fp = fopen(sfile, "w")) == NULL) { |
1367 |
> |
fprintf(stderr, "%s: cannot create\n", |
1368 |
> |
sfile); |
1369 |
> |
quit(1); |
1370 |
> |
} |
1371 |
> |
fprintf(fp, "%d %d\n", xdiv, ydiv); |
1372 |
> |
fclose(fp); |
1373 |
> |
} |
1374 |
> |
} else if (next_process()) { |
1375 |
|
if (pfile != NULL) |
1376 |
< |
sleep(20); |
1376 |
> |
sleep(10); |
1377 |
|
continue; |
1378 |
< |
} |
1378 |
> |
} else if (!inchild()) |
1379 |
> |
pfile = NULL; |
1380 |
|
/* XXX Remember to call finish_process() */ |
1381 |
|
/* build rpict command */ |
1382 |
< |
if (rfdt >= oct1date) { /* recover */ |
1383 |
< |
sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, |
1384 |
< |
rep, opts, po, zopt, rawfile, oct1name); |
1385 |
< |
if (runcom(combuf)) /* run rpict */ |
1382 |
> |
if (rfdt >= oct1date) { /* already in progress */ |
1383 |
> |
if (do_rpiece) { |
1384 |
> |
sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s", |
1385 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1386 |
> |
res, opts, po, rawfile, oct1name); |
1387 |
> |
while (children_running < nprocs-1 && |
1388 |
> |
next_process()) { |
1389 |
> |
sleep(10); |
1390 |
> |
combuf[strlen(c_rpiece)+2] = 'F'; |
1391 |
> |
} |
1392 |
> |
} else |
1393 |
> |
sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict, |
1394 |
> |
rep, opts, po, zopt, rawfile, oct1name); |
1395 |
> |
if (runcom(combuf)) /* run rpict/rpiece */ |
1396 |
|
goto rperror; |
1397 |
|
} else { |
1398 |
|
if (overture) { /* run overture calculation */ |
1410 |
|
rmfile(overfile); |
1411 |
|
#endif |
1412 |
|
} |
1413 |
< |
sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", |
1414 |
< |
c_rpict, rep, vw, res, opts, po, |
1415 |
< |
zopt, oct1name, rawfile); |
1416 |
< |
if (pfile != NULL && inchild()) { |
1417 |
< |
/* rpict persistent mode */ |
1413 |
> |
if (do_rpiece) { |
1414 |
> |
sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s", |
1415 |
> |
c_rpiece, sfile, rppopt, rep, vw, |
1416 |
> |
res, opts, po, rawfile, oct1name); |
1417 |
> |
while (children_running < nprocs-1 && |
1418 |
> |
next_process()) |
1419 |
> |
sleep(10); |
1420 |
> |
} else { |
1421 |
> |
sprintf(combuf, "%s%s %s %s%s%s%s %s > %s", |
1422 |
> |
c_rpict, rep, vw, res, opts, po, |
1423 |
> |
zopt, oct1name, rawfile); |
1424 |
> |
} |
1425 |
> |
if ((pfile != NULL) & !do_rpiece) { |
1426 |
|
if (!silent) |
1427 |
|
printf("\t%s\n", combuf); |
1428 |
|
fflush(stdout); |
1429 |
|
sprintf(combuf, "%s%s %s %s%s%s %s > %s", |
1430 |
< |
c_rpict, rep, rppopt, res, opts, |
1431 |
< |
po, oct1name, rawfile); |
1430 |
> |
c_rpict, rep, rppopt, res, |
1431 |
> |
opts, po, oct1name, rawfile); |
1432 |
|
fp = popen(combuf, "w"); |
1433 |
|
if (fp == NULL) |
1434 |
|
goto rperror; |
1435 |
|
myprintview(vw, fp); |
1436 |
|
if (pclose(fp)) |
1437 |
|
goto rperror; |
1438 |
< |
} else { /* rpict normal mode */ |
1439 |
< |
if (runcom(combuf)) |
1392 |
< |
goto rperror; |
1393 |
< |
} |
1438 |
> |
} else if (runcom(combuf)) |
1439 |
> |
goto rperror; |
1440 |
|
} |
1441 |
+ |
if (do_rpiece) { /* need to finish raw, first */ |
1442 |
+ |
finish_process(); |
1443 |
+ |
wait_process(1); |
1444 |
+ |
/* XXX should check sync file to see if really done? */ |
1445 |
+ |
} |
1446 |
|
if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) { |
1447 |
|
/* build pfilt command */ |
1448 |
|
if (mult > 1) |
1466 |
|
mvfile(rawfile, combuf); |
1467 |
|
} else |
1468 |
|
rmfile(rawfile); |
1469 |
< |
finish_process(); /* exit if child */ |
1469 |
> |
if (do_rpiece) /* done with sync file */ |
1470 |
> |
rmfile(sfile); |
1471 |
> |
else |
1472 |
> |
finish_process(); /* exit if child */ |
1473 |
|
} |
1474 |
|
wait_process(1); /* wait for children to finish */ |
1475 |
< |
if (pfile != NULL) { /* clean up rpict persistent mode */ |
1475 |
> |
if (pfile != NULL) { /* clean up persistent rpict */ |
1476 |
|
RT_PID pid; |
1477 |
|
fp = fopen(pfile, "r"); |
1478 |
|
if (fp != NULL) { |
1486 |
|
rperror: |
1487 |
|
fprintf(stderr, "%s: error rendering view %s\n", progname, vs); |
1488 |
|
quit(1); |
1489 |
+ |
#undef do_rpiece |
1490 |
|
} |
1491 |
|
|
1492 |
|
|
1499 |
|
printf("\ttouch %s\n", fn); |
1500 |
|
if (!nprocs) |
1501 |
|
return(0); |
1447 |
– |
#ifdef notused |
1448 |
– |
if (access(fn, F_OK) == -1) /* create it */ |
1449 |
– |
if (close(open(fn, O_WRONLY|O_CREAT, 0666)) == -1) |
1450 |
– |
return(-1); |
1451 |
– |
#endif |
1502 |
|
return(setfdate(fn, time((time_t *)NULL))); |
1503 |
|
} |
1504 |
|
|