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

Comparing ray/src/rt/rcmain.c (file contents):
Revision 2.4 by greg, Fri Jun 15 00:57:40 2012 UTC vs.
Revision 2.42 by greg, Thu Jun 5 18:26:46 2025 UTC

# Line 8 | Line 8 | static const char      RCSid[] = "$Id$";
8   #include "copyright.h"
9  
10   #include <signal.h>
11 + #include <time.h>
12   #include "rcontrib.h"
13 < #include "platform.h"
13 < #include "paths.h"
13 > #include "random.h"
14   #include "source.h"
15   #include "ambient.h"
16 + #include "pmapray.h"
17 + #include "pmapcontrib.h"
18  
19   int     gargc;                          /* global argc */
20   char    **gargv;                        /* global argv */
21   char    *octname;                       /* global octree name */
20 char    *progname;                      /* global argv[0] */
22  
23   char    *sigerr[NSIG];                  /* signal error messages */
24  
# Line 41 | Line 42 | int    using_stdout = 0;               /* are we using stdout? */
42   int     imm_irrad = 0;                  /* compute immediate irradiance? */
43   int     lim_dist = 0;                   /* limit distance? */
44  
45 < const char      *modname[MAXMODLIST];   /* ordered modifier name list */
45 < int             nmods = 0;              /* number of modifiers */
45 > int     report_intvl = 0;               /* reporting interval (seconds) */
46  
47 + char    **modname = NULL;               /* ordered modifier name list */
48 + int     nmods = 0;                      /* number of modifiers */
49 + int     modasiz = 0;                    /* allocated modifier array size */
50 +
51   void    (*addobjnotify[8])() = {ambnotify, NULL};
52  
53 < char    RCCONTEXT[] = "RCONTRIB";       /* our special evaluation context */
53 > char    RCCONTEXT[] = "RC.";            /* our special evaluation context */
54  
55 + #if defined(_WIN32) || defined(_WIN64)
56 + #define RCONTRIB_FEATURES       "Accumulation\nSummation\nRecovery\n" \
57 +                                "ImmediateIrradiance\n" \
58 +                                "ProgressReporting\nDistanceLimiting\n" \
59 +                                "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
60 +                                "Outputs=V,W\n" \
61 +                                "OutputCS=RGB,spec\n"
62 + #else
63 + #define RCONTRIB_FEATURES       "Multiprocessing\n" \
64 +                                "Accumulation\nSummation\nRecovery\n" \
65 +                                "ImmediateIrradiance\n" \
66 +                                "ProgressReporting\nDistanceLimiting\n" \
67 +                                "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
68 +                                "Outputs=V,W\n" \
69 +                                "OutputCS=RGB,spec\n"
70 + #endif
71  
72   static void
73   printdefaults(void)                     /* print default values to stdout */
74   {
55        char  *cp;
56
75          printf("-c %-5d\t\t\t# accumulated rays per record\n", accumulate);
76          printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-',
77                          contrib ? "contributions" : "coefficients");
# Line 65 | Line 83 | printdefaults(void)                    /* print default values to stdou
83          printf("-y %-9d\t\t\t# y resolution\n", yres);
84          printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" :
85                          "-ld-\t\t\t\t# limit distance off\n");
86 <        printf("-h%c\t\t\t\t# %s header\n", header ? '+' : '-',
87 <                        header ? "output" : "no");
86 >        printf(header ? "-h+\t\t\t\t# output header\n" :
87 >                        "-h-\t\t\t\t# no header\n");
88          printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n",
89                          inpfmt, outfmt, formstr(inpfmt), formstr(outfmt));
90 +        if (report_intvl > 0)
91 +                printf("-t %-9d\t\t\t#  time between reports\n", report_intvl);
92          printf(erract[WARNING].pf != NULL ?
93                          "-w+\t\t\t\t# warning messages on\n" :
94                          "-w-\t\t\t\t# warning messages off\n");
# Line 163 | Line 183 | main(int argc, char *argv[])
183   #define  check(ol,al)           if (argv[i][ol] || \
184                                  badarg(argc-i-1,argv+i+1,al)) \
185                                  goto badopt
186 < #define  bool(olen,var)         switch (argv[i][olen]) { \
186 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
187                                  case '\0': var = !var; break; \
188                                  case 'y': case 'Y': case 't': case 'T': \
189                                  case '+': case '1': var = 1; break; \
190                                  case 'n': case 'N': case 'f': case 'F': \
191                                  case '-': case '0': var = 0; break; \
192                                  default: goto badopt; }
173        int     nprocs = 1;
193          char    *curout = NULL;
194 +        char    *prms = NULL;
195          char    *binval = NULL;
196          int     bincnt = 0;
197          int     rval;
198          int     i;
199                                          /* global program name */
200 <        progname = argv[0] = fixargv0(argv[0]);
200 >        argv[0] = fixargv0(argv[0]);
201          gargv = argv;
202          gargc = argc;
203 <                                        /* initialize calcomp routines early */
204 <        initfunc();
205 <        setcontext(RCCONTEXT);
203 >                                        /* feature check only? */
204 >        strcat(RFeatureList, RCONTRIB_FEATURES);
205 >        if (argc > 1 && !strcmp(argv[1], "-features"))
206 >                return feature_status(argc-2, argv+2);
207 > #if defined(_WIN32) || defined(_WIN64)  /* increase file limit to maximum */
208 >        for (i = 8192; i > _IOB_ENTRIES; i >>= 1)
209 >                if (_setmaxstdio(i) == i)
210 >                        break;
211 > #endif
212 >        initfunc();                     /* initialize calcomp routines */
213 >        calcontext(RCCONTEXT);
214                                          /* option city */
215          for (i = 1; i < argc; i++) {
216                                                  /* expand arguments */
# Line 217 | Line 245 | main(int argc, char *argv[])
245                                  error(USER, "bad number of processes");
246                          break;
247                  case 'V':                       /* output contributions */
248 <                        bool(2,contrib);
248 >                        check_bool(2,contrib);
249                          break;
250                  case 'x':                       /* x resolution */
251                          check(2,"i");
# Line 229 | Line 257 | main(int argc, char *argv[])
257                          break;
258                  case 'w':                       /* warnings */
259                          rval = (erract[WARNING].pf != NULL);
260 <                        bool(2,rval);
260 >                        check_bool(2,rval);
261                          if (rval) erract[WARNING].pf = wputs;
262                          else erract[WARNING].pf = NULL;
263                          break;
236                case 'e':                       /* expression */
237                        check(2,"s");
238                        scompile(argv[++i], NULL, 0);
239                        break;
264                  case 'l':                       /* limit distance */
265                          if (argv[i][2] != 'd')
266                                  goto badopt;
267 <                        bool(3,lim_dist);
267 >                        check_bool(3,lim_dist);
268                          break;
269                  case 'I':                       /* immed. irradiance */
270 <                        bool(2,imm_irrad);
270 >                        check_bool(2,imm_irrad);
271                          break;
272 <                case 'f':                       /* file or force or format */
249 <                        if (!argv[i][2]) {
250 <                                check(2,"s");
251 <                                loadfunc(argv[++i]);
252 <                                break;
253 <                        }
272 >                case 'f':                       /* force or format */
273                          if (argv[i][2] == 'o') {
274 <                                bool(3,force_open);
274 >                                check_bool(3,force_open);
275                                  break;
276                          }
277                          setformat(argv[i]+2);
# Line 261 | Line 280 | main(int argc, char *argv[])
280                          check(2,"s");
281                          curout = argv[++i];
282                          break;
264                case 'c':                       /* input rays per output */
265                        check(2,"i");
266                        accumulate = atoi(argv[++i]);
267                        break;
283                  case 'r':                       /* recover output */
284 <                        bool(2,recover);
284 >                        check_bool(2,recover);
285                          break;
286                  case 'h':                       /* header output */
287 <                        bool(2,header);
287 >                        check_bool(2,header);
288                          break;
289 +                case 'p':                       /* parameter setting(s) */
290 +                        check(2,"s");
291 +                        set_eparams(prms = argv[++i]);
292 +                        break;
293 +                case 'c':                       /* sample count */
294 +                        check(2,"i");
295 +                        accumulate = atoi(argv[++i]);
296 +                        break;
297                  case 'b':                       /* bin expression/count */
298                          if (argv[i][2] == 'n') {
299                                  check(3,"s");
# Line 282 | Line 305 | main(int argc, char *argv[])
305                          break;
306                  case 'm':                       /* modifier name */
307                          check(2,"s");
308 <                        addmodifier(argv[++i], curout, binval, bincnt);
308 >                        addmodifier(argv[++i], curout, prms, binval, bincnt);
309                          break;
310                  case 'M':                       /* modifier file */
311                          check(2,"s");
312 <                        addmodfile(argv[++i], curout, binval, bincnt);
312 >                        addmodfile(argv[++i], curout, prms, binval, bincnt);
313                          break;
314 +                case 't':                       /* reporting interval */
315 +                        check(2,"i");
316 +                        report_intvl = atoi(argv[++i]);
317 +                        break;
318                  default:
319                          goto badopt;
320                  }
321          }
322 +        if (nmods <= 0)
323 +                error(USER, "missing required modifier argument");
324                                          /* override some option settings */
325          override_options();
326 +                                        /* set/check spectral sampling */
327 +        if (setspectrsamp(CNDX, WLPART) < 0)
328 +                error(USER, "unsupported spectral sampling");
329                                          /* initialize object types */
330          initotypes();
331                                          /* initialize urand */
# Line 336 | Line 368 | main(int argc, char *argv[])
368          readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL);
369          nsceneobjs = nobjects;
370  
371 +        /* PMAP: set up & load photon maps */
372 +        ray_init_pmap();    
373 +        
374          marksources();                  /* find and mark sources */
375 +        
376 +        /* PMAP: init photon map for light source contributions */
377 +        initPmapContrib(&modconttab, nmods);
378  
379          setambient();                   /* initialize ambient calculation */
380 <
380 >        
381          rcontrib();                     /* trace ray contributions (loop) */
382  
383 <        ambsync();                      /* flush ambient file */
384 <
383 >        /* PMAP: free photon maps */
384 >        ray_done_pmap();    
385 >        
386          quit(0);        /* exit clean */
387  
388   badopt:
389          fprintf(stderr,
390 < "Usage: %s [-n nprocs][-V][-r][-e expr][-f source][-o ospec][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n",
390 > "Usage: %s [-n nprocs][-V][-c count][-r][-e expr][-f source][-o ospec][-p p1=V1,p2=V2][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n",
391                          progname);
392          sprintf(errmsg, "command line error at '%s'", argv[i]);
393          error(USER, errmsg);
394          return(1);      /* pro forma return */
395  
396   #undef  check
397 < #undef  bool
397 > #undef  check_bool
398   }
399  
400  
401   void
402   wputs(                          /* warning output function */
403 <        char    *s
403 >        const char      *s
404   )
405   {
406          int  lasterrno = errno;
407 +        if (erract[WARNING].pf == NULL)
408 +                return;         /* called by calcomp or someone */
409          eputs(s);
410          errno = lasterrno;
411   }
# Line 372 | Line 413 | wputs(                         /* warning output function */
413  
414   void
415   eputs(                          /* put string to stderr */
416 <        char  *s
416 >        const char  *s
417   )
418   {
419          static int  midline = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines