--- ray/src/hd/rholo.c 1997/12/01 16:34:21 3.14 +++ ray/src/hd/rholo.c 1997/12/08 18:51:15 3.17 @@ -26,12 +26,12 @@ char froot[MAXPATH]; /* root file name */ int nowarn = 0; /* turn warnings off? */ -double expval = 1.; /* global exposure value */ - int ncprocs = 0; /* desired number of compute processes */ char *outdev = NULL; /* output device name */ +int readinp = 0; /* read commands from stdin */ + time_t starttime; /* time we got started */ time_t endtime; /* time we should end by */ time_t reporttime; /* time for next report */ @@ -72,6 +72,9 @@ char *argv[]; case 'f': /* force overwrite */ force++; break; + case 'i': /* read input from stdin */ + readinp++; + break; case 'n': /* compute processes */ if (i >= argc-2) goto userr; @@ -115,12 +118,17 @@ char *argv[]; creatholo(&hdg); } else { /* else load holodeck */ loadholo(); - if (vdef(RIF)) /* load RIF if any */ + /* check settings */ + checkvalues(); + /* load RIF if any */ + if (vdef(RIF)) getradfile(vval(RIF)); + /* set defaults */ + setdefaults(NULL); } /* initialize */ initrholo(); - /* run */ + /* main loop */ while (rholo()) ; /* done */ @@ -184,6 +192,8 @@ initrholo() /* get our holodeck running */ { extern int global_packet(); register int i; + /* close holodeck on exec() */ + fcntl(hdlist[0]->fd, F_SETFD, FD_CLOEXEC); if (outdev != NULL) /* open output device */ disp_open(outdev); @@ -335,32 +345,6 @@ register HDGRID *gp; sprintf(errmsg, "ignoring all but first %s", vnam(SECTION)); error(WARNING, errmsg); } - if (sscanf(vval(SECTION), - "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", - &gp->orig[0], &gp->orig[1], &gp->orig[2], - &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2], - &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2], - &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2]) != 12) - badvalue(SECTION); - maxlen = 0.; - for (i = 0; i < 3; i++) - if ((len[i] = VLEN(gp->xv[i])) > maxlen) - maxlen = len[i]; - if (!vdef(GRID)) { - sprintf(buf, "%.4f", maxlen/8.); - vval(GRID) = savqstr(buf); - vdef(GRID)++; - } - if ((d = vflt(GRID)) <= FTINY) - badvalue(GRID); - for (i = 0; i < 3; i++) - gp->grid[i] = len[i]/d + (1.-FTINY); - if (!vdef(EXPOSURE)) { - sprintf(errmsg, "%s must be defined", vnam(EXPOSURE)); - error(USER, errmsg); - } - expval = vval(EXPOSURE)[0] == '-' || vval(EXPOSURE)[0] == '+' ? - pow(2., vflt(EXPOSURE)) : vflt(EXPOSURE); if (!vdef(OCTREE)) { if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL) error(SYSTEM, "out of memory"); @@ -382,6 +366,33 @@ register HDGRID *gp; /* append rendering options */ if (vdef(RENDER)) rtargc += wordstring(rtargv+rtargc, vval(RENDER)); + + if (gp == NULL) /* already initialized? */ + return; + /* set grid parameters */ + gp->grid[0] = gp->grid[1] = gp->grid[2] = 0; + if (sscanf(vval(SECTION), + "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %hd %hd %hd", + &gp->orig[0], &gp->orig[1], &gp->orig[2], + &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2], + &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2], + &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2], + &gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12) + badvalue(SECTION); + maxlen = 0.; + for (i = 0; i < 3; i++) + if ((len[i] = VLEN(gp->xv[i])) > maxlen) + maxlen = len[i]; + if (!vdef(GRID)) { + sprintf(buf, "%.4f", maxlen/8.); + vval(GRID) = savqstr(buf); + vdef(GRID)++; + } + if ((d = vflt(GRID)) <= FTINY) + badvalue(GRID); + for (i = 0; i < 3; i++) + if (gp->grid[i] <= 0) + gp->grid[i] = len[i]/d + (1.-FTINY); } @@ -499,7 +510,7 @@ PACKET *pl; getradfile(rfargs) /* run rad and get needed variables */ char *rfargs; { - static short mvar[] = {OCTREE,EXPOSURE,-1}; + static short mvar[] = {OCTREE,-1}; static char tf1[] = TEMPLATE; char tf2[64]; char combuf[256];