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.91 by greg, Thu Dec 18 23:26:57 2008 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 1123 | Line 1123 | specview(                              /* get proper view spec from vs */
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                  }
# Line 1152 | Line 1152 | getview(                               /* get view n, or NULL if none */
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) {
# Line 1162 | Line 1168 | getview(                               /* get view n, or NULL if none */
1168                                  ;
1169                          *vn = '\0';
1170                  }
1165                                                /* view number? */
1166                if (isint(viewselect))
1167                        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  
# Line 1253 | 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 1303 | 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);
1316                if (!vs[0])
1317                        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 1336 | 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 1364 | 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))
1386 <                                        goto rperror;
1387 <                        }
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 1409 | 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 1426 | 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