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.11 by greg, Fri Mar 9 14:00:06 1990 UTC vs.
Revision 1.18 by greg, Tue Jun 25 14:06:15 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  
39   int  maxdepth = 4;                      /* maximum recursion depth */
40   double  minweight = 1e-2;               /* minimum ray weight */
# Line 55 | Line 59 | PNODE  ptrunk;                         /* the base of our image */
59   RECT  pframe;                           /* current frame boundaries */
60   int  pdepth;                            /* image depth in current frame */
61  
62 + static char  *reserve_mem = NULL;       /* pre-allocated reserve memory */
63 +
64 + #define RESERVE_AMT     8192            /* amount of memory to reserve */
65 +
66   #define  CTRL(c)        ('c'-'@')
67  
68  
# Line 112 | Line 120 | rview()                                /* do a view */
120          char  buf[32];
121  
122          devopen(devname);               /* open device */
123 <        newimage();                     /* set up image */
123 >        newimage();                     /* start image (calls fillreserves) */
124  
125          for ( ; ; ) {                   /* quit in command() */
126 <                while (hresolu <= 1<<pdepth &&
119 <                                vresolu <= 1<<pdepth)
126 >                while (hresolu <= 1<<pdepth && vresolu <= 1<<pdepth)
127                          command("done: ");
128 <
129 <                if (hresolu <= psample<<pdepth &&
130 <                                vresolu <= psample<<pdepth) {
128 >                while (reserve_mem == NULL)
129 >                        command("out of memory: ");
130 >                errno = 0;
131 >                if (hresolu <= psample<<pdepth && vresolu <= psample<<pdepth) {
132                          sprintf(buf, "%d sampling...\n", 1<<pdepth);
133                          (*dev->comout)(buf);
134                          rsample();
# Line 129 | Line 137 | rview()                                /* do a view */
137                          (*dev->comout)(buf);
138                          refine(&ptrunk, 0, 0, hresolu, vresolu, pdepth+1);
139                  }
140 <                if (dev->inpready)
140 >                if (errno == ENOMEM)            /* ran out of memory */
141 >                        freereserves();
142 >                else if (dev->inpready)         /* noticed some input */
143                          command(": ");
144 <                else
144 >                else                            /* finished this depth */
145                          pdepth++;
146          }
147   }
148  
149  
150 + fillreserves()                  /* fill memory reserves */
151 + {
152 +        if (reserve_mem != NULL)
153 +                return;
154 +        reserve_mem = malloc(RESERVE_AMT);
155 + }
156 +
157 +
158 + freereserves()                  /* free memory reserves */
159 + {
160 +        if (reserve_mem == NULL)
161 +                return;
162 +        free(reserve_mem);
163 +        reserve_mem = NULL;
164 + }
165 +
166 +
167   command(prompt)                 /* get/execute command */
168   char  *prompt;
169   {
# Line 268 | Line 295 | rsample()                      /* sample the image */
295          xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
296          ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
297          rl = (RECT *)malloc(xsiz*sizeof(RECT));
298 +        if (rl == NULL)
299 +                return;
300          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
301 <        if (rl == NULL || pl == NULL)
302 <                error(SYSTEM, "out of memory in rsample");
301 >        if (pl == NULL)
302 >                return;
303          /*
304           * Initialize the bottom row.
305           */
# Line 357 | Line 386 | int  pd;
386          if (p->kid == NULL) {                   /* subdivide */
387  
388                  if ((p->kid = newptree()) == NULL)
389 <                        error(SYSTEM, "out of memory in refine");
389 >                        return(growth);
390                  /*
391                   *  The following paint order can leave a black pixel
392                   *  when redraw() is called in (*dev->paintr)().

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines