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

Comparing ray/src/rt/rtmain.c (file contents):
Revision 2.20 by greg, Sun Dec 13 19:39:51 2009 UTC vs.
Revision 2.33 by greg, Mon Apr 6 21:09:07 2020 UTC

# Line 17 | Line 17 | static const char      RCSid[] = "$Id$";
17   #include  "ambient.h"
18   #include  "random.h"
19   #include  "paths.h"
20 + #include  "pmapray.h"
21  
22   extern char     *progname;              /* global argv[0] */
23  
# Line 34 | Line 35 | char  *errfile = NULL;                 /* error output file */
35  
36   int  nproc = 1;                         /* number of processes */
37  
38 < extern char  *formstr();                /* string from format */
38 > extern char  *formstr(int f);           /* string from format */
39 > extern int  setrtoutput(void);          /* set output values */
40 >
41   int  inform = 'a';                      /* input format */
42   int  outform = 'a';                     /* output format */
43   char  *outvals = "v";                   /* output specification */
# Line 42 | Line 45 | char  *outvals = "v";                  /* output specification */
45   int  hresolu = 0;                       /* horizontal (scan) size */
46   int  vresolu = 0;                       /* vertical resolution */
47  
48 + extern int  castonly;                   /* only doing ray-casting? */
49 +
50   int  imm_irrad = 0;                     /* compute immediate irradiance? */
51   int  lim_dist = 0;                      /* limit distance? */
52  
# Line 68 | Line 73 | main(int  argc, char  *argv[])
73   #define  check(ol,al)           if (argv[i][ol] || \
74                                  badarg(argc-i-1,argv+i+1,al)) \
75                                  goto badopt
76 < #define  bool(olen,var)         switch (argv[i][olen]) { \
76 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
77                                  case '\0': var = !var; break; \
78                                  case 'y': case 'Y': case 't': case 'T': \
79                                  case '+': case '1': var = 1; break; \
80                                  case 'n': case 'N': case 'f': case 'F': \
81                                  case '-': case '0': var = 0; break; \
82                                  default: goto badopt; }
83 +        extern char  *octname;
84          int  persist = 0;
85          char  *octnm = NULL;
86 <        char  **tralp;
87 <        int  duped1;
86 >        char  **tralp = NULL;
87 >        int  duped1 = -1;
88          int  rval;
89          int  i;
90                                          /* global program name */
# Line 87 | Line 93 | main(int  argc, char  *argv[])
93          for (i = 0; addobjnotify[i] != NULL; i++)
94                  ;
95          addobjnotify[i] = tranotify;
90                                        /* set our defaults */
91        rand_samp = 1;
92        maxdepth = -10;
93        minweight = 2e-3;
96                                          /* option city */
97          for (i = 1; i < argc; i++) {
98                                                  /* expand arguments */
# Line 133 | Line 135 | main(int  argc, char  *argv[])
135                          break;
136                  case 'w':                               /* warnings */
137                          rval = erract[WARNING].pf != NULL;
138 <                        bool(2,rval);
138 >                        check_bool(2,rval);
139                          if (rval) erract[WARNING].pf = wputs;
140                          else erract[WARNING].pf = NULL;
141                          break;
# Line 144 | Line 146 | main(int  argc, char  *argv[])
146                  case 'l':                               /* limit distance */
147                          if (argv[i][2] != 'd')
148                                  goto badopt;
149 <                        bool(3,lim_dist);
149 >                        check_bool(3,lim_dist);
150                          break;
151                  case 'I':                               /* immed. irradiance */
152 <                        bool(2,imm_irrad);
152 >                        check_bool(2,imm_irrad);
153                          break;
154                  case 'f':                               /* format i/o */
155                          switch (argv[i][2]) {
# Line 179 | Line 181 | main(int  argc, char  *argv[])
181                          break;
182                  case 'h':                               /* header output */
183                          rval = loadflags & IO_INFO;
184 <                        bool(2,rval);
184 >                        check_bool(2,rval);
185                          loadflags = rval ? loadflags | IO_INFO :
186                                          loadflags & ~IO_INFO;
187                          break;
# Line 193 | Line 195 | main(int  argc, char  *argv[])
195                                          tralp = tralist;
196                                  }
197                                  if (argv[i][2] == 'I') {        /* file */
198 <                                        rval = wordfile(tralp,
198 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
199                                          getpath(argv[++i],getrlibpath(),R_OK));
200                                          if (rval < 0) {
201                                                  sprintf(errmsg,
# Line 215 | Line 217 | main(int  argc, char  *argv[])
217                                          tralp = tralist;
218                                  }
219                                  if (argv[i][2] == 'E') {        /* file */
220 <                                        rval = wordfile(tralp,
220 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
221                                          getpath(argv[++i],getrlibpath(),R_OK));
222                                          if (rval < 0) {
223                                                  sprintf(errmsg,
# Line 252 | Line 254 | main(int  argc, char  *argv[])
254          if (nproc > 1) {
255                  if (persist)
256                          error(USER, "multiprocessing incompatible with persist file");
257 <                if (hresolu > 0 && hresolu < nproc)
257 >                if (!vresolu && hresolu > 0 && hresolu < nproc)
258                          error(WARNING, "number of cores should not exceed horizontal resolution");
259                  if (trace != NULL)
260                          error(WARNING, "multiprocessing does not work properly with trace mode");
# Line 314 | Line 316 | main(int  argc, char  *argv[])
316   #endif
317          if (outform != 'a')
318                  SET_FILE_BINARY(stdout);
319 <        readoct(octnm, loadflags, &thescene, NULL);
319 >        rval = setrtoutput();
320 >        readoct(octname = octnm, loadflags, &thescene, NULL);
321          nsceneobjs = nobjects;
322  
323          if (loadflags & IO_INFO) {      /* print header */
324                  printargs(i, argv, stdout);
325                  printf("SOFTWARE= %s\n", VersionID);
326                  fputnow(stdout);
327 +                if (rval > 0)           /* saved from setrtoutput() call */
328 +                        printf("NCOMP=%d\n", rval);
329 +                if ((outform == 'f') | (outform == 'd'))
330 +                        fputendian(stdout);
331                  fputformat(formstr(outform), stdout);
332                  putchar('\n');
333          }
334  
335 <        marksources();                  /* find and mark sources */
335 >        if (!castonly) {        /* any actual ray traversal to do? */
336  
337 <        setambient();                   /* initialize ambient calculation */
337 >                ray_init_pmap();        /* PMAP: set up & load photon maps */
338 >                
339 >                marksources();          /* find and mark sources */
340  
341 +                setambient();           /* initialize ambient calculation */
342 +        } else
343 +                distantsources();       /* else mark only distant sources */
344   #ifdef  PERSIST
345          if (persist) {
346                  fflush(stdout);
# Line 374 | Line 386 | runagain:
386                  goto runagain;
387          }
388   #endif
389 +
390 +        ray_done_pmap();           /* PMAP: free photon maps */
391 +        
392          quit(0);
393  
394   badopt:
# Line 382 | Line 397 | badopt:
397          return 1; /* pro forma return */
398  
399   #undef  check
400 < #undef  bool
400 > #undef  check_bool
401   }
402  
403  
# Line 459 | Line 474 | printdefaults(void)                    /* print default values to stdou
474          if (imm_irrad)
475                  printf("-I+\t\t\t\t# immediate irradiance on\n");
476          printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
477 <        printf("-x %-9d\t\t\t# x resolution (flush interval)\n", hresolu);
477 >        printf("-x %-9d\t\t\t# %s\n", hresolu,
478 >                        vresolu && hresolu ? "x resolution" : "flush interval");
479          printf("-y %-9d\t\t\t# y resolution\n", vresolu);
480          printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" :
481                          "-ld-\t\t\t\t# limit distance off\n");
# Line 473 | Line 489 | printdefaults(void)                    /* print default values to stdou
489                  case 't': case 'T': printf(" trace"); break;
490                  case 'o': printf(" origin"); break;
491                  case 'd': printf(" direction"); break;
492 +                case 'r': printf(" reflect_contrib"); break;
493 +                case 'R': printf(" reflect_length"); break;
494 +                case 'x': printf(" unreflect_contrib"); break;
495 +                case 'X': printf(" unreflect_length"); break;
496                  case 'v': printf(" value"); break;
497                  case 'V': printf(" contribution"); break;
498                  case 'l': printf(" length"); break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines