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.21 by greg, Sun Sep 26 15:51:15 2010 UTC vs.
Revision 2.39 by greg, Wed Oct 19 23:10:34 2022 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 61 | Line 66 | static void onsig(int  signo);
66   static void sigdie(int  signo, char  *msg);
67   static void printdefaults(void);
68  
69 + #ifdef PERSIST
70 + #define RTRACE_FEATURES "Persist\nParallelPersist\nMultiProcessing\n" \
71 +                        "IrradianceCalc\nImmediateIrradiance\nDistanceLimiting\n" \
72 +                        "HessianAmbientCache\nAmbientAveraging\n" \
73 +                        "AmbientValueSharing\nAdaptiveShadowTesting\n"
74 + #else
75 + #define RTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \
76 +                        "HessianAmbientCache\nAmbientAveraging\n" \
77 +                        "AmbientValueSharing\nAdaptiveShadowTesting\n"
78 + #endif
79  
80 +
81   int
82   main(int  argc, char  *argv[])
83   {
84   #define  check(ol,al)           if (argv[i][ol] || \
85                                  badarg(argc-i-1,argv+i+1,al)) \
86                                  goto badopt
87 < #define  bool(olen,var)         switch (argv[i][olen]) { \
87 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
88                                  case '\0': var = !var; break; \
89                                  case 'y': case 'Y': case 't': case 'T': \
90                                  case '+': case '1': var = 1; break; \
91                                  case 'n': case 'N': case 'f': case 'F': \
92                                  case '-': case '0': var = 0; break; \
93                                  default: goto badopt; }
94 +        extern char  *octname;
95          int  persist = 0;
96          char  *octnm = NULL;
97 <        char  **tralp;
98 <        int  duped1;
97 >        char  **tralp = NULL;
98 >        int  duped1 = -1;
99          int  rval;
100          int  i;
101                                          /* global program name */
102          progname = argv[0] = fixargv0(argv[0]);
103 +                                        /* feature check only? */
104 +        strcat(RFeatureList, RTRACE_FEATURES);
105 +        if (!strcmp(argv[1], "-features"))
106 +                return feature_status(argc-2, argv+2);
107                                          /* add trace notify function */
108          for (i = 0; addobjnotify[i] != NULL; i++)
109                  ;
110          addobjnotify[i] = tranotify;
90                                        /* set our defaults */
91        rand_samp = 1;
92        maxdepth = -10;
93        minweight = 2e-3;
111                                          /* option city */
112          for (i = 1; i < argc; i++) {
113                                                  /* expand arguments */
# Line 133 | Line 150 | main(int  argc, char  *argv[])
150                          break;
151                  case 'w':                               /* warnings */
152                          rval = erract[WARNING].pf != NULL;
153 <                        bool(2,rval);
153 >                        check_bool(2,rval);
154                          if (rval) erract[WARNING].pf = wputs;
155                          else erract[WARNING].pf = NULL;
156                          break;
# Line 144 | Line 161 | main(int  argc, char  *argv[])
161                  case 'l':                               /* limit distance */
162                          if (argv[i][2] != 'd')
163                                  goto badopt;
164 <                        bool(3,lim_dist);
164 >                        check_bool(3,lim_dist);
165                          break;
166                  case 'I':                               /* immed. irradiance */
167 <                        bool(2,imm_irrad);
167 >                        check_bool(2,imm_irrad);
168                          break;
169                  case 'f':                               /* format i/o */
170                          switch (argv[i][2]) {
# Line 179 | Line 196 | main(int  argc, char  *argv[])
196                          break;
197                  case 'h':                               /* header output */
198                          rval = loadflags & IO_INFO;
199 <                        bool(2,rval);
199 >                        check_bool(2,rval);
200                          loadflags = rval ? loadflags | IO_INFO :
201                                          loadflags & ~IO_INFO;
202                          break;
# Line 193 | Line 210 | main(int  argc, char  *argv[])
210                                          tralp = tralist;
211                                  }
212                                  if (argv[i][2] == 'I') {        /* file */
213 <                                        rval = wordfile(tralp,
213 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
214                                          getpath(argv[++i],getrlibpath(),R_OK));
215                                          if (rval < 0) {
216                                                  sprintf(errmsg,
# Line 215 | Line 232 | main(int  argc, char  *argv[])
232                                          tralp = tralist;
233                                  }
234                                  if (argv[i][2] == 'E') {        /* file */
235 <                                        rval = wordfile(tralp,
235 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
236                                          getpath(argv[++i],getrlibpath(),R_OK));
237                                          if (rval < 0) {
238                                                  sprintf(errmsg,
# Line 249 | Line 266 | main(int  argc, char  *argv[])
266                          goto badopt;
267                  }
268          }
269 <        if (nproc > 1) {
270 <                if (persist)
254 <                        error(USER, "multiprocessing incompatible with persist file");
255 <                if (!vresolu && hresolu > 0 && hresolu < nproc)
256 <                        error(WARNING, "number of cores should not exceed horizontal resolution");
257 <                if (trace != NULL)
258 <                        error(WARNING, "multiprocessing does not work properly with trace mode");
259 <        }
269 >        if (nproc > 1 && persist)
270 >                error(USER, "multiprocessing incompatible with persist file");
271                                          /* initialize object types */
272          initotypes();
273                                          /* initialize urand */
# Line 314 | Line 325 | main(int  argc, char  *argv[])
325   #endif
326          if (outform != 'a')
327                  SET_FILE_BINARY(stdout);
328 <        readoct(octnm, loadflags, &thescene, NULL);
328 >        rval = setrtoutput();
329 >        readoct(octname = octnm, loadflags, &thescene, NULL);
330          nsceneobjs = nobjects;
331  
332          if (loadflags & IO_INFO) {      /* print header */
333                  printargs(i, argv, stdout);
334                  printf("SOFTWARE= %s\n", VersionID);
335                  fputnow(stdout);
336 +                if (rval > 0)           /* saved from setrtoutput() call */
337 +                        printf("NCOMP=%d\n", rval);
338 +                if ((outform == 'f') | (outform == 'd'))
339 +                        fputendian(stdout);
340                  fputformat(formstr(outform), stdout);
341                  putchar('\n');
342          }
343  
344 <        marksources();                  /* find and mark sources */
344 >        if (!castonly) {        /* any actual ray traversal to do? */
345  
346 <        setambient();                   /* initialize ambient calculation */
346 >                ray_init_pmap();        /* PMAP: set up & load photon maps */
347 >                
348 >                marksources();          /* find and mark sources */
349  
350 +                setambient();           /* initialize ambient calculation */
351 +        } else
352 +                distantsources();       /* else mark only distant sources */
353 +
354 +        fflush(stdout);                 /* in case we're duplicating header */
355 +
356   #ifdef  PERSIST
357          if (persist) {
334                fflush(stdout);
358                                                  /* reconnect stdout */
359                  dup2(duped1, fileno(stdout));
360                  close(duped1);
# Line 374 | Line 397 | runagain:
397                  goto runagain;
398          }
399   #endif
400 +
401 +        ray_done_pmap();           /* PMAP: free photon maps */
402 +        
403          quit(0);
404  
405   badopt:
# Line 382 | Line 408 | badopt:
408          return 1; /* pro forma return */
409  
410   #undef  check
411 < #undef  bool
411 > #undef  check_bool
412   }
413  
414  
# Line 399 | Line 425 | wputs(                         /* warning output function */
425  
426   void
427   eputs(                          /* put string to stderr */
428 <        register char  *s
428 >        char  *s
429   )
430   {
431          static int  midline = 0;
# Line 454 | Line 480 | sigdie(                        /* set fatal signal */
480   static void
481   printdefaults(void)                     /* print default values to stdout */
482   {
483 <        register char  *cp;
483 >        char  *cp;
484  
485          if (imm_irrad)
486                  printf("-I+\t\t\t\t# immediate irradiance on\n");
# Line 474 | Line 500 | printdefaults(void)                    /* print default values to stdou
500                  case 't': case 'T': printf(" trace"); break;
501                  case 'o': printf(" origin"); break;
502                  case 'd': printf(" direction"); break;
503 +                case 'r': printf(" reflect_contrib"); break;
504 +                case 'R': printf(" reflect_length"); break;
505 +                case 'x': printf(" unreflect_contrib"); break;
506 +                case 'X': printf(" unreflect_length"); break;
507                  case 'v': printf(" value"); break;
508                  case 'V': printf(" contribution"); break;
509                  case 'l': printf(" length"); break;
# Line 486 | Line 516 | printdefaults(void)                    /* print default values to stdou
516                  case 'W': printf(" coefficient"); break;
517                  case 'm': printf(" modifier"); break;
518                  case 'M': printf(" material"); break;
519 <                case '-': printf(" stroke"); break;
519 >                case '~': printf(" tilde"); break;
520                  }
521          putchar('\n');
522          printf(erract[WARNING].pf != NULL ?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines