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

Comparing ray/src/rt/rvmain.c (file contents):
Revision 2.1 by greg, Sat Feb 22 02:07:29 2003 UTC vs.
Revision 2.10 by greg, Sat Dec 12 19:01:00 2009 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   *  rvmain.c - main for rview interactive viewer
6   */
7  
8 < /* ====================================================================
9 < * The Radiance Software License, Version 1.0
10 < *
11 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
12 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
13 < *
14 < * Redistribution and use in source and binary forms, with or without
15 < * modification, are permitted provided that the following conditions
16 < * are met:
17 < *
18 < * 1. Redistributions of source code must retain the above copyright
19 < *         notice, this list of conditions and the following disclaimer.
20 < *
21 < * 2. Redistributions in binary form must reproduce the above copyright
22 < *       notice, this list of conditions and the following disclaimer in
23 < *       the documentation and/or other materials provided with the
24 < *       distribution.
25 < *
26 < * 3. The end-user documentation included with the redistribution,
27 < *           if any, must include the following acknowledgment:
28 < *             "This product includes Radiance software
29 < *                 (http://radsite.lbl.gov/)
30 < *                 developed by the Lawrence Berkeley National Laboratory
31 < *               (http://www.lbl.gov/)."
32 < *       Alternately, this acknowledgment may appear in the software itself,
33 < *       if and wherever such third-party acknowledgments normally appear.
34 < *
35 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
36 < *       and "The Regents of the University of California" must
37 < *       not be used to endorse or promote products derived from this
38 < *       software without prior written permission. For written
39 < *       permission, please contact [email protected].
40 < *
41 < * 5. Products derived from this software may not be called "Radiance",
42 < *       nor may "Radiance" appear in their name, without prior written
43 < *       permission of Lawrence Berkeley National Laboratory.
44 < *
45 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
46 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
47 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
49 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
52 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
53 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
54 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
55 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 < * SUCH DAMAGE.
57 < * ====================================================================
58 < *
59 < * This software consists of voluntary contributions made by many
60 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
61 < * information on Lawrence Berkeley National Laboratory, please see
62 < * <http://www.lbl.gov/>.
63 < */
8 > #include "copyright.h"
9  
10 < #include  "ray.h"
10 > #include  <signal.h>
11 > #include  <time.h>
12  
13 + #include  "platform.h"
14 + #include  "ray.h"
15   #include  "source.h"
68
16   #include  "ambient.h"
17 <
17 > #include  "rpaint.h"
18   #include  "random.h"
72
19   #include  "paths.h"
20 + #include  "view.h"
21  
22 < #include  <signal.h>
22 > extern char  *progname;                 /* global argv[0] */
23  
24 < #include  "view.h"
24 > VIEW  ourview = STDVIEW;                /* viewing parameters */
25 > int  hresolu, vresolu;                  /* image resolution */
26  
27 < char  *progname;                        /* argv[0] */
27 > int  psample = 8;                       /* pixel sample size */
28 > double  maxdiff = .15;                  /* max. sample difference */
29  
30 < char  *octname;                         /* octree name */
30 > int  greyscale = 0;                     /* map colors to brightness? */
31 > char  *dvcname = dev_default;           /* output device name */
32  
33 < char  *sigerr[NSIG];                    /* signal error messages */
33 > double  exposure = 1.0;                 /* exposure for scene */
34  
35 < char  *shm_boundary = NULL;             /* boundary of shared memory */
35 > int  newparam = 1;                      /* parameter setting changed */
36 >
37 > struct driver  *dev = NULL;             /* driver functions */
38  
39 < char  *errfile = NULL;                  /* error output file */
39 > char  rifname[128];                     /* rad input file name */
40  
41 < extern int  greyscale;                  /* map colors to brightness? */
90 < extern char  *dvcname;                  /* output device name */
91 < extern double  exposure;                /* exposure compensation */
41 > VIEW  oldview;                          /* previous view parameters */
42  
43 < extern VIEW  ourview;                   /* viewing parameters */
43 > PNODE  ptrunk;                          /* the base of our image */
44 > RECT  pframe;                           /* current frame boundaries */
45 > int  pdepth;                            /* image depth in current frame */
46  
47 < extern char  rifname[];                 /* rad input file name */
47 > char  *errfile = NULL;                  /* error output file */
48  
49 < extern int  hresolu;                    /* horizontal resolution */
98 < extern int  vresolu;                    /* vertical resolution */
49 > int  nproc = 1;                         /* number of processes */
50  
51 < extern int  psample;                    /* pixel sample size */
101 < extern double  maxdiff;                 /* max. sample difference */
51 > char  *sigerr[NSIG];                    /* signal error messages */
52  
53 < void    onsig();
54 < void    sigdie();
55 < void    printdefaults();
53 > static void onsig(int  signo);
54 > static void sigdie(int  signo, char  *msg);
55 > static void printdefaults(void);
56  
57  
58   int
59 < main(argc, argv)
110 < int  argc;
111 < char  *argv[];
59 > main(int argc, char *argv[])
60   {
61   #define  check(ol,al)           if (argv[i][ol] || \
62                                  badarg(argc-i-1,argv+i+1,al)) \
# Line 120 | Line 68 | char  *argv[];
68                                  case 'n': case 'N': case 'f': case 'F': \
69                                  case '-': case '0': var = 0; break; \
70                                  default: goto badopt; }
71 +        char  *octnm = NULL;
72          char  *err;
73          int  rval;
74          int  i;
75                                          /* global program name */
76          progname = argv[0] = fixargv0(argv[0]);
77 +                                        /* set our defaults */
78 +        shadthresh = .1;
79 +        shadcert = .25;
80 +        directrelay = 0;
81 +        vspretest = 128;
82 +        srcsizerat = 0.;
83 +        specthresh = .3;
84 +        specjitter = 1.;
85 +        maxdepth = 6;
86 +        minweight = 1e-2;
87 +        ambacc = 0.3;
88 +        ambres = 32;
89 +        ambdiv = 256;
90 +        ambssamp = 64;
91                                          /* option city */
92          for (i = 1; i < argc; i++) {
93                                                  /* expand arguments */
# Line 160 | Line 123 | char  *argv[];
123                          continue;
124                  }
125                  switch (argv[i][1]) {
126 +                case 'n':                               /* # processes */
127 +                        check(2,"i");
128 +                        nproc = atoi(argv[++i]);
129 +                        if (nproc <= 0)
130 +                                error(USER, "bad number of processes");
131 +                        break;
132                  case 'v':                               /* view file */
133                          if (argv[i][2] != 'f')
134                                  goto badopt;
# Line 225 | Line 194 | char  *argv[];
194          err = setview(&ourview);        /* set viewing parameters */
195          if (err != NULL)
196                  error(USER, err);
197 <                                        /* initialize object types */
229 <        initotypes();
230 <                                        /* initialize urand */
231 <        initurand(2048);
232 <                                        /* set up signal handling */
197 >                                                /* set up signal handling */
198          sigdie(SIGINT, "Interrupt");
199          sigdie(SIGHUP, "Hangup");
200          sigdie(SIGTERM, "Terminate");
201          sigdie(SIGPIPE, "Broken pipe");
202          sigdie(SIGALRM, "Alarm clock");
238 #ifdef  SIGXCPU
239        sigdie(SIGXCPU, "CPU limit exceeded");
240        sigdie(SIGXFSZ, "File size exceeded");
241 #endif
203                                          /* open error file */
204          if (errfile != NULL) {
205                  if (freopen(errfile, "a", stderr) == NULL)
# Line 254 | Line 215 | char  *argv[];
215   #endif
216                                          /* get octree */
217          if (i == argc)
218 <                octname = NULL;
218 >                octnm = NULL;
219          else if (i == argc-1)
220 <                octname = argv[i];
220 >                octnm = argv[i];
221          else
222                  goto badopt;
223 <        if (octname == NULL)
223 >        if (octnm == NULL)
224                  error(USER, "missing octree argument");
225 <                                        /* set up output */
226 < #ifdef  MSDOS
227 <        setmode(fileno(stdout), O_BINARY);
228 < #endif
268 <        readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL);
269 <        nsceneobjs = nobjects;
225 >                                        /* set up output & start process(es) */
226 >        SET_FILE_BINARY(stdout);
227 >        
228 >        ray_init(octnm);
229  
271        marksources();                  /* find and mark sources */
272
273        setambient();                   /* initialize ambient calculation */
274
230          rview();                        /* run interactive viewer */
231  
232 <        ambsync();                      /* flush ambient file */
232 >        devclose();                     /* close output device */
233  
234          quit(0);
235  
236   badopt:
237          sprintf(errmsg, "command line error at '%s'", argv[i]);
238          error(USER, errmsg);
239 +        return 1; /* pro forma return */
240  
241   #undef  check
242   #undef  bool
# Line 288 | Line 244 | badopt:
244  
245  
246   void
247 < wputs(s)                                /* warning output function */
248 < char    *s;
247 > wputs(                          /* warning output function */
248 >        char    *s
249 > )
250   {
251          int  lasterrno = errno;
252          eputs(s);
# Line 298 | Line 255 | char   *s;
255  
256  
257   void
258 < eputs(s)                                /* put string to stderr */
259 < register char  *s;
258 > eputs(                          /* put string to stderr */
259 >        char  *s
260 > )
261   {
262          static int  midline = 0;
263  
# Line 317 | Line 275 | register char  *s;
275   }
276  
277  
278 < void
279 < onsig(signo)                            /* fatal signal */
280 < int  signo;
278 > static void
279 > onsig(                          /* fatal signal */
280 >        int  signo
281 > )
282   {
283          static int  gotsig = 0;
284  
# Line 331 | Line 290 | int  signo;
290          eputs("signal - ");
291          eputs(sigerr[signo]);
292          eputs("\n");
293 +        devclose();
294          quit(3);
295   }
296  
297  
298 < void
299 < sigdie(signo, msg)                      /* set fatal signal */
300 < int  signo;
301 < char  *msg;
298 > static void
299 > sigdie(                 /* set fatal signal */
300 >        int  signo,
301 >        char  *msg
302 > )
303   {
304          if (signal(signo, onsig) == SIG_IGN)
305                  signal(signo, SIG_IGN);
# Line 346 | Line 307 | char  *msg;
307   }
308  
309  
310 < void
311 < printdefaults()                 /* print default values to stdout */
310 > static void
311 > printdefaults(void)                     /* print default values to stdout */
312   {
313 <        register char  *cp;
353 <
313 >        printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
314          printf(greyscale ? "-b+\t\t\t\t# greyscale on\n" :
315                          "-b-\t\t\t\t# greyscale off\n");
316          printf("-vt%c\t\t\t\t# view type %s\n", ourview.type,
# Line 359 | Line 319 | printdefaults()                        /* print default values to stdout */
319                          ourview.type==VT_HEM ? "hemispherical" :
320                          ourview.type==VT_ANG ? "angular" :
321                          ourview.type==VT_CYL ? "cylindrical" :
322 +                        ourview.type==VT_PLS ? "planisphere" :
323                          "unknown");
324          printf("-vp %f %f %f\t# view point\n",
325                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines