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.15 by schorsch, Thu Mar 10 18:25:46 2016 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 44 | Line 46 | int    lim_dist = 0;                   /* limit distance? */
46   const char      *modname[MAXMODLIST];   /* ordered modifier name list */
47   int             nmods = 0;              /* number of modifiers */
48  
49 < char    RCCONTEXT[] = "RCONTRIB";       /* our special evaluation context */
49 > void    (*addobjnotify[8])() = {ambnotify, NULL};
50  
51 < void    (*addobjnotify[8])() = {ambnotify, tranotify, NULL};
51 > char    RCCONTEXT[] = "RC";             /* our special evaluation context */
52  
53  
54   static void
55   printdefaults(void)                     /* print default values to stdout */
56   {
55        char  *cp;
56
57          printf("-c %-5d\t\t\t# accumulated rays per record\n", accumulate);
58          printf("-V%c\t\t\t\t# output %s\n", contrib ? '+' : '-',
59                          contrib ? "contributions" : "coefficients");
# Line 163 | Line 163 | main(int argc, char *argv[])
163   #define  check(ol,al)           if (argv[i][ol] || \
164                                  badarg(argc-i-1,argv+i+1,al)) \
165                                  goto badopt
166 < #define  bool(olen,var)         switch (argv[i][olen]) { \
166 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
167                                  case '\0': var = !var; break; \
168                                  case 'y': case 'Y': case 't': case 'T': \
169                                  case '+': case '1': var = 1; break; \
170                                  case 'n': case 'N': case 'f': case 'F': \
171                                  case '-': case '0': var = 0; break; \
172                                  default: goto badopt; }
173        int     nprocs = 1;
173          char    *curout = NULL;
174 +        char    *prms = NULL;
175          char    *binval = NULL;
176          int     bincnt = 0;
177          int     rval;
# Line 217 | Line 217 | main(int argc, char *argv[])
217                                  error(USER, "bad number of processes");
218                          break;
219                  case 'V':                       /* output contributions */
220 <                        bool(2,contrib);
220 >                        check_bool(2,contrib);
221                          break;
222                  case 'x':                       /* x resolution */
223                          check(2,"i");
# Line 229 | Line 229 | main(int argc, char *argv[])
229                          break;
230                  case 'w':                       /* warnings */
231                          rval = (erract[WARNING].pf != NULL);
232 <                        bool(2,rval);
232 >                        check_bool(2,rval);
233                          if (rval) erract[WARNING].pf = wputs;
234                          else erract[WARNING].pf = NULL;
235                          break;
# Line 240 | Line 240 | main(int argc, char *argv[])
240                  case 'l':                       /* limit distance */
241                          if (argv[i][2] != 'd')
242                                  goto badopt;
243 <                        bool(3,lim_dist);
243 >                        check_bool(3,lim_dist);
244                          break;
245                  case 'I':                       /* immed. irradiance */
246 <                        bool(2,imm_irrad);
246 >                        check_bool(2,imm_irrad);
247                          break;
248                  case 'f':                       /* file or force or format */
249                          if (!argv[i][2]) {
# Line 252 | Line 252 | main(int argc, char *argv[])
252                                  break;
253                          }
254                          if (argv[i][2] == 'o') {
255 <                                bool(3,force_open);
255 >                                check_bool(3,force_open);
256                                  break;
257                          }
258                          setformat(argv[i]+2);
# Line 266 | Line 266 | main(int argc, char *argv[])
266                          accumulate = atoi(argv[++i]);
267                          break;
268                  case 'r':                       /* recover output */
269 <                        bool(2,recover);
269 >                        check_bool(2,recover);
270                          break;
271                  case 'h':                       /* header output */
272 <                        bool(2,header);
272 >                        check_bool(2,header);
273                          break;
274 +                case 'p':                       /* parameter setting(s) */
275 +                        check(2,"s");
276 +                        set_eparams(prms = argv[++i]);
277 +                        break;
278                  case 'b':                       /* bin expression/count */
279                          if (argv[i][2] == 'n') {
280                                  check(3,"s");
# Line 282 | Line 286 | main(int argc, char *argv[])
286                          break;
287                  case 'm':                       /* modifier name */
288                          check(2,"s");
289 <                        addmodifier(argv[++i], curout, binval, bincnt);
289 >                        addmodifier(argv[++i], curout, prms, binval, bincnt);
290                          break;
291                  case 'M':                       /* modifier file */
292                          check(2,"s");
293 <                        addmodfile(argv[++i], curout, binval, bincnt);
293 >                        addmodfile(argv[++i], curout, prms, binval, bincnt);
294                          break;
295                  default:
296                          goto badopt;
297                  }
298          }
299 +        if (nmods <= 0)
300 +                error(USER, "missing required modifier argument");
301                                          /* override some option settings */
302          override_options();
303                                          /* initialize object types */
# Line 336 | Line 342 | main(int argc, char *argv[])
342          readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL);
343          nsceneobjs = nobjects;
344  
345 +        /* PMAP: set up & load photon maps */
346 +        ray_init_pmap();    
347 +        
348          marksources();                  /* find and mark sources */
349 +        
350 +        /* PMAP: init photon map for light source contributions */
351 +        initPmapContrib(&modconttab, nmods);
352  
353          setambient();                   /* initialize ambient calculation */
354 <
354 >        
355          rcontrib();                     /* trace ray contributions (loop) */
356  
357          ambsync();                      /* flush ambient file */
358  
359 +        /* PMAP: free photon maps */
360 +        ray_done_pmap();    
361 +        
362          quit(0);        /* exit clean */
363  
364   badopt:
365          fprintf(stderr,
366 < "Usage: %s [-n nprocs][-V][-r][-e expr][-f source][-o ospec][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n",
366 > "Usage: %s [-n nprocs][-V][-r][-e expr][-f source][-o ospec][-p p1=V1,p2=V2][-b binv][-bn N] {-m mod | -M file} [rtrace options] octree\n",
367                          progname);
368          sprintf(errmsg, "command line error at '%s'", argv[i]);
369          error(USER, errmsg);
370          return(1);      /* pro forma return */
371  
372   #undef  check
373 < #undef  bool
373 > #undef  check_bool
374   }
375  
376  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines