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.11 by greg, Wed Oct 5 17:20:55 2011 UTC vs.
Revision 2.23 by greg, Tue Apr 22 17:12:25 2025 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12  
13   #include  "platform.h"
14   #include  "ray.h"
15 + #include  "func.h"
16   #include  "source.h"
17   #include  "ambient.h"
18   #include  "rpaint.h"
19   #include  "random.h"
20   #include  "paths.h"
21   #include  "view.h"
22 + #include  "pmapray.h"
23  
24   extern char  *progname;                 /* global argv[0] */
25  
# Line 54 | Line 56 | static void onsig(int  signo);
56   static void sigdie(int  signo, char  *msg);
57   static void printdefaults(void);
58  
59 + static void
60 + set_defaults(void)
61 + {
62 +        shadthresh = .1;
63 +        shadcert = .25;
64 +        directrelay = 0;
65 +        vspretest = 128;
66 +        srcsizerat = 0.;
67 +        specthresh = .3;
68 +        specjitter = 1.;
69 +        maxdepth = 6;
70 +        minweight = 1e-3;
71 +        ambacc = 0.3;
72 +        ambres = 32;
73 +        ambdiv = 256;
74 +        ambssamp = 64;
75 + }
76  
77   int
78   main(int argc, char *argv[])
# Line 61 | Line 80 | main(int argc, char *argv[])
80   #define  check(ol,al)           if (argv[i][ol] || \
81                                  badarg(argc-i-1,argv+i+1,al)) \
82                                  goto badopt
83 < #define  bool(olen,var)         switch (argv[i][olen]) { \
83 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
84                                  case '\0': var = !var; break; \
85                                  case 'y': case 'Y': case 't': case 'T': \
86                                  case '+': case '1': var = 1; break; \
# Line 75 | Line 94 | main(int argc, char *argv[])
94                                          /* global program name */
95          progname = argv[0] = fixargv0(argv[0]);
96                                          /* set our defaults */
97 <        shadthresh = .1;
98 <        shadcert = .25;
99 <        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;
97 >        set_defaults();
98 >                                        /* initialize calcomp routines */
99 >        initfunc();
100                                          /* option city */
101          for (i = 1; i < argc; i++) {
102                                                  /* expand arguments */
# Line 147 | Line 156 | main(int argc, char *argv[])
156                          }
157                          break;
158                  case 'b':                               /* grayscale */
159 <                        bool(2,greyscale);
159 >                        check_bool(2,greyscale);
160                          break;
161                  case 'p':                               /* pixel */
162                          switch (argv[i][2]) {
# Line 171 | Line 180 | main(int argc, char *argv[])
180                          break;
181                  case 'w':                               /* warnings */
182                          rval = erract[WARNING].pf != NULL;
183 <                        bool(2,rval);
183 >                        check_bool(2,rval);
184                          if (rval) erract[WARNING].pf = wputs;
185                          else erract[WARNING].pf = NULL;
186                          break;
# Line 191 | Line 200 | main(int argc, char *argv[])
200                          goto badopt;
201                  }
202          }
203 +                                        /* set/check spectral sampling */
204 +        if (setspectrsamp(CNDX, WLPART) <= 0)
205 +                error(USER, "unsupported spectral sampling");
206 +
207          err = setview(&ourview);        /* set viewing parameters */
208          if (err != NULL)
209                  error(USER, err);
210                                                  /* set up signal handling */
211          sigdie(SIGINT, "Interrupt");
212          sigdie(SIGTERM, "Terminate");
213 < #ifndef _WIN32
213 > #if !defined(_WIN32) && !defined(_WIN64)
214          sigdie(SIGHUP, "Hangup");
215          sigdie(SIGPIPE, "Broken pipe");
216          sigdie(SIGALRM, "Alarm clock");
# Line 227 | Line 240 | main(int argc, char *argv[])
240                                          /* set up output & start process(es) */
241          SET_FILE_BINARY(stdout);
242          
243 <        ray_init(octnm);
244 <
243 >        ray_init(octnm);                /* also calls ray_init_pmap() */
244 >        
245 > /* temporary shortcut, until winrview is refactored into a "device" */
246 > #ifndef WIN_RVIEW
247          rview();                        /* run interactive viewer */
248  
249 +
250          devclose();                     /* close output device */
251 + #endif
252  
253 +        /* PMAP: free photon maps */
254 +        ray_done_pmap();
255 +        
256 + #ifdef WIN_RVIEW
257 +        return 1;
258 + #endif
259          quit(0);
260  
261   badopt:
# Line 241 | Line 264 | badopt:
264          return 1; /* pro forma return */
265  
266   #undef  check
267 < #undef  bool
267 > #undef  check_bool
268   }
269  
270  
271   void
272   wputs(                          /* warning output function */
273 <        char    *s
273 >        const char      *s
274   )
275   {
276          int  lasterrno = errno;
277 +        if (erract[WARNING].pf == NULL)
278 +                return;         /* called by calcomp or someone */
279          eputs(s);
280          errno = lasterrno;
281   }
# Line 258 | Line 283 | wputs(                         /* warning output function */
283  
284   void
285   eputs(                          /* put string to stderr */
286 <        char  *s
286 >        const char  *s
287   )
288   {
289          static int  midline = 0;
# Line 287 | Line 312 | onsig(                         /* fatal signal */
312          if (gotsig++)                   /* two signals and we're gone! */
313                  _exit(signo);
314  
315 < #ifndef _WIN32
315 > #if !defined(_WIN32) && !defined(_WIN64)
316          alarm(15);                      /* allow 15 seconds to clean up */
317          signal(SIGALRM, SIG_DFL);       /* make certain we do die */
318   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines