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.45 by greg, Tue Aug 15 00:46:56 2023 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 int  setrtoutput(void);          /* set output values */
39 >
40   int  inform = 'a';                      /* input format */
41   int  outform = 'a';                     /* output format */
42   char  *outvals = "v";                   /* output specification */
# Line 42 | Line 44 | char  *outvals = "v";                  /* output specification */
44   int  hresolu = 0;                       /* horizontal (scan) size */
45   int  vresolu = 0;                       /* vertical resolution */
46  
47 + extern int  castonly;                   /* only doing ray-casting? */
48 +
49   int  imm_irrad = 0;                     /* compute immediate irradiance? */
50   int  lim_dist = 0;                      /* limit distance? */
51  
# Line 61 | Line 65 | static void onsig(int  signo);
65   static void sigdie(int  signo, char  *msg);
66   static void printdefaults(void);
67  
68 + #ifdef PERSIST
69 + #define RTRACE_FEATURES "Persist\nParallelPersist\nMultiprocessing\n" \
70 +                        "IrradianceCalc\nImmediateIrradiance\nDistanceLimiting\n" \
71 +                        "HessianAmbientCache\nAmbientAveraging\n" \
72 +                        "AmbientValueSharing\nAdaptiveShadowTesting\n" \
73 +                        "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
74 +                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
75 + #else
76 + #define RTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \
77 +                        "HessianAmbientCache\nAmbientAveraging\n" \
78 +                        "AmbientValueSharing\nAdaptiveShadowTesting\n" \
79 +                        "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
80 +                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
81 + #endif
82  
83 +
84   int
85   main(int  argc, char  *argv[])
86   {
87   #define  check(ol,al)           if (argv[i][ol] || \
88                                  badarg(argc-i-1,argv+i+1,al)) \
89                                  goto badopt
90 < #define  bool(olen,var)         switch (argv[i][olen]) { \
90 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
91                                  case '\0': var = !var; break; \
92                                  case 'y': case 'Y': case 't': case 'T': \
93                                  case '+': case '1': var = 1; break; \
94                                  case 'n': case 'N': case 'f': case 'F': \
95                                  case '-': case '0': var = 0; break; \
96                                  default: goto badopt; }
97 +        extern char  *octname;
98          int  persist = 0;
99          char  *octnm = NULL;
100 <        char  **tralp;
101 <        int  duped1;
100 >        char  **tralp = NULL;
101 >        int  duped1 = -1;
102          int  rval;
103          int  i;
104                                          /* global program name */
105          progname = argv[0] = fixargv0(argv[0]);
106 +                                        /* feature check only? */
107 +        strcat(RFeatureList, RTRACE_FEATURES);
108 +        if (argc > 1 && !strcmp(argv[1], "-features"))
109 +                return feature_status(argc-2, argv+2);
110                                          /* add trace notify function */
111          for (i = 0; addobjnotify[i] != NULL; i++)
112                  ;
113          addobjnotify[i] = tranotify;
90                                        /* set our defaults */
91        rand_samp = 1;
92        maxdepth = -10;
93        minweight = 2e-3;
114                                          /* option city */
115          for (i = 1; i < argc; i++) {
116                                                  /* expand arguments */
# Line 133 | Line 153 | main(int  argc, char  *argv[])
153                          break;
154                  case 'w':                               /* warnings */
155                          rval = erract[WARNING].pf != NULL;
156 <                        bool(2,rval);
156 >                        check_bool(2,rval);
157                          if (rval) erract[WARNING].pf = wputs;
158                          else erract[WARNING].pf = NULL;
159                          break;
# Line 144 | Line 164 | main(int  argc, char  *argv[])
164                  case 'l':                               /* limit distance */
165                          if (argv[i][2] != 'd')
166                                  goto badopt;
167 <                        bool(3,lim_dist);
167 >                        check_bool(3,lim_dist);
168                          break;
169                  case 'I':                               /* immed. irradiance */
170 <                        bool(2,imm_irrad);
170 >                        check_bool(2,imm_irrad);
171                          break;
172                  case 'f':                               /* format i/o */
173                          switch (argv[i][2]) {
# Line 179 | Line 199 | main(int  argc, char  *argv[])
199                          break;
200                  case 'h':                               /* header output */
201                          rval = loadflags & IO_INFO;
202 <                        bool(2,rval);
202 >                        check_bool(2,rval);
203                          loadflags = rval ? loadflags | IO_INFO :
204                                          loadflags & ~IO_INFO;
205                          break;
# Line 193 | Line 213 | main(int  argc, char  *argv[])
213                                          tralp = tralist;
214                                  }
215                                  if (argv[i][2] == 'I') {        /* file */
216 <                                        rval = wordfile(tralp,
216 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
217                                          getpath(argv[++i],getrlibpath(),R_OK));
218                                          if (rval < 0) {
219                                                  sprintf(errmsg,
# Line 215 | Line 235 | main(int  argc, char  *argv[])
235                                          tralp = tralist;
236                                  }
237                                  if (argv[i][2] == 'E') {        /* file */
238 <                                        rval = wordfile(tralp,
238 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
239                                          getpath(argv[++i],getrlibpath(),R_OK));
240                                          if (rval < 0) {
241                                                  sprintf(errmsg,
# Line 249 | Line 269 | main(int  argc, char  *argv[])
269                          goto badopt;
270                  }
271          }
272 <        if (nproc > 1) {
273 <                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 <        }
272 >        if (nproc > 1 && persist)
273 >                error(USER, "multiprocessing incompatible with persist file");
274                                          /* initialize object types */
275          initotypes();
276                                          /* initialize urand */
# Line 314 | Line 328 | main(int  argc, char  *argv[])
328   #endif
329          if (outform != 'a')
330                  SET_FILE_BINARY(stdout);
331 <        readoct(octnm, loadflags, &thescene, NULL);
331 >        rval = setrtoutput();
332 >        octname = savqstr(octnm);
333 >        readoct(octname, loadflags, &thescene, NULL);
334          nsceneobjs = nobjects;
335  
336          if (loadflags & IO_INFO) {      /* print header */
337                  printargs(i, argv, stdout);
338                  printf("SOFTWARE= %s\n", VersionID);
339                  fputnow(stdout);
340 +                if (rval > 0)           /* saved from setrtoutput() call */
341 +                        printf("NCOMP=%d\n", rval);
342 +                if ((outform == 'f') | (outform == 'd'))
343 +                        fputendian(stdout);
344                  fputformat(formstr(outform), stdout);
345                  putchar('\n');
346          }
347  
348 <        marksources();                  /* find and mark sources */
348 >        if (!castonly) {        /* any actual ray traversal to do? */
349  
350 <        setambient();                   /* initialize ambient calculation */
350 >                ray_init_pmap();        /* PMAP: set up & load photon maps */
351 >                
352 >                marksources();          /* find and mark sources */
353  
354 +                setambient();           /* initialize ambient calculation */
355 +        } else
356 +                distantsources();       /* else mark only distant sources */
357 +
358 +        fflush(stdout);                 /* in case we're duplicating header */
359 +
360   #ifdef  PERSIST
361          if (persist) {
334                fflush(stdout);
362                                                  /* reconnect stdout */
363                  dup2(duped1, fileno(stdout));
364                  close(duped1);
# Line 374 | Line 401 | runagain:
401                  goto runagain;
402          }
403   #endif
404 +
405 +        ray_done_pmap();           /* PMAP: free photon maps */
406 +        
407          quit(0);
408  
409   badopt:
# Line 382 | Line 412 | badopt:
412          return 1; /* pro forma return */
413  
414   #undef  check
415 < #undef  bool
415 > #undef  check_bool
416   }
417  
418  
419   void
420   wputs(                          /* warning output function */
421 <        char    *s
421 >        const char      *s
422   )
423   {
424          int  lasterrno = errno;
# Line 399 | Line 429 | wputs(                         /* warning output function */
429  
430   void
431   eputs(                          /* put string to stderr */
432 <        register char  *s
432 >        const char  *s
433   )
434   {
435          static int  midline = 0;
# Line 454 | Line 484 | sigdie(                        /* set fatal signal */
484   static void
485   printdefaults(void)                     /* print default values to stdout */
486   {
487 <        register char  *cp;
487 >        char  *cp;
488  
489          if (imm_irrad)
490                  printf("-I+\t\t\t\t# immediate irradiance on\n");
# Line 474 | Line 504 | printdefaults(void)                    /* print default values to stdou
504                  case 't': case 'T': printf(" trace"); break;
505                  case 'o': printf(" origin"); break;
506                  case 'd': printf(" direction"); break;
507 +                case 'r': printf(" reflect_contrib"); break;
508 +                case 'R': printf(" reflect_length"); break;
509 +                case 'x': printf(" unreflect_contrib"); break;
510 +                case 'X': printf(" unreflect_length"); break;
511                  case 'v': printf(" value"); break;
512                  case 'V': printf(" contribution"); break;
513                  case 'l': printf(" length"); break;
# Line 486 | Line 520 | printdefaults(void)                    /* print default values to stdou
520                  case 'W': printf(" coefficient"); break;
521                  case 'm': printf(" modifier"); break;
522                  case 'M': printf(" material"); break;
523 <                case '-': printf(" stroke"); break;
523 >                case '~': printf(" tilde"); break;
524                  }
525          putchar('\n');
526          printf(erract[WARNING].pf != NULL ?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines