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.8 by greg, Tue Mar 11 02:21:47 2008 UTC vs.
Revision 2.17 by greg, Thu Aug 18 00:52:48 2016 UTC

# Line 18 | Line 18 | static const char      RCSid[] = "$Id$";
18   #include  "random.h"
19   #include  "paths.h"
20   #include  "view.h"
21 + #include  "pmapray.h"
22  
23 < char  *progname;                        /* argv[0] */
23 > extern char  *progname;                 /* global argv[0] */
24  
25 < char  *octname;                         /* octree name */
25 > VIEW  ourview = STDVIEW;                /* viewing parameters */
26 > int  hresolu, vresolu;                  /* image resolution */
27  
28 < char  *sigerr[NSIG];                    /* signal error messages */
28 > int  psample = 8;                       /* pixel sample size */
29 > double  maxdiff = .15;                  /* max. sample difference */
30  
31 < char  *shm_boundary = NULL;             /* boundary of shared memory */
31 > int  greyscale = 0;                     /* map colors to brightness? */
32 > char  *dvcname = dev_default;           /* output device name */
33  
34 < char  *errfile = NULL;                  /* error output file */
34 > double  exposure = 1.0;                 /* exposure for scene */
35  
36 < extern int  greyscale;                  /* map colors to brightness? */
37 < extern char  *dvcname;                  /* output device name */
38 < extern double  exposure;                /* exposure compensation */
36 > int  newparam = 1;                      /* parameter setting changed */
37 >
38 > struct driver  *dev = NULL;             /* driver functions */
39  
40 < extern VIEW  ourview;                   /* viewing parameters */
40 > char  rifname[128];                     /* rad input file name */
41  
42 < extern char  rifname[];                 /* rad input file name */
42 > VIEW  oldview;                          /* previous view parameters */
43  
44 < extern int  hresolu;                    /* horizontal resolution */
45 < extern int  vresolu;                    /* vertical resolution */
44 > PNODE  ptrunk;                          /* the base of our image */
45 > RECT  pframe;                           /* current frame boundaries */
46 > int  pdepth;                            /* image depth in current frame */
47  
48 < extern int  psample;                    /* pixel sample size */
44 < extern double  maxdiff;                 /* max. sample difference */
48 > char  *errfile = NULL;                  /* error output file */
49  
50 + int  nproc = 1;                         /* number of processes */
51 +
52 + char  *sigerr[NSIG];                    /* signal error messages */
53 +
54   static void onsig(int  signo);
55   static void sigdie(int  signo, char  *msg);
56   static void printdefaults(void);
57  
50
58   int
59 < main(int  argc, 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)) \
63                                  goto badopt
64 < #define  bool(olen,var)         switch (argv[i][olen]) { \
64 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
65                                  case '\0': var = !var; break; \
66                                  case 'y': case 'Y': case 't': case 'T': \
67                                  case '+': case '1': var = 1; break; \
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 101 | Line 123 | main(int  argc, 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 119 | Line 147 | main(int  argc, char  *argv[])
147                          }
148                          break;
149                  case 'b':                               /* grayscale */
150 <                        bool(2,greyscale);
150 >                        check_bool(2,greyscale);
151                          break;
152                  case 'p':                               /* pixel */
153                          switch (argv[i][2]) {
# Line 143 | Line 171 | main(int  argc, char  *argv[])
171                          break;
172                  case 'w':                               /* warnings */
173                          rval = erract[WARNING].pf != NULL;
174 <                        bool(2,rval);
174 >                        check_bool(2,rval);
175                          if (rval) erract[WARNING].pf = wputs;
176                          else erract[WARNING].pf = NULL;
177                          break;
# Line 166 | Line 194 | main(int  argc, char  *argv[])
194          err = setview(&ourview);        /* set viewing parameters */
195          if (err != NULL)
196                  error(USER, err);
197 <                                        /* initialize object types */
170 <        initotypes();
171 <                                        /* initialize urand */
172 <        if (rand_samp) {
173 <                srandom((long)time(0));
174 <                initurand(0);
175 <        } else {
176 <                srandom(0L);
177 <                initurand(2048);
178 <        }
179 <                                        /* set up signal handling */
197 >                                                /* set up signal handling */
198          sigdie(SIGINT, "Interrupt");
181        sigdie(SIGHUP, "Hangup");
199          sigdie(SIGTERM, "Terminate");
200 + #if !defined(_WIN32) && !defined(_WIN64)
201 +        sigdie(SIGHUP, "Hangup");
202          sigdie(SIGPIPE, "Broken pipe");
203          sigdie(SIGALRM, "Alarm clock");
185 #ifdef  SIGXCPU
186        sigdie(SIGXCPU, "CPU limit exceeded");
187        sigdie(SIGXFSZ, "File size exceeded");
204   #endif
205                                          /* open error file */
206          if (errfile != NULL) {
# Line 201 | Line 217 | main(int  argc, char  *argv[])
217   #endif
218                                          /* get octree */
219          if (i == argc)
220 <                octname = NULL;
220 >                octnm = NULL;
221          else if (i == argc-1)
222 <                octname = argv[i];
222 >                octnm = argv[i];
223          else
224                  goto badopt;
225 <        if (octname == NULL)
225 >        if (octnm == NULL)
226                  error(USER, "missing octree argument");
227 <                                        /* set up output */
227 >                                        /* set up output & start process(es) */
228          SET_FILE_BINARY(stdout);
229 <        readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL);
230 <        nsceneobjs = nobjects;
231 <
232 <        marksources();                  /* find and mark sources */
233 <
218 <        setambient();                   /* initialize ambient calculation */
219 <
229 >        
230 >        ray_init(octnm);                /* also calls ray_init_pmap() */
231 >        
232 > /* temporary shortcut, until winrview is refactored into a "device" */
233 > #ifndef WIN_RVIEW
234          rview();                        /* run interactive viewer */
235  
222        ambsync();                      /* flush ambient file */
236  
237 +        devclose();                     /* close output device */
238 + #endif
239 +
240 +        /* PMAP: free photon maps */
241 +        ray_done_pmap();
242 +        
243 + #ifdef WIN_RVIEW
244 +        return 1;
245 + #endif
246          quit(0);
247  
248   badopt:
# Line 229 | Line 251 | badopt:
251          return 1; /* pro forma return */
252  
253   #undef  check
254 < #undef  bool
254 > #undef  check_bool
255   }
256  
257  
# Line 246 | Line 268 | wputs(                         /* warning output function */
268  
269   void
270   eputs(                          /* put string to stderr */
271 <        register char  *s
271 >        char  *s
272   )
273   {
274          static int  midline = 0;
# Line 275 | Line 297 | onsig(                         /* fatal signal */
297          if (gotsig++)                   /* two signals and we're gone! */
298                  _exit(signo);
299  
300 + #if !defined(_WIN32) && !defined(_WIN64)
301          alarm(15);                      /* allow 15 seconds to clean up */
302          signal(SIGALRM, SIG_DFL);       /* make certain we do die */
303 + #endif
304          eputs("signal - ");
305          eputs(sigerr[signo]);
306          eputs("\n");
307 +        devclose();
308          quit(3);
309   }
310  
# Line 299 | Line 324 | sigdie(                        /* set fatal signal */
324   static void
325   printdefaults(void)                     /* print default values to stdout */
326   {
327 +        printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
328          printf(greyscale ? "-b+\t\t\t\t# greyscale on\n" :
329                          "-b-\t\t\t\t# greyscale off\n");
330          printf("-vt%c\t\t\t\t# view type %s\n", ourview.type,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines