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.8 by greg, Mon Sep 21 12:08:00 1992 UTC vs.
Revision 2.21 by greg, Wed Jul 2 01:15:20 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  rview.c - routines and variables for interactive view generation.
6   *
7 < *     3/24/87
7 > *  External symbols declared in rpaint.h
8   */
9  
10 < #include  "ray.h"
10 > #include "copyright.h"
11  
15 #include  "rpaint.h"
16
12   #include  <signal.h>
18
13   #include  <ctype.h>
14  
15 < VIEW  ourview = STDVIEW;                /* viewing parameters */
16 < int  hresolu, vresolu;                  /* image resolution */
15 > #include  "platform.h"
16 > #include  "ray.h"
17 > #include  "rpaint.h"
18  
19 +
20 + CUBE  thescene;                         /* our scene */
21 + OBJECT  nsceneobjs;                     /* number of objects in our scene */
22 +
23   int  dimlist[MAXDIM];                   /* sampling dimensions */
24   int  ndims = 0;                         /* number of sampling dimensions */
25   int  samplendx = 0;                     /* index for this sample */
26  
27 + extern void  ambnotify();
28 + void  (*addobjnotify[])() = {ambnotify, NULL};
29 +
30 + VIEW  ourview = STDVIEW;                /* viewing parameters */
31 + int  hresolu, vresolu;                  /* image resolution */
32 +
33 + void  (*trace)() = NULL;                /* trace call */
34 +
35 + int  do_irrad = 0;                      /* compute irradiance? */
36 +
37   int  psample = 8;                       /* pixel sample size */
38   double  maxdiff = .15;                  /* max. sample difference */
39  
# Line 35 | Line 44 | double shadthresh = .1;                /* shadow threshold */
44   double  shadcert = .25;                 /* shadow certainty */
45   int  directrelay = 0;                   /* number of source relays */
46   int  vspretest = 128;                   /* virtual source pretest density */
47 < int  directinvis = 0;                   /* sources invisible? */
47 > int  directvis = 1;                     /* sources visible? */
48   double  srcsizerat = 0.;                /* maximum ratio source size/dist. */
49  
50 + COLOR  cextinction = BLKCOLOR;          /* global extinction coefficient */
51 + COLOR  salbedo = BLKCOLOR;              /* global scattering albedo */
52 + double  seccg = 0.;                     /* global scattering eccentricity */
53 + double  ssampdist = 0.;                 /* scatter sampling distance */
54 +
55   double  specthresh = .3;                /* specular sampling threshold */
56   double  specjitter = 1.;                /* specular sampling jitter */
57  
58 + int  backvis = 1;                       /* back face visibility */
59 +
60   int  maxdepth = 4;                      /* maximum recursion depth */
61   double  minweight = 1e-2;               /* minimum ray weight */
62  
63 + char  *ambfile = NULL;                  /* ambient file name */
64   COLOR  ambval = BLKCOLOR;               /* ambient value */
65 + int  ambvwt = 0;                        /* initial weight for ambient value */
66   double  ambacc = 0.2;                   /* ambient accuracy */
67   int  ambres = 8;                        /* ambient resolution */
68   int  ambdiv = 32;                       /* ambient divisions */
# Line 54 | Line 72 | char  *amblist[128];                   /* ambient include/exclude list
72   int  ambincl = -1;                      /* include == 1, exclude == 0 */
73  
74   int  greyscale = 0;                     /* map colors to brightness? */
75 < char  *devname = dev_default;           /* output device name */
75 > char  *dvcname = dev_default;           /* output device name */
76  
77   struct driver  *dev = NULL;             /* driver functions */
78  
79 + char  rifname[128];                     /* rad input file name */
80 +
81   VIEW  oldview;                          /* previous view parameters */
82  
83   PNODE  ptrunk;                          /* the base of our image */
# Line 71 | Line 91 | static char  *reserve_mem = NULL;      /* pre-allocated res
91   #define  CTRL(c)        ((c)-'@')
92  
93  
94 + void
95   quit(code)                      /* quit program */
96   int  code;
97   {
98 + #ifdef MSTATS
99 +        if (code == 2 && errno == ENOMEM)
100 +                printmemstats(stderr);
101 + #endif
102          devclose();
103          exit(code);
104   }
105  
106  
107 + void
108   devopen(dname)                          /* open device driver */
109   char  *dname;
110   {
# Line 95 | Line 121 | char  *dname;
121                                  error(USER, errmsg);
122                          } else
123                                  return;
98 #ifndef NIX                                                
124                                                  /* not there, try exec */
125          if ((dev = comm_init(dname, id)) == NULL) {
126                  sprintf(errmsg, "cannot start device \"%s\"", dname);
127                  error(USER, errmsg);
128          }
104 #endif
129   }
130  
131  
132 + void
133   devclose()                              /* close our device */
134   {
135          if (dev != NULL)
# Line 113 | Line 138 | devclose()                             /* close our device */
138   }
139  
140  
141 + void
142   printdevices()                          /* print list of output devices */
143   {
144          register int  i;
# Line 122 | Line 148 | printdevices()                         /* print list of output devices */
148   }
149  
150  
151 + void
152   rview()                         /* do a view */
153   {
154          char  buf[32];
155  
156 <        devopen(devname);               /* open device */
156 >        devopen(dvcname);               /* open device */
157          newimage();                     /* start image (calls fillreserves) */
158  
159          for ( ; ; ) {                   /* quit in command() */
# Line 154 | Line 181 | rview()                                /* do a view */
181   }
182  
183  
184 + void
185   fillreserves()                  /* fill memory reserves */
186   {
187          if (reserve_mem != NULL)
188                  return;
189 <        reserve_mem = malloc(RESERVE_AMT);
189 >        reserve_mem = (char *)malloc(RESERVE_AMT);
190   }
191  
192  
193 + void
194   freereserves()                  /* free memory reserves */
195   {
196          if (reserve_mem == NULL)
# Line 171 | Line 200 | freereserves()                 /* free memory reserves */
200   }
201  
202  
203 + void
204   command(prompt)                 /* get/execute command */
205   char  *prompt;
206   {
# Line 185 | Line 215 | again:
215          else *++args = '\0';
216          
217          switch (inpbuf[0]) {
218 <        case 'f':                               /* new frame */
219 <                if (badcom("frame"))
220 <                        goto commerr;
218 >        case 'f':                               /* new frame (or free mem.) */
219 >                if (badcom("frame")) {
220 >                        if (badcom("free"))
221 >                                goto commerr;
222 >                        free_objmem();
223 >                        break;
224 >                }
225                  getframe(args);
226                  break;
227          case 'v':                               /* view */
# Line 200 | Line 234 | again:
234                          goto commerr;
235                  lastview(args);
236                  break;
237 +        case 'V':                               /* save view */
238 +                if (badcom("V"))
239 +                        goto commerr;
240 +                saveview(args);
241 +                break;
242 +        case 'L':                               /* load view */
243 +                if (badcom("L"))
244 +                        goto commerr;
245 +                loadview(args);
246 +                break;
247          case 'e':                               /* exposure */
248                  if (badcom("exposure"))
249                          goto commerr;
250                  getexposure(args);
251                  break;
252          case 's':                               /* set a parameter */
253 <                if (badcom("set"))
253 >                if (badcom("set")) {
254 > #ifdef  SIGTSTP
255 >                        if (!badcom("stop"))
256 >                                goto dostop;
257 > #endif
258                          goto commerr;
259 +                }
260                  setparam(args);
261                  break;
262          case 'n':                               /* new picture */
# Line 225 | Line 274 | again:
274                          goto commerr;
275                  getaim(args);
276                  break;
277 <        case 'm':                               /* move camera */
277 >        case 'm':                               /* move camera (or memstats) */
278                  if (badcom("move"))
279   #ifdef  MSTATS
280                  {
# Line 241 | Line 290 | again:
290                  break;
291          case 'r':                               /* rotate/repaint */
292                  if (badcom("rotate")) {
293 <                        if (badcom("repaint"))
294 <                                goto commerr;
293 >                        if (badcom("repaint")) {
294 >                                if (badcom("redraw"))
295 >                                        goto commerr;
296 >                                redraw();
297 >                                break;
298 >                        }
299                          getrepaint(args);
300                          break;
301                  }
302                  getrotate(args);
303                  break;
304          case 'p':                               /* pivot view */
305 <                if (badcom("pivot"))
306 <                        goto commerr;
305 >                if (badcom("pivot")) {
306 >                        if (badcom("pause"))
307 >                                goto commerr;
308 >                        goto again;
309 >                }
310                  getpivot(args);
311                  break;
312          case CTRL('R'):                         /* redraw */
# Line 268 | Line 324 | again:
324          case CTRL('C'):                         /* interrupt */
325                  goto again;
326   #ifdef  SIGTSTP
327 <        case CTRL('Z'):                         /* stop */
327 >        case CTRL('Z'):;                        /* stop */
328 > dostop:
329                  devclose();
330                  kill(0, SIGTSTP);
331                  /* pc stops here */
332 <                devopen(devname);
332 >                devopen(dvcname);
333                  redraw();
334                  break;
335   #endif
# Line 292 | Line 349 | commerr:
349   }
350  
351  
352 + void
353   rsample()                       /* sample the image */
354   {
355          int  xsiz, ysiz, y;
# Line 307 | Line 365 | rsample()                      /* sample the image */
365           * difference, we subsample the super-pixels.  The testing process
366           * includes initialization of the next row.
367           */
368 <        xsiz = (((pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
369 <        ysiz = (((pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
368 >        xsiz = (((long)(pframe.r-pframe.l)<<pdepth)+hresolu-1) / hresolu;
369 >        ysiz = (((long)(pframe.u-pframe.d)<<pdepth)+vresolu-1) / vresolu;
370          rl = (RECT *)malloc(xsiz*sizeof(RECT));
371          if (rl == NULL)
372                  return;
373          pl = (PNODE **)malloc(xsiz*sizeof(PNODE *));
374          if (pl == NULL) {
375 <                free((char *)rl);
375 >                free((void *)rl);
376                  return;
377          }
378          /*
# Line 375 | Line 433 | rsample()                      /* sample the image */
433                  }
434          }
435   escape:
436 <        free((char *)rl);
437 <        free((char *)pl);
436 >        free((void *)rl);
437 >        free((void *)pl);
438   }
439  
440  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines