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.12 by greg, Fri May 3 15:22:24 1991 UTC vs.
Revision 1.17 by greg, Mon Jun 24 16:10:49 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 = 32;                    /* virtual source pretest density */
38  
39   int  maxdepth = 4;                      /* maximum recursion depth */
40   double  minweight = 1e-2;               /* minimum ray weight */
# Line 116 | 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 &&
123 <                                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 133 | 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 < memreserve()                    /* fill memory reserves */
150 > fillreserves()                  /* fill memory reserves */
151   {
152          if (reserve_mem != NULL)
153 <                return;                 /* got some already */
153 >                return;
154          reserve_mem = malloc(RESERVE_AMT);
155   }
156  
157  
158 < memerror(detail)                /* try and rescue a memory error */
153 < char    *detail;
158 > freereserves()                  /* free memory reserves */
159   {
160 <        if (reserve_mem == NULL) {
161 <                sprintf(errmsg, "out of memory %s", detail);
157 <                error(SYSTEM, errmsg);
158 <        }
160 >        if (reserve_mem == NULL)
161 >                return;
162          free(reserve_mem);
163          reserve_mem = NULL;
161        for ( ; ; )
162                command("out of memory: ");
164   }
165  
166  
# Line 295 | Line 296 | rsample()                      /* sample the image */
296          ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
297          rl = (RECT *)malloc(xsiz*sizeof(RECT));
298          if (rl == NULL)
299 <                memerror("in rsample");
299 >                return;
300          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
301          if (pl == NULL)
302 <                memerror("in rsample");
302 >                return;
303          /*
304           * Initialize the bottom row.
305           */
# Line 385 | Line 386 | int  pd;
386          if (p->kid == NULL) {                   /* subdivide */
387  
388                  if ((p->kid = newptree()) == NULL)
389 <                        memerror("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