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

Comparing ray/src/rt/rcmain.c (file contents):
Revision 2.3 by greg, Mon Jun 11 05:07:55 2012 UTC vs.
Revision 2.22 by greg, Wed Oct 19 21:25:20 2022 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 */
# Line 41 | Line 43 | int    using_stdout = 0;               /* are we using stdout? */
43   int     imm_irrad = 0;                  /* compute immediate irradiance? */
44   int     lim_dist = 0;                   /* limit distance? */
45  
46 < const char      *modname[MAXMODLIST];   /* ordered modifier name list */
45 < int             nmods = 0;              /* number of modifiers */
46 > int     report_intvl = 0;               /* reporting interval (seconds) */
47  
48 < char    RCCONTEXT[] = "RCONTRIB";       /* our special evaluation context */
48 > char    **modname = NULL;               /* ordered modifier name list */
49 > int     nmods = 0;                      /* number of modifiers */
50 > int     modasiz = 0;                    /* allocated modifier array size */
51  
52 < void    (*addobjnotify[8])() = {ambnotify, tranotify, NULL};
52 > void    (*addobjnotify[8])() = {ambnotify, NULL};
53  
54 + char    RCCONTEXT[] = "RC.";            /* our special evaluation context */
55  
56 + #if defined(_WIN32) || defined(_WIN64)
57 + #define RCONTRIB_FEATURES       "Accumulation\nSummation\nRAWrecovery\n" \
58 +                                "ValueContribution\nImmediateIrradiance\n" \
59 +                                "ProgressReporting\nDistanceLimiting\n"
60 + #else
61 + #define RCONTRIB_FEATURES       "Multiprocessing\n" \
62 +                                "Accumulation\nSummation\nRAWrecovery\n" \
63 +                                "ValueContribution\nImmediateIrradiance\n" \
64 +                                "ProgressReporting\nDistanceLimiting\n"
65 + #endif
66 +
67   static void
68   printdefaults(void)                     /* print default values to stdout */
69   {
55        char  *cp;
56
70          printf("-c %-5d\t\t\t# accumulated rays per record\n", accumulate);
71          printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-',
72                          contrib ? "contributions" : "coefficients");
# Line 163 | Line 176 | main(int argc, char *argv[])
176   #define  check(ol,al)           if (argv[i][ol] || \
177                                  badarg(argc-i-1,argv+i+1,al)) \
178                                  goto badopt
179 < #define  bool(olen,var)         switch (argv[i][olen]) { \
179 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
180                                  case '\0': var = !var; break; \
181                                  case 'y': case 'Y': case 't': case 'T': \
182                                  case '+': case '1': var = 1; break; \
183                                  case 'n': case 'N': case 'f': case 'F': \
184                                  case '-': case '0': var = 0; break; \
185                                  default: goto badopt; }
173        int     nprocs = 1;
186          char    *curout = NULL;
187 +        char    *prms = NULL;
188          char    *binval = NULL;
189          int     bincnt = 0;
190          int     rval;
# Line 180 | Line 193 | main(int argc, char *argv[])
193          progname = argv[0] = fixargv0(argv[0]);
194          gargv = argv;
195          gargc = argc;
196 +                                        /* feature check only? */
197 +        strcat(RFeatureList, RCONTRIB_FEATURES);
198 +        if (!strcmp(argv[1], "-features"))
199 +                return feature_status(argc-2, argv+2);
200 + #if defined(_WIN32) || defined(_WIN64)
201 +        _setmaxstdio(2048);             /* increase file limit to maximum */
202 + #endif
203                                          /* initialize calcomp routines early */
204          initfunc();
205 <        setcontext(RCCONTEXT);
205 >        calcontext(RCCONTEXT);
206                                          /* option city */
207          for (i = 1; i < argc; i++) {
208                                                  /* expand arguments */
# Line 217 | Line 237 | main(int argc, char *argv[])
237                                  error(USER, "bad number of processes");
238                          break;
239                  case 'V':                       /* output contributions */
240 <                        bool(2,contrib);
240 >                        check_bool(2,contrib);
241                          break;
242                  case 'x':                       /* x resolution */
243                          check(2,"i");
# Line 229 | Line 249 | main(int argc, char *argv[])
249                          break;
250                  case 'w':                       /* warnings */
251                          rval = (erract[WARNING].pf != NULL);
252 <                        bool(2,rval);
252 >                        check_bool(2,rval);
253                          if (rval) erract[WARNING].pf = wputs;
254                          else erract[WARNING].pf = NULL;
255                          break;
# Line 240 | Line 260 | main(int argc, char *argv[])
260                  case 'l':                       /* limit distance */
261                          if (argv[i][2] != 'd')
262                                  goto badopt;
263 <                        bool(3,lim_dist);
263 >                        check_bool(3,lim_dist);
264                          break;
265                  case 'I':                       /* immed. irradiance */
266 <                        bool(2,imm_irrad);
266 >                        check_bool(2,imm_irrad);
267                          break;
268                  case 'f':                       /* file or force or format */
269                          if (!argv[i][2]) {
# Line 252 | Line 272 | main(int argc, char *argv[])
272                                  break;
273                          }
274                          if (argv[i][2] == 'o') {
275 <                                bool(3,force_open);
275 >                                check_bool(3,force_open);
276                                  break;
277                          }
278                          setformat(argv[i]+2);
# Line 266 | Line 286 | main(int argc, char *argv[])
286                          accumulate = atoi(argv[++i]);
287                          break;
288                  case 'r':                       /* recover output */
289 <                        bool(2,recover);
289 >                        check_bool(2,recover);
290                          break;
291                  case 'h':                       /* header output */
292 <                        bool(2,header);
292 >                        check_bool(2,header);
293                          break;
294 +                case 'p':                       /* parameter setting(s) */
295 +                        check(2,"s");
296 +                        set_eparams(prms = argv[++i]);
297 +                        break;
298                  case 'b':                       /* bin expression/count */
299                          if (argv[i][2] == 'n') {
300                                  check(3,"s");
# Line 282 | Line 306 | main(int argc, char *argv[])
306                          break;
307                  case 'm':                       /* modifier name */
308                          check(2,"s");
309 <                        addmodifier(argv[++i], curout, binval, bincnt);
309 >                        addmodifier(argv[++i], curout, prms, binval, bincnt);
310                          break;
311                  case 'M':                       /* modifier file */
312                          check(2,"s");
313 <                        addmodfile(argv[++i], curout, binval, bincnt);
313 >                        addmodfile(argv[++i], curout, prms, binval, bincnt);
314                          break;
315 +                case 't':                       /* reporting interval */
316 +                        check(2,"i");
317 +                        report_intvl = atoi(argv[++i]);
318 +                        break;
319                  default:
320                          goto badopt;
321                  }
322          }
323 +        if (nmods <= 0)
324 +                error(USER, "missing required modifier argument");
325                                          /* override some option settings */
326          override_options();
327                                          /* initialize object types */
# Line 336 | Line 366 | main(int argc, char *argv[])
366          readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL);
367          nsceneobjs = nobjects;
368  
369 +        /* PMAP: set up & load photon maps */
370 +        ray_init_pmap();    
371 +        
372          marksources();                  /* find and mark sources */
373 +        
374 +        /* PMAP: init photon map for light source contributions */
375 +        initPmapContrib(&modconttab, nmods);
376  
377          setambient();                   /* initialize ambient calculation */
378 <
378 >        
379          rcontrib();                     /* trace ray contributions (loop) */
380  
381          ambsync();                      /* flush ambient file */
382  
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines