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 2.6 by greg, Thu Jan 16 12:05:26 1992 UTC vs.
Revision 2.13 by greg, Wed Sep 14 18:35:21 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 26 | Line 26 | 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 */
29 > double  maxdiff = .15;                  /* max. sample difference */
30  
31 < double  exposure = 1.0;                 /* exposure for scene */
31 > double  exposure = 1.0;                 /* exposure for scene */
32  
33 < double  dstrsrc = 0.0;                  /* square source distribution */
34 < double  shadthresh = .1;                /* shadow threshold */
35 < double  shadcert = .25;                 /* shadow certainty */
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 < double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
38 > int  directvis = 1;                     /* sources visible? */
39 > double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
40  
41 < double  specthresh = .3;                /* specular sampling threshold */
42 < double  specjitter = 1.;                /* specular sampling jitter */
41 > double  specthresh = .3;                /* specular sampling threshold */
42 > double  specjitter = 1.;                /* specular sampling jitter */
43  
44   int  maxdepth = 4;                      /* maximum recursion depth */
45 < double  minweight = 1e-2;               /* minimum ray weight */
45 > double  minweight = 1e-2;               /* minimum ray weight */
46  
47   COLOR  ambval = BLKCOLOR;               /* ambient value */
48 < double  ambacc = 0.2;                   /* ambient accuracy */
48 > double  ambacc = 0.2;                   /* ambient accuracy */
49   int  ambres = 8;                        /* ambient resolution */
50   int  ambdiv = 32;                       /* ambient divisions */
51   int  ambssamp = 0;                      /* ambient super-samples */
# Line 58 | Line 58 | char  *devname = dev_default;          /* output device name *
58  
59   struct driver  *dev = NULL;             /* driver functions */
60  
61 + char  rifname[128];                     /* rad input file name */
62 +
63   VIEW  oldview;                          /* previous view parameters */
64  
65   PNODE  ptrunk;                          /* the base of our image */
# Line 68 | Line 70 | static char  *reserve_mem = NULL;      /* pre-allocated res
70  
71   #define RESERVE_AMT     32768           /* amount of memory to reserve */
72  
73 < #define  CTRL(c)        ((c)-'@')
73 > #define  CTRL(c)        ((c)-'@')
74  
75  
76   quit(code)                      /* quit program */
77   int  code;
78   {
79 + #ifdef MSTATS
80 +        if (code == 2 && errno == ENOMEM)
81 +                printmemstats(stderr);
82 + #endif
83          devclose();
84          exit(code);
85   }
# Line 95 | Line 101 | char  *dname;
101                                  error(USER, errmsg);
102                          } else
103                                  return;
104 + #ifndef NIX                                                
105                                                  /* not there, try exec */
106          if ((dev = comm_init(dname, id)) == NULL) {
107                  sprintf(errmsg, "cannot start device \"%s\"", dname);
108                  error(USER, errmsg);
109          }
110 + #endif
111   }
112  
113  
# Line 172 | Line 180 | freereserves()                 /* free memory reserves */
180   command(prompt)                 /* get/execute command */
181   char  *prompt;
182   {
183 < #define  badcom(s)      strncmp(s, inpbuf, args-inpbuf-1)
183 > #define  badcom(s)      strncmp(s, inpbuf, args-inpbuf-1)
184          char  inpbuf[256];
185          char  *args;
186   again:
# Line 183 | Line 191 | again:
191          else *++args = '\0';
192          
193          switch (inpbuf[0]) {
194 <        case 'f':                               /* new frame */
195 <                if (badcom("frame"))
196 <                        goto commerr;
194 >        case 'f':                               /* new frame (or free mem.) */
195 >                if (badcom("frame")) {
196 >                        if (badcom("free"))
197 >                                goto commerr;
198 >                        free_objmem();
199 >                        break;
200 >                }
201                  getframe(args);
202                  break;
203          case 'v':                               /* view */
# Line 198 | Line 210 | again:
210                          goto commerr;
211                  lastview(args);
212                  break;
213 +        case 'V':                               /* save view */
214 +                if (badcom("V"))
215 +                        goto commerr;
216 +                saveview(args);
217 +                break;
218 +        case 'L':                               /* load view */
219 +                if (badcom("L"))
220 +                        goto commerr;
221 +                loadview(args);
222 +                break;
223          case 'e':                               /* exposure */
224                  if (badcom("exposure"))
225                          goto commerr;
226                  getexposure(args);
227                  break;
228          case 's':                               /* set a parameter */
229 <                if (badcom("set"))
229 >                if (badcom("set")) {
230 > #ifdef  SIGTSTP
231 >                        if (!badcom("stop"))
232 >                                goto dostop;
233 > #endif
234                          goto commerr;
235 +                }
236                  setparam(args);
237                  break;
238          case 'n':                               /* new picture */
# Line 223 | Line 250 | again:
250                          goto commerr;
251                  getaim(args);
252                  break;
253 <        case 'm':                               /* move camera */
253 >        case 'm':                               /* move camera (or memstats) */
254                  if (badcom("move"))
255 < #ifdef  MSTATS
255 > #ifdef  MSTATS
256                  {
257                          if (badcom("memory"))
258                                  goto commerr;
# Line 239 | Line 266 | again:
266                  break;
267          case 'r':                               /* rotate/repaint */
268                  if (badcom("rotate")) {
269 <                        if (badcom("repaint"))
270 <                                goto commerr;
269 >                        if (badcom("repaint")) {
270 >                                if (badcom("redraw"))
271 >                                        goto commerr;
272 >                                redraw();
273 >                                break;
274 >                        }
275                          getrepaint(args);
276                          break;
277                  }
278                  getrotate(args);
279                  break;
280          case 'p':                               /* pivot view */
281 <                if (badcom("pivot"))
282 <                        goto commerr;
281 >                if (badcom("pivot")) {
282 >                        if (badcom("pause"))
283 >                                goto commerr;
284 >                        goto again;
285 >                }
286                  getpivot(args);
287                  break;
288          case CTRL('R'):                         /* redraw */
# Line 265 | Line 299 | again:
299                  quit(0);
300          case CTRL('C'):                         /* interrupt */
301                  goto again;
302 < #ifdef  SIGTSTP
303 <        case CTRL('Z'):                         /* stop */
302 > #ifdef  SIGTSTP
303 >        case CTRL('Z'):;                        /* stop */
304 > dostop:
305                  devclose();
306                  kill(0, SIGTSTP);
307                  /* pc stops here */
# Line 286 | Line 321 | commerr:
321                  error(COMMAND, errmsg);
322                  break;
323          }
324 < #undef  badcom
324 > #undef  badcom
325   }
326  
327  
# Line 296 | Line 331 | rsample()                      /* sample the image */
331          RECT  r;
332          PNODE  *p;
333          register RECT  *rl;
334 <        register PNODE  **pl;
334 >        register PNODE  **pl;
335          register int  x;
336          /*
337           *     We initialize the bottom row in the image at our current
338 <         * resolution.  During sampling, we check super-pixels to the
338 >         * resolution.  During sampling, we check super-pixels to the
339           * right and above by calling bigdiff().  If there is a significant
340           * difference, we subsample the super-pixels.  The testing process
341           * includes initialization of the next row.
342           */
343 <        xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
344 <        ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
343 >        xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
344 >        ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
345          rl = (RECT *)malloc(xsiz*sizeof(RECT));
346          if (rl == NULL)
347                  return;
348          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
349 <        if (pl == NULL)
349 >        if (pl == NULL) {
350 >                free((char *)rl);
351                  return;
352 +        }
353          /*
354           * Initialize the bottom row.
355           */
# Line 378 | Line 415 | escape:
415  
416   int
417   refine(p, xmin, ymin, xmax, ymax, pd)           /* refine a node */
418 < register PNODE  *p;
418 > register PNODE  *p;
419   int  xmin, ymin, xmax, ymax;
420   int  pd;
421   {
# Line 402 | Line 439 | int  pd;
439                          return(0);
440                  /*
441                   *  The following paint order can leave a black pixel
442 <                 *  when redraw() is called in (*dev->paintr)().
442 >                 *  if redraw() is called in (*dev->paintr)().
443                   */
444                  if (p->x >= mx && p->y >= my)
445                          pcopy(p, p->kid+UR);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines