ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rad.c
(Generate patch)

Comparing ray/src/util/rad.c (file contents):
Revision 2.92 by greg, Mon Feb 9 16:41:29 2009 UTC vs.
Revision 2.93 by greg, Tue May 18 00:01:02 2010 UTC

# Line 116 | Line 116 | int    sayview = 0;            /* print view out */
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 */
# Line 218 | Line 221 | main(
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 */
# Line 1158 | Line 1158 | getview(                               /* get view n, or NULL if none */
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) {
# Line 1259 | Line 1260 | rpict(                         /* run rpict and pfilt for each view */
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;
# Line 1309 | Line 1311 | rpict(                         /* run rpict and pfilt for each view */
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;
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, "rpiece_%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 <                        pfile = NULL;
1326 >                        if (do_rpiece) {
1327 >                                fprintf(stderr, "%s: cannot create\n", pfile);
1328 >                                quit(1);
1329 >                        } else
1330 >                                pfile = NULL;
1331          }
1332          vn = 0;                                 /* do each view */
1333          while ((vw = getview(vn++, vs)) != NULL) {
1334                  if (sayview)
1335                          myprintview(vw, stdout);
1322                if (!vs[0])
1323                        sprintf(vs, "%d", vn);
1336                  sprintf(picfile, "%s_%s.hdr", vval(PICTURE), vs);
1337                  if (vdef(ZFILE))
1338                          sprintf(zopt, " -z %s_%s.zbf", vval(ZFILE), vs);
# Line 1342 | Line 1354 | rpict(                         /* run rpict and pfilt for each view */
1354                                  touch(picfile);
1355                          continue;
1356                  }
1357 <                if (next_process()) {           /* parallel running? */
1357 >                                                /* parallel running? */
1358 >                if (do_rpiece) {
1359 >                        if (rfdt < oct1date || fdate(sfile) < oct1date) {
1360 >                                rfdt = 0;               /* start fresh */
1361 >                                if ((fp = fopen(sfile, "w")) == NULL) {
1362 >                                        fprintf(stderr, "%s: cannot create\n",
1363 >                                                        sfile);
1364 >                                        quit(1);
1365 >                                }
1366 >                                fprintf(fp, "%d %d\n", 8+nprocs/3, 8+nprocs/3);
1367 >                                fclose(fp);
1368 >                        }
1369 >                } else if (next_process()) {
1370                          if (pfile != NULL)
1371 <                                sleep(20);
1371 >                                sleep(10);
1372                          continue;
1373 <                }
1373 >                } else if (!inchild())
1374 >                        pfile = NULL;
1375                  /* XXX Remember to call finish_process() */
1376                                                  /* build rpict command */
1377 <                if (rfdt >= oct1date) {         /* recover */
1378 <                        sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict,
1379 <                                rep, opts, po, zopt, rawfile, oct1name);
1380 <                        if (runcom(combuf))     /* run rpict */
1377 >                if (rfdt >= oct1date) {         /* already in progress */
1378 >                        if (do_rpiece) {
1379 >                                sprintf(combuf, "%s -R %s %s%s %s %s%s%s -o %s %s",
1380 >                                                c_rpiece, sfile, rppopt, rep, vw,
1381 >                                                res, opts, po, rawfile, oct1name);
1382 >                                while (children_running < nprocs-1 &&
1383 >                                                        next_process()) {
1384 >                                        sleep(10);
1385 >                                        combuf[strlen(c_rpiece)+2] = 'F';
1386 >                                }
1387 >                        } else
1388 >                                sprintf(combuf, "%s%s%s%s%s -ro %s %s", c_rpict,
1389 >                                        rep, opts, po, zopt, rawfile, oct1name);
1390 >                        if (runcom(combuf))     /* run rpict/rpiece */
1391                                  goto rperror;
1392                  } else {
1393                          if (overture) {         /* run overture calculation */
# Line 1370 | Line 1405 | rpict(                         /* run rpict and pfilt for each view */
1405                                  rmfile(overfile);
1406   #endif
1407                          }
1408 <                        sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
1409 <                                        c_rpict, rep, vw, res, opts, po,
1410 <                                        zopt, oct1name, rawfile);
1411 <                        if (pfile != NULL && inchild()) {
1412 <                                                /* rpict persistent mode */
1408 >                        if (do_rpiece) {
1409 >                                sprintf(combuf, "%s -F %s %s%s %s %s%s%s -o %s %s",
1410 >                                                c_rpiece, sfile, rppopt, rep, vw,
1411 >                                                res, opts, po, rawfile, oct1name);
1412 >                                while (children_running < nprocs-1 &&
1413 >                                                        next_process())
1414 >                                        sleep(10);
1415 >                        } else {
1416 >                                sprintf(combuf, "%s%s %s %s%s%s%s %s > %s",
1417 >                                                c_rpict, rep, vw, res, opts, po,
1418 >                                                zopt, oct1name, rawfile);
1419 >                        }
1420 >                        if ((pfile != NULL) & !do_rpiece) {
1421                                  if (!silent)
1422                                          printf("\t%s\n", combuf);
1423                                  fflush(stdout);
1424                                  sprintf(combuf, "%s%s %s %s%s%s %s > %s",
1425 <                                                c_rpict, rep, rppopt, res, opts,
1426 <                                                po, oct1name, rawfile);
1425 >                                                c_rpict, rep, rppopt, res,
1426 >                                                opts, po, oct1name, rawfile);
1427                                  fp = popen(combuf, "w");
1428                                  if (fp == NULL)
1429                                          goto rperror;
1430                                  myprintview(vw, fp);
1431                                  if (pclose(fp))
1432                                          goto rperror;
1433 <                        } else {                /* rpict normal mode */
1434 <                                if (runcom(combuf))
1392 <                                        goto rperror;
1393 <                        }
1433 >                        } else if (runcom(combuf))
1434 >                                goto rperror;
1435                  }
1436 +                if (do_rpiece) {                /* need to finish raw, first */
1437 +                        finish_process();
1438 +                        wait_process(1);
1439 +                        /* XXX should check sync file to see if really done? */
1440 +                }
1441                  if (!vdef(RAWFILE) || strcmp(vval(RAWFILE),vval(PICTURE))) {
1442                                                  /* build pfilt command */
1443                          if (mult > 1)
# Line 1415 | Line 1461 | rpict(                         /* run rpict and pfilt for each view */
1461                          mvfile(rawfile, combuf);
1462                  } else
1463                          rmfile(rawfile);
1464 <                finish_process();               /* exit if child */
1464 >                if (do_rpiece)                  /* done with sync file */
1465 >                        rmfile(sfile);
1466 >                else
1467 >                        finish_process();       /* exit if child */
1468          }
1469          wait_process(1);                /* wait for children to finish */
1470          if (pfile != NULL) {            /* clean up rpict persistent mode */
# Line 1432 | Line 1481 | rpict(                         /* run rpict and pfilt for each view */
1481   rperror:
1482          fprintf(stderr, "%s: error rendering view %s\n", progname, vs);
1483          quit(1);
1484 + #undef do_rpiece
1485   }
1486  
1487  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines