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

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.12 by gregl, Thu Nov 20 11:39:24 1997 UTC vs.
Revision 3.16 by gregl, Thu Dec 4 10:30:33 1997 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ SGI";
9   */
10  
11   #include "rholo.h"
12 + #include "random.h"
13   #include "paths.h"
14   #include <signal.h>
15   #include <sys/types.h>
# Line 25 | Line 26 | char   froot[MAXPATH];         /* root file name */
26  
27   int     nowarn = 0;             /* turn warnings off? */
28  
28 double  expval = 1.;            /* global exposure value */
29
29   int     ncprocs = 0;            /* desired number of compute processes */
30  
31   char    *outdev = NULL;         /* output device name */
# Line 61 | Line 60 | char   *argv[];
60          int     force = 0;
61                                                  /* mark start time */
62          starttime = time(NULL);
63 +        initurand(10240);                       /* initialize urand */
64          progname = argv[0];                     /* get arguments */
65          for (i = 1; i < argc && argv[i][0] == '-'; i++)
66                  switch (argv[i][1]) {
# Line 113 | Line 113 | char   *argv[];
113                  creatholo(&hdg);
114          } else {                                /* else load holodeck */
115                  loadholo();
116 <                if (vdef(RIF))                          /* load RIF if any */
116 >                                                        /* check settings */
117 >                checkvalues();
118 >                                                        /* load RIF if any */
119 >                if (vdef(RIF))
120                          getradfile(vval(RIF));
121 +                                                        /* set defaults */
122 +                setdefaults(NULL);
123          }
124                                                  /* initialize */
125          initrholo();
126 <                                                /* run */
126 >                                                /* main loop */
127          while (rholo())
128                  ;
129                                                  /* done */
# Line 333 | Line 338 | register HDGRID        *gp;
338                  sprintf(errmsg, "ignoring all but first %s", vnam(SECTION));
339                  error(WARNING, errmsg);
340          }
336        if (sscanf(vval(SECTION),
337                        "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf",
338                        &gp->orig[0], &gp->orig[1], &gp->orig[2],
339                        &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2],
340                        &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2],
341                        &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2]) != 12)
342                badvalue(SECTION);
343        maxlen = 0.;
344        for (i = 0; i < 3; i++)
345                if ((len[i] = VLEN(gp->xv[i])) > maxlen)
346                        maxlen = len[i];
347        if (!vdef(GRID)) {
348                sprintf(buf, "%.4f", maxlen/8.);
349                vval(GRID) = savqstr(buf);
350                vdef(GRID)++;
351        }
352        if ((d = vflt(GRID)) <= FTINY)
353                badvalue(GRID);
354        for (i = 0; i < 3; i++)
355                gp->grid[i] = len[i]/d + (1.-FTINY);
356        if (!vdef(EXPOSURE)) {
357                sprintf(errmsg, "%s must be defined", vnam(EXPOSURE));
358                error(USER, errmsg);
359        }
360        expval = vval(EXPOSURE)[0] == '-' || vval(EXPOSURE)[0] == '+' ?
361                        pow(2., vflt(EXPOSURE)) : vflt(EXPOSURE);
341          if (!vdef(OCTREE)) {
342                  if ((vval(OCTREE) = bmalloc(strlen(froot)+5)) == NULL)
343                          error(SYSTEM, "out of memory");
# Line 369 | Line 348 | register HDGRID        *gp;
348                  vval(OBSTRUCTIONS) = "T";
349                  vdef(OBSTRUCTIONS)++;
350          }
351 +        if (!vdef(VDIST)) {
352 +                vval(VDIST) = "F";
353 +                vdef(VDIST)++;
354 +        }
355          if (!vdef(OCCUPANCY)) {
356                  vval(OCCUPANCY) = "U";
357                  vdef(OCCUPANCY)++;
# Line 376 | Line 359 | register HDGRID        *gp;
359                                  /* append rendering options */
360          if (vdef(RENDER))
361                  rtargc += wordstring(rtargv+rtargc, vval(RENDER));
362 +        
363 +        if (gp == NULL)         /* already initialized? */
364 +                return;
365 +                                /* set grid parameters */
366 +        gp->grid[0] = gp->grid[1] = gp->grid[2] = 0;
367 +        if (sscanf(vval(SECTION),
368 +                "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %hd %hd %hd",
369 +                        &gp->orig[0], &gp->orig[1], &gp->orig[2],
370 +                        &gp->xv[0][0], &gp->xv[0][1], &gp->xv[0][2],
371 +                        &gp->xv[1][0], &gp->xv[1][1], &gp->xv[1][2],
372 +                        &gp->xv[2][0], &gp->xv[2][1], &gp->xv[2][2],
373 +                        &gp->grid[0], &gp->grid[1], &gp->grid[2]) < 12)
374 +                badvalue(SECTION);
375 +        maxlen = 0.;
376 +        for (i = 0; i < 3; i++)
377 +                if ((len[i] = VLEN(gp->xv[i])) > maxlen)
378 +                        maxlen = len[i];
379 +        if (!vdef(GRID)) {
380 +                sprintf(buf, "%.4f", maxlen/8.);
381 +                vval(GRID) = savqstr(buf);
382 +                vdef(GRID)++;
383 +        }
384 +        if ((d = vflt(GRID)) <= FTINY)
385 +                badvalue(GRID);
386 +        for (i = 0; i < 3; i++)
387 +                if (gp->grid[i] <= 0)
388 +                        gp->grid[i] = len[i]/d + (1.-FTINY);
389   }
390  
391  
# Line 463 | Line 473 | loadholo()                     /* start loading a holodeck from fname */
473   done_packets(pl)                /* handle finished packets */
474   PACKET  *pl;
475   {
476 <        static int      nunflushed = 0;
476 >        static int      n2flush = 0;
477          register PACKET *p;
478  
479          while (pl != NULL) {
# Line 474 | Line 484 | PACKET *pl;
484                                  p->nr*sizeof(RAYVAL));
485                          if (outdev != NULL)     /* display it */
486                                  disp_packet((PACKHEAD *)p);
487 <                        else
488 <                                nunflushed += p->nr;
487 >                        if (hdcachesize <= 0)   /* manual flushing */
488 >                                n2flush += p->nr;
489                          nraysdone += p->nr;
490                          npacksdone++;
491                  }
# Line 483 | Line 493 | PACKET *pl;
493                  p->next = freepacks;
494                  freepacks = p;
495          }
496 <        if (nunflushed >= 256*RPACKSIZ) {
496 >        if (n2flush > 512*RPACKSIZ*ncprocs) {
497                  hdflush(NULL);                  /* flush holodeck buffers */
498 <                nunflushed = 0;
498 >                n2flush = 0;
499          }
500   }
501  
# Line 493 | Line 503 | PACKET *pl;
503   getradfile(rfargs)              /* run rad and get needed variables */
504   char    *rfargs;
505   {
506 <        static short    mvar[] = {OCTREE,EXPOSURE,-1};
506 >        static short    mvar[] = {OCTREE,-1};
507          static char     tf1[] = TEMPLATE;
508          char    tf2[64];
509          char    combuf[256];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines