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

Comparing ray/src/rt/rpmain.c (file contents):
Revision 2.8 by schorsch, Tue Mar 30 16:13:01 2004 UTC vs.
Revision 2.38 by greg, Tue Apr 22 17:12:25 2025 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7  
8   #include "copyright.h"
9  
10 < #include  <sys/types.h>
10 > #include  <time.h>
11   #include  <signal.h>
12  
13   #include  "platform.h"
14   #include  "rtprocess.h" /* getpid() */
15   #include  "ray.h"
16 + #include  "func.h"
17   #include  "source.h"
18   #include  "ambient.h"
19   #include  "random.h"
20   #include  "paths.h"
21   #include  "view.h"
22 + #include  "pmapray.h"
23  
24                                          /* persistent processes define */
25   #ifdef  F_SETLKW
# Line 29 | Line 31 | static const char      RCSid[] = "$Id$";
31   char  *progname;                        /* argv[0] */
32   char  *octname;                         /* octree name */
33   char  *sigerr[NSIG];                    /* signal error messages */
32 char  *shm_boundary = NULL;             /* boundary of shared memory */
34   char  *errfile = NULL;                  /* error output file */
35  
36   extern time_t  time();
# Line 49 | Line 50 | extern double  dstrpix;                        /* square pixel distribution
50  
51   extern double  mblur;                   /* motion blur parameter */
52  
53 + extern double  dblur;                   /* depth-of-field blur parameter */
54 +
55 + RGBPRIMP  out_prims = stdprims;         /* output color primitives */
56 + static RGBPRIMS  our_prims;             /* private output color primitives */
57 +
58   static void onsig(int signo);
59   static void sigdie(int  signo, char  *msg);
60   static void printdefaults(void);
61 +                                        /* rpict additional features */
62 + #ifdef PERSIST
63 + #define RPICT_FEATURES  "Persist\nParallelPersist\n" \
64 +                "ParticipatingMedia=Mist\n" \
65 +                "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
66 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
67 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
68 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
69 +                "AdaptiveShadowTesting\nOutputs=v,l\n" \
70 +                "OutputCS=RGB,XYZ,prims\n"
71 + #else
72 + #define RPICT_FEATURES  "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
73 +                "ParticipatingMedia=Mist\n" \
74 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
75 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
76 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
77 +                "AdaptiveShadowTesting\nOutputs=v,l\n" \
78 +                "OutputCS=RGB,XYZ,prims\n"
79 + #endif
80  
81  
82   int
# Line 60 | Line 85 | main(int  argc, char  *argv[])
85   #define  check(ol,al)           if (argv[i][ol] || \
86                                  badarg(argc-i-1,argv+i+1,al)) \
87                                  goto badopt
88 < #define  bool(olen,var)         switch (argv[i][olen]) { \
88 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
89                                  case '\0': var = !var; break; \
90                                  case 'y': case 'Y': case 't': case 'T': \
91                                  case '+': case '1': var = 1; break; \
# Line 74 | Line 99 | main(int  argc, char  *argv[])
99          int  loadflags = ~IO_FILES;
100          int  seqstart = 0;
101          int  persist = 0;
102 <        int  duped1;
102 >        int  duped1 = -1;
103          int  rval;
104          int  i;
105                                          /* record start time */
106          tstart = time((time_t *)NULL);
107                                          /* global program name */
108          progname = argv[0] = fixargv0(argv[0]);
109 +                                        /* feature check only? */
110 +        strcat(RFeatureList, RPICT_FEATURES);
111 +        if (argc > 1 && !strcmp(argv[1], "-features"))
112 +                return feature_status(argc-2, argv+2);
113 +                                        /* initialize calcomp routines */
114 +        initfunc();
115                                          /* option city */
116          for (i = 1; i < argc; i++) {
117                                                  /* expand arguments */
# Line 152 | Line 183 | main(int  argc, char  *argv[])
183                                  check(3,"f");
184                                  mblur = atof(argv[++i]);
185                                  break;
186 +                        case 'd':                               /* aperture */
187 +                                check(3,"f");
188 +                                dblur = atof(argv[++i]);
189 +                                break;
190 +                        case 'R':                               /* standard RGB output */
191 +                                if (strcmp(argv[i]+2, "RGB"))
192 +                                        goto badopt;
193 +                                out_prims = stdprims;
194 +                                break;
195 +                        case 'X':                               /* XYZ output */
196 +                                if (strcmp(argv[i]+2, "XYZ"))
197 +                                        goto badopt;
198 +                                out_prims = xyzprims;
199 +                                break;
200 +                        case 'c': {                             /* chromaticities */
201 +                                int     j;
202 +                                check(3,"ffffffff");
203 +                                rval = 0;
204 +                                for (j = 0; j < 8; j++) {
205 +                                        our_prims[0][j] = atof(argv[++i]);
206 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
207 +                                }
208 +                                if (rval) {
209 +                                        if (!colorprimsOK(our_prims))
210 +                                                error(USER, "illegal primary chromaticities");
211 +                                        out_prims = our_prims;
212 +                                } else
213 +                                        out_prims = stdprims;
214 +                                } break;
215                          default:
216                                  goto badopt;
217                          }
# Line 184 | Line 244 | main(int  argc, char  *argv[])
244                                  check(2,"s");
245                          recover = argv[++i];
246                          break;
187                case 't':                               /* timer */
188                        check(2,"i");
189                        ralrm = atoi(argv[++i]);
190                        break;
247   #ifdef  PERSIST
248                  case 'P':                               /* persist file */
249                          if (argv[i][2] == 'P') {
# Line 200 | Line 256 | main(int  argc, char  *argv[])
256                          persistfile(argv[++i]);
257                          break;
258   #endif
259 +                case 't':                               /* timer */
260 +                        check(2,"i");
261 +                        ralrm = atoi(argv[++i]);
262 +                        break;
263                  case 'w':                               /* warnings */
264                          rval = erract[WARNING].pf != NULL;
265 <                        bool(2,rval);
265 >                        check_bool(2,rval);
266                          if (rval) erract[WARNING].pf = wputs;
267                          else erract[WARNING].pf = NULL;
268                          break;
# Line 214 | Line 274 | main(int  argc, char  *argv[])
274                          goto badopt;
275                  }
276          }
277 +                                        /* set/check spectral sampling */
278 +        if (setspectrsamp(CNDX, WLPART) <= 0)
279 +                error(USER, "unsupported spectral sampling");
280 +
281          err = setview(&ourview);        /* set viewing parameters */
282          if (err != NULL)
283                  error(USER, err);
284                                          /* initialize object types */
285          initotypes();
286                                          /* initialize urand */
287 <        initurand(2048);
287 >        if (rand_samp) {
288 >                srandom((long)time(0));
289 >                initurand(0);
290 >        } else {
291 >                srandom(0L);
292 >                initurand(2048);
293 >        }
294                                          /* set up signal handling */
295          sigdie(SIGINT, "Interrupt");
296   #ifdef SIGHUP
# Line 273 | Line 343 | main(int  argc, char  *argv[])
343   #endif
344          if (outfile != NULL)
345                  openheader();
276 #ifdef  _WIN32
346          SET_FILE_BINARY(stdout);
347          if (octname == NULL)
348                  SET_FILE_BINARY(stdin);
280 #endif
349          readoct(octname, loadflags, &thescene, NULL);
350          nsceneobjs = nobjects;
351  
# Line 285 | Line 353 | main(int  argc, char  *argv[])
353                  printargs(i, argv, stdout);
354                  printf("SOFTWARE= %s\n", VersionID);
355          }
356 +                  
357 +        ray_init_pmap();     /* PMAP: set up & load photon maps */
358  
359          marksources();                  /* find and mark sources */
290
360          setambient();                   /* initialize ambient calculation */
361 +        
362 +        fflush(stdout);                 /* in case we're duplicating header */
363  
364   #ifdef  PERSIST
365          if (persist) {
295                fflush(stdout);
366                  if (outfile == NULL) {          /* reconnect stdout */
367                          dup2(duped1, fileno(stdout));
368                          close(duped1);
369                  }
370                  if (persist == PARALLEL) {      /* multiprocessing */
371 <                        preload_objs();         /* preload scene */
302 <                        shm_boundary = (char *)malloc(16);
303 <                        strcpy(shm_boundary, "SHM_BOUNDARY");
371 >                        cow_memshare();         /* preloads scene */
372                          while ((rval=fork()) == 0) {    /* keep on forkin' */
373                                  pflock(1);
374                                  pfhold();
375                                  tstart = time((time_t *)NULL);
376 +                                ambsync();              /* load new values */
377                          }
378                          if (rval < 0)
379                                  error(SYSTEM, "cannot fork child for persist function");
380 <                        pfdetach();             /* parent exits */
380 >                        pfdetach();             /* parent will run then exit */
381                  }
382          }
383   runagain:
# Line 343 | Line 412 | runagain:
412                  goto runagain;
413          }
414   #endif
415 +
416 +
417 +        ray_done_pmap();           /* PMAP: free photon maps */
418 +        
419          quit(0);
420  
421   badopt:
# Line 351 | Line 424 | badopt:
424          return 1; /* pro forma return */
425  
426   #undef  check
427 < #undef  bool
427 > #undef  check_bool
428   }
429  
430  
431   void
432   wputs(                          /* warning output function */
433 <        char    *s
433 >        const char      *s
434   )
435   {
436          int  lasterrno = errno;
437 +        if (erract[WARNING].pf == NULL)
438 +                return;         /* called by calcomp or someone */
439          eputs(s);
440          errno = lasterrno;
441   }
# Line 368 | Line 443 | wputs(                         /* warning output function */
443  
444   void
445   eputs(                          /* put string to stderr */
446 <        register char  *s
446 >        const char  *s
447   )
448   {
449          static int  midline = 0;
# Line 429 | Line 504 | printdefaults(void)                    /* print default values to stdou
504                          ourview.type==VT_HEM ? "hemispherical" :
505                          ourview.type==VT_ANG ? "angular" :
506                          ourview.type==VT_CYL ? "cylindrical" :
507 +                        ourview.type==VT_PLS ? "planisphere" :
508                          "unknown");
509          printf("-vp %f %f %f\t# view point\n",
510                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
# Line 444 | Line 520 | printdefaults(void)                    /* print default values to stdou
520          printf("-vl %f\t\t\t# view lift\n", ourview.voff);
521          printf("-x  %-9d\t\t\t# x resolution\n", hresolu);
522          printf("-y  %-9d\t\t\t# y resolution\n", vresolu);
523 +        if (out_prims == stdprims)
524 +                printf("-pRGB\t\t\t\t# standard RGB color output\n");
525 +        else if (out_prims == xyzprims)
526 +                printf("-pXYZ\t\t\t\t# CIE XYZ color output\n");
527 +        else if (out_prims != NULL)
528 +                printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n",
529 +                                out_prims[RED][0], out_prims[RED][1],
530 +                                out_prims[GRN][0], out_prims[GRN][1],
531 +                                out_prims[BLU][0], out_prims[BLU][1],
532 +                                out_prims[WHT][0], out_prims[WHT][1]);
533          printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect);
534          printf("-pj %f\t\t\t# pixel jitter\n", dstrpix);
535          printf("-pm %f\t\t\t# pixel motion\n", mblur);
536 +        printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur);
537          printf("-ps %-9d\t\t\t# pixel sample\n", psample);
538          printf("-pt %f\t\t\t# pixel threshold\n", maxdiff);
539          printf("-t  %-9d\t\t\t# time between reports\n", ralrm);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines