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.9 by greg, Thu Aug 21 07:05:59 2008 UTC vs.
Revision 2.24 by greg, Wed Apr 23 02:35:26 2025 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   extern char  *progname;                 /* global argv[0] */
24  
# Line 54 | Line 55 | static void onsig(int  signo);
55   static void sigdie(int  signo, char  *msg);
56   static void printdefaults(void);
57  
58 + static void
59 + set_defaults(void)
60 + {
61 +        shadthresh = .1;
62 +        shadcert = .25;
63 +        directrelay = 0;
64 +        vspretest = 128;
65 +        srcsizerat = 0.;
66 +        specthresh = .3;
67 +        specjitter = 1.;
68 +        maxdepth = 6;
69 +        minweight = 1e-3;
70 +        ambacc = 0.3;
71 +        ambres = 32;
72 +        ambdiv = 256;
73 +        ambssamp = 64;
74 + }
75  
76   int
77   main(int argc, char *argv[])
# Line 61 | Line 79 | main(int argc, char *argv[])
79   #define  check(ol,al)           if (argv[i][ol] || \
80                                  badarg(argc-i-1,argv+i+1,al)) \
81                                  goto badopt
82 < #define  bool(olen,var)         switch (argv[i][olen]) { \
82 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
83                                  case '\0': var = !var; break; \
84                                  case 'y': case 'Y': case 't': case 'T': \
85                                  case '+': case '1': var = 1; break; \
# Line 75 | Line 93 | main(int argc, char *argv[])
93                                          /* global program name */
94          progname = argv[0] = fixargv0(argv[0]);
95                                          /* set our defaults */
96 <        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;
96 >        set_defaults();
97                                          /* option city */
98          for (i = 1; i < argc; i++) {
99                                                  /* expand arguments */
# Line 147 | Line 153 | main(int argc, char *argv[])
153                          }
154                          break;
155                  case 'b':                               /* grayscale */
156 <                        bool(2,greyscale);
156 >                        check_bool(2,greyscale);
157                          break;
158                  case 'p':                               /* pixel */
159                          switch (argv[i][2]) {
# Line 171 | Line 177 | main(int argc, char *argv[])
177                          break;
178                  case 'w':                               /* warnings */
179                          rval = erract[WARNING].pf != NULL;
180 <                        bool(2,rval);
180 >                        check_bool(2,rval);
181                          if (rval) erract[WARNING].pf = wputs;
182                          else erract[WARNING].pf = NULL;
183                          break;
# Line 191 | Line 197 | main(int argc, char *argv[])
197                          goto badopt;
198                  }
199          }
200 +                                        /* set/check spectral sampling */
201 +        if (setspectrsamp(CNDX, WLPART) <= 0)
202 +                error(USER, "unsupported spectral sampling");
203 +
204          err = setview(&ourview);        /* set viewing parameters */
205          if (err != NULL)
206                  error(USER, err);
207                                                  /* set up signal handling */
208          sigdie(SIGINT, "Interrupt");
199        sigdie(SIGHUP, "Hangup");
209          sigdie(SIGTERM, "Terminate");
210 + #if !defined(_WIN32) && !defined(_WIN64)
211 +        sigdie(SIGHUP, "Hangup");
212          sigdie(SIGPIPE, "Broken pipe");
213          sigdie(SIGALRM, "Alarm clock");
214 + #endif
215                                          /* open error file */
216          if (errfile != NULL) {
217                  if (freopen(errfile, "a", stderr) == NULL)
# Line 225 | Line 237 | main(int argc, char *argv[])
237                                          /* set up output & start process(es) */
238          SET_FILE_BINARY(stdout);
239          
240 <        ray_pinit(octnm, 0);
241 <
240 >        ray_init(octnm);                /* also calls ray_init_pmap() */
241 >        
242 > /* temporary shortcut, until winrview is refactored into a "device" */
243 > #ifndef WIN_RVIEW
244          rview();                        /* run interactive viewer */
245  
246 +
247          devclose();                     /* close output device */
248 + #endif
249  
250 +        /* PMAP: free photon maps */
251 +        ray_done_pmap();
252 +        
253 + #ifdef WIN_RVIEW
254 +        return 1;
255 + #endif
256          quit(0);
257  
258   badopt:
# Line 239 | Line 261 | badopt:
261          return 1; /* pro forma return */
262  
263   #undef  check
264 < #undef  bool
264 > #undef  check_bool
265   }
266  
267  
268   void
269   wputs(                          /* warning output function */
270 <        char    *s
270 >        const char      *s
271   )
272   {
273          int  lasterrno = errno;
274 +        if (erract[WARNING].pf == NULL)
275 +                return;         /* called by calcomp or someone */
276          eputs(s);
277          errno = lasterrno;
278   }
# Line 256 | Line 280 | wputs(                         /* warning output function */
280  
281   void
282   eputs(                          /* put string to stderr */
283 <        char  *s
283 >        const char  *s
284   )
285   {
286          static int  midline = 0;
# Line 285 | Line 309 | onsig(                         /* fatal signal */
309          if (gotsig++)                   /* two signals and we're gone! */
310                  _exit(signo);
311  
312 + #if !defined(_WIN32) && !defined(_WIN64)
313          alarm(15);                      /* allow 15 seconds to clean up */
314          signal(SIGALRM, SIG_DFL);       /* make certain we do die */
315 + #endif
316          eputs("signal - ");
317          eputs(sigerr[signo]);
318          eputs("\n");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines