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

Comparing ray/src/rt/rview.c (file contents):
Revision 1.10 by greg, Tue Jan 30 11:37:41 1990 UTC vs.
Revision 1.19 by greg, Thu Jul 18 14:42:58 1991 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *     3/24/87
11   */
12  
13 < #include  "standard.h"
13 > #include  "ray.h"
14  
15 #include  "color.h"
16
15   #include  "rpaint.h"
16  
17   #include  <signal.h>
# Line 23 | Line 21 | static char SCCSid[] = "$SunId$ LBL";
21   VIEW  ourview = STDVIEW;                /* viewing parameters */
22   int  hresolu, vresolu;                  /* image resolution */
23  
24 + int  dimlist[MAXDIM];                   /* sampling dimensions */
25 + int  ndims = 0;                         /* number of sampling dimensions */
26 + int  samplendx = 0;                     /* index for this sample */
27 +
28   int  psample = 8;                       /* pixel sample size */
29   double  maxdiff = .15;                  /* max. sample difference */
30  
# Line 31 | Line 33 | double  exposure = 1.0;                        /* exposure for scene */
33   double  dstrsrc = 0.0;                  /* square source distribution */
34   double  shadthresh = .1;                /* shadow threshold */
35   double  shadcert = .25;                 /* shadow certainty */
36 + int  directrelay = 0;                   /* number of source relays */
37 + int  vspretest = 128;                   /* virtual source pretest density */
38 + int  directinvis = 0;                   /* sources invisible? */
39  
40   int  maxdepth = 4;                      /* maximum recursion depth */
41   double  minweight = 1e-2;               /* minimum ray weight */
# Line 45 | Line 50 | char  *amblist[128];                   /* ambient include/exclude list
50   int  ambincl = -1;                      /* include == 1, exclude == 0 */
51  
52   int  greyscale = 0;                     /* map colors to brightness? */
53 < char  *devname = "X";                   /* output device name */
53 > char  *devname = dev_default;           /* output device name */
54  
55   struct driver  *dev = NULL;             /* driver functions */
56  
# Line 55 | Line 60 | PNODE  ptrunk;                         /* the base of our image */
60   RECT  pframe;                           /* current frame boundaries */
61   int  pdepth;                            /* image depth in current frame */
62  
63 + static char  *reserve_mem = NULL;       /* pre-allocated reserve memory */
64 +
65 + #define RESERVE_AMT     8192            /* amount of memory to reserve */
66 +
67   #define  CTRL(c)        ('c'-'@')
68  
69  
# Line 112 | Line 121 | rview()                                /* do a view */
121          char  buf[32];
122  
123          devopen(devname);               /* open device */
124 <        newimage();                     /* set up image */
124 >        newimage();                     /* start image (calls fillreserves) */
125  
126          for ( ; ; ) {                   /* quit in command() */
127 <                while (hresolu <= 1<<pdepth &&
119 <                                vresolu <= 1<<pdepth)
127 >                while (hresolu <= 1<<pdepth && vresolu <= 1<<pdepth)
128                          command("done: ");
129 <
130 <                if (hresolu <= psample<<pdepth &&
131 <                                vresolu <= psample<<pdepth) {
129 >                while (reserve_mem == NULL)
130 >                        command("out of memory: ");
131 >                errno = 0;
132 >                if (hresolu <= psample<<pdepth && vresolu <= psample<<pdepth) {
133                          sprintf(buf, "%d sampling...\n", 1<<pdepth);
134                          (*dev->comout)(buf);
135                          rsample();
# Line 129 | Line 138 | rview()                                /* do a view */
138                          (*dev->comout)(buf);
139                          refine(&ptrunk, 0, 0, hresolu, vresolu, pdepth+1);
140                  }
141 <                if (dev->inpready)
141 >                if (errno == ENOMEM)            /* ran out of memory */
142 >                        freereserves();
143 >                else if (dev->inpready)         /* noticed some input */
144                          command(": ");
145 <                else
145 >                else                            /* finished this depth */
146                          pdepth++;
147          }
148   }
149  
150  
151 + fillreserves()                  /* fill memory reserves */
152 + {
153 +        if (reserve_mem != NULL)
154 +                return;
155 +        reserve_mem = malloc(RESERVE_AMT);
156 + }
157 +
158 +
159 + freereserves()                  /* free memory reserves */
160 + {
161 +        if (reserve_mem == NULL)
162 +                return;
163 +        free(reserve_mem);
164 +        reserve_mem = NULL;
165 + }
166 +
167 +
168   command(prompt)                 /* get/execute command */
169   char  *prompt;
170   {
# Line 268 | Line 296 | rsample()                      /* sample the image */
296          xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
297          ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
298          rl = (RECT *)malloc(xsiz*sizeof(RECT));
299 +        if (rl == NULL)
300 +                return;
301          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
302 <        if (rl == NULL || pl == NULL)
303 <                error(SYSTEM, "out of memory in rsample");
302 >        if (pl == NULL)
303 >                return;
304          /*
305           * Initialize the bottom row.
306           */
# Line 357 | Line 387 | int  pd;
387          if (p->kid == NULL) {                   /* subdivide */
388  
389                  if ((p->kid = newptree()) == NULL)
390 <                        error(SYSTEM, "out of memory in refine");
390 >                        return(growth);
391                  /*
392                   *  The following paint order can leave a black pixel
393                   *  when redraw() is called in (*dev->paintr)().

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines