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.25 by greg, Sat Jun 7 05:09:46 2025 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines