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.24 by greg, Thu Apr 23 17:42:04 2015 UTC vs.
Revision 2.41 by greg, Thu Feb 2 18:55:09 2023 UTC

# Line 35 | 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 43 | 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 62 | 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 +                        "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 +                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
80 + #endif
81  
82 +
83   int
84   main(int  argc, char  *argv[])
85   {
86   #define  check(ol,al)           if (argv[i][ol] || \
87                                  badarg(argc-i-1,argv+i+1,al)) \
88                                  goto badopt
89 < #define  bool(olen,var)         switch (argv[i][olen]) { \
89 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
90                                  case '\0': var = !var; break; \
91                                  case 'y': case 'Y': case 't': case 'T': \
92                                  case '+': case '1': var = 1; break; \
93                                  case 'n': case 'N': case 'f': case 'F': \
94                                  case '-': case '0': var = 0; break; \
95                                  default: goto badopt; }
96 +        extern char  *octname;
97          int  persist = 0;
98          char  *octnm = NULL;
99          char  **tralp = NULL;
# Line 84 | Line 102 | main(int  argc, char  *argv[])
102          int  i;
103                                          /* global program name */
104          progname = argv[0] = fixargv0(argv[0]);
105 +                                        /* feature check only? */
106 +        strcat(RFeatureList, RTRACE_FEATURES);
107 +        if (!strcmp(argv[1], "-features"))
108 +                return feature_status(argc-2, argv+2);
109                                          /* add trace notify function */
110          for (i = 0; addobjnotify[i] != NULL; i++)
111                  ;
112          addobjnotify[i] = tranotify;
91                                        /* set our defaults */
92        rand_samp = 1;
93        maxdepth = -10;
94        minweight = 2e-3;
113                                          /* option city */
114          for (i = 1; i < argc; i++) {
115                                                  /* expand arguments */
# Line 134 | Line 152 | main(int  argc, char  *argv[])
152                          break;
153                  case 'w':                               /* warnings */
154                          rval = erract[WARNING].pf != NULL;
155 <                        bool(2,rval);
155 >                        check_bool(2,rval);
156                          if (rval) erract[WARNING].pf = wputs;
157                          else erract[WARNING].pf = NULL;
158                          break;
# Line 145 | Line 163 | main(int  argc, char  *argv[])
163                  case 'l':                               /* limit distance */
164                          if (argv[i][2] != 'd')
165                                  goto badopt;
166 <                        bool(3,lim_dist);
166 >                        check_bool(3,lim_dist);
167                          break;
168                  case 'I':                               /* immed. irradiance */
169 <                        bool(2,imm_irrad);
169 >                        check_bool(2,imm_irrad);
170                          break;
171                  case 'f':                               /* format i/o */
172                          switch (argv[i][2]) {
# Line 180 | Line 198 | main(int  argc, char  *argv[])
198                          break;
199                  case 'h':                               /* header output */
200                          rval = loadflags & IO_INFO;
201 <                        bool(2,rval);
201 >                        check_bool(2,rval);
202                          loadflags = rval ? loadflags | IO_INFO :
203                                          loadflags & ~IO_INFO;
204                          break;
# Line 194 | Line 212 | main(int  argc, char  *argv[])
212                                          tralp = tralist;
213                                  }
214                                  if (argv[i][2] == 'I') {        /* file */
215 <                                        rval = wordfile(tralp,
215 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
216                                          getpath(argv[++i],getrlibpath(),R_OK));
217                                          if (rval < 0) {
218                                                  sprintf(errmsg,
# Line 216 | Line 234 | main(int  argc, char  *argv[])
234                                          tralp = tralist;
235                                  }
236                                  if (argv[i][2] == 'E') {        /* file */
237 <                                        rval = wordfile(tralp,
237 >                                        rval = wordfile(tralp, MAXMODLIST-(tralp-tralist),
238                                          getpath(argv[++i],getrlibpath(),R_OK));
239                                          if (rval < 0) {
240                                                  sprintf(errmsg,
# Line 250 | Line 268 | main(int  argc, char  *argv[])
268                          goto badopt;
269                  }
270          }
271 <        if (nproc > 1) {
272 <                if (persist)
255 <                        error(USER, "multiprocessing incompatible with persist file");
256 <                if (!vresolu && hresolu > 0 && hresolu < nproc)
257 <                        error(WARNING, "number of cores should not exceed horizontal resolution");
258 <                if (trace != NULL)
259 <                        error(WARNING, "multiprocessing does not work properly with trace mode");
260 <        }
271 >        if (nproc > 1 && persist)
272 >                error(USER, "multiprocessing incompatible with persist file");
273                                          /* initialize object types */
274          initotypes();
275                                          /* initialize urand */
# Line 315 | Line 327 | main(int  argc, char  *argv[])
327   #endif
328          if (outform != 'a')
329                  SET_FILE_BINARY(stdout);
330 <        readoct(octname = octnm, loadflags, &thescene, NULL);
330 >        rval = setrtoutput();
331 >        octname = savqstr(octnm);
332 >        readoct(octname, loadflags, &thescene, NULL);
333          nsceneobjs = nobjects;
334  
335          if (loadflags & IO_INFO) {      /* print header */
336                  printargs(i, argv, stdout);
337                  printf("SOFTWARE= %s\n", VersionID);
338                  fputnow(stdout);
339 +                if (rval > 0)           /* saved from setrtoutput() call */
340 +                        printf("NCOMP=%d\n", rval);
341 +                if ((outform == 'f') | (outform == 'd'))
342 +                        fputendian(stdout);
343                  fputformat(formstr(outform), stdout);
344                  putchar('\n');
345          }
328        
329        ray_init_pmap();     /* PMAP: set up & load photon maps */
330        
331        marksources();                  /* find and mark sources */
346  
347 <        setambient();                   /* initialize ambient calculation */
348 <        
347 >        if (!castonly) {        /* any actual ray traversal to do? */
348 >
349 >                ray_init_pmap();        /* PMAP: set up & load photon maps */
350 >                
351 >                marksources();          /* find and mark sources */
352 >
353 >                setambient();           /* initialize ambient calculation */
354 >        } else
355 >                distantsources();       /* else mark only distant sources */
356 >
357 >        fflush(stdout);                 /* in case we're duplicating header */
358 >
359   #ifdef  PERSIST
360          if (persist) {
337                fflush(stdout);
361                                                  /* reconnect stdout */
362                  dup2(duped1, fileno(stdout));
363                  close(duped1);
# Line 388 | Line 411 | badopt:
411          return 1; /* pro forma return */
412  
413   #undef  check
414 < #undef  bool
414 > #undef  check_bool
415   }
416  
417  
# Line 405 | Line 428 | wputs(                         /* warning output function */
428  
429   void
430   eputs(                          /* put string to stderr */
431 <        register char  *s
431 >        char  *s
432   )
433   {
434          static int  midline = 0;
# Line 460 | Line 483 | sigdie(                        /* set fatal signal */
483   static void
484   printdefaults(void)                     /* print default values to stdout */
485   {
486 <        register char  *cp;
486 >        char  *cp;
487  
488          if (imm_irrad)
489                  printf("-I+\t\t\t\t# immediate irradiance on\n");
# Line 480 | Line 503 | printdefaults(void)                    /* print default values to stdou
503                  case 't': case 'T': printf(" trace"); break;
504                  case 'o': printf(" origin"); break;
505                  case 'd': printf(" direction"); break;
506 +                case 'r': printf(" reflect_contrib"); break;
507 +                case 'R': printf(" reflect_length"); break;
508 +                case 'x': printf(" unreflect_contrib"); break;
509 +                case 'X': printf(" unreflect_length"); break;
510                  case 'v': printf(" value"); break;
511                  case 'V': printf(" contribution"); break;
512                  case 'l': printf(" length"); break;
# Line 492 | Line 519 | printdefaults(void)                    /* print default values to stdou
519                  case 'W': printf(" coefficient"); break;
520                  case 'm': printf(" modifier"); break;
521                  case 'M': printf(" material"); break;
522 <                case '-': printf(" stroke"); break;
522 >                case '~': printf(" tilde"); break;
523                  }
524          putchar('\n');
525          printf(erract[WARNING].pf != NULL ?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines