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.12 by greg, Wed Apr 5 06:22:57 2006 UTC vs.
Revision 2.39 by greg, Wed Apr 23 01:57:04 2025 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
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  
35 extern time_t  time();
36   extern time_t  tstart;                  /* start time */
37  
38   extern int  ralrm;                      /* seconds between reports */
# Line 51 | Line 51 | extern double  mblur;                  /* motion blur parameter */
51  
52   extern double  dblur;                   /* depth-of-field blur parameter */
53  
54 + RGBPRIMP  out_prims = stdprims;         /* output color primitives */
55 + static RGBPRIMS  our_prims;             /* private output color primitives */
56 +
57   static void onsig(int signo);
58   static void sigdie(int  signo, char  *msg);
59   static void printdefaults(void);
60 +                                        /* rpict additional features */
61 + #ifdef PERSIST
62 + #define RPICT_FEATURES  "Persist\nParallelPersist\n" \
63 +                "ParticipatingMedia=Mist\n" \
64 +                "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
65 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
66 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
67 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
68 +                "AdaptiveShadowTesting\nOutputs=v,l\n" \
69 +                "OutputCS=RGB,XYZ,prims\n"
70 + #else
71 + #define RPICT_FEATURES  "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
72 +                "ParticipatingMedia=Mist\n" \
73 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
74 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
75 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
76 +                "AdaptiveShadowTesting\nOutputs=v,l\n" \
77 +                "OutputCS=RGB,XYZ,prims\n"
78 + #endif
79  
80  
81   int
# Line 62 | Line 84 | main(int  argc, char  *argv[])
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; \
# Line 76 | Line 98 | main(int  argc, char  *argv[])
98          int  loadflags = ~IO_FILES;
99          int  seqstart = 0;
100          int  persist = 0;
101 <        int  duped1;
101 >        int  duped1 = -1;
102          int  rval;
103          int  i;
104                                          /* record start time */
105          tstart = time((time_t *)NULL);
106                                          /* global program name */
107          progname = argv[0] = fixargv0(argv[0]);
108 +                                        /* feature check only? */
109 +        strcat(RFeatureList, RPICT_FEATURES);
110 +        if (argc > 1 && !strcmp(argv[1], "-features"))
111 +                return feature_status(argc-2, argv+2);
112 +                                        /* initialize calcomp routines */
113 +        initfunc();
114                                          /* option city */
115          for (i = 1; i < argc; i++) {
116                                                  /* expand arguments */
# Line 158 | Line 186 | main(int  argc, char  *argv[])
186                                  check(3,"f");
187                                  dblur = atof(argv[++i]);
188                                  break;
189 +                        case 'R':                               /* standard RGB output */
190 +                                if (strcmp(argv[i]+2, "RGB"))
191 +                                        goto badopt;
192 +                                out_prims = stdprims;
193 +                                break;
194 +                        case 'X':                               /* XYZ output */
195 +                                if (strcmp(argv[i]+2, "XYZ"))
196 +                                        goto badopt;
197 +                                out_prims = xyzprims;
198 +                                break;
199 +                        case 'c': {                             /* chromaticities */
200 +                                int     j;
201 +                                check(3,"ffffffff");
202 +                                rval = 0;
203 +                                for (j = 0; j < 8; j++) {
204 +                                        our_prims[0][j] = atof(argv[++i]);
205 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
206 +                                }
207 +                                if (rval) {
208 +                                        if (!colorprimsOK(our_prims))
209 +                                                error(USER, "illegal primary chromaticities");
210 +                                        out_prims = our_prims;
211 +                                } else
212 +                                        out_prims = stdprims;
213 +                                } break;
214                          default:
215                                  goto badopt;
216                          }
# Line 190 | Line 243 | main(int  argc, char  *argv[])
243                                  check(2,"s");
244                          recover = argv[++i];
245                          break;
193                case 't':                               /* timer */
194                        check(2,"i");
195                        ralrm = atoi(argv[++i]);
196                        break;
246   #ifdef  PERSIST
247                  case 'P':                               /* persist file */
248                          if (argv[i][2] == 'P') {
# Line 206 | Line 255 | main(int  argc, char  *argv[])
255                          persistfile(argv[++i]);
256                          break;
257   #endif
258 +                case 't':                               /* timer */
259 +                        check(2,"i");
260 +                        ralrm = atoi(argv[++i]);
261 +                        break;
262                  case 'w':                               /* warnings */
263                          rval = erract[WARNING].pf != NULL;
264 <                        bool(2,rval);
264 >                        check_bool(2,rval);
265                          if (rval) erract[WARNING].pf = wputs;
266                          else erract[WARNING].pf = NULL;
267                          break;
# Line 220 | Line 273 | main(int  argc, char  *argv[])
273                          goto badopt;
274                  }
275          }
276 +                                        /* set/check spectral sampling */
277 +        if (setspectrsamp(CNDX, WLPART) <= 0)
278 +                error(USER, "unsupported spectral sampling");
279 +
280          err = setview(&ourview);        /* set viewing parameters */
281          if (err != NULL)
282                  error(USER, err);
# Line 285 | Line 342 | main(int  argc, char  *argv[])
342   #endif
343          if (outfile != NULL)
344                  openheader();
288 #ifdef  _WIN32
345          SET_FILE_BINARY(stdout);
346          if (octname == NULL)
347                  SET_FILE_BINARY(stdin);
292 #endif
348          readoct(octname, loadflags, &thescene, NULL);
349          nsceneobjs = nobjects;
350  
# Line 297 | Line 352 | main(int  argc, char  *argv[])
352                  printargs(i, argv, stdout);
353                  printf("SOFTWARE= %s\n", VersionID);
354          }
355 +                  
356 +        ray_init_pmap();     /* PMAP: set up & load photon maps */
357  
358          marksources();                  /* find and mark sources */
302
359          setambient();                   /* initialize ambient calculation */
360 +        
361 +        fflush(stdout);                 /* in case we're duplicating header */
362  
363   #ifdef  PERSIST
364          if (persist) {
307                fflush(stdout);
365                  if (outfile == NULL) {          /* reconnect stdout */
366                          dup2(duped1, fileno(stdout));
367                          close(duped1);
368                  }
369                  if (persist == PARALLEL) {      /* multiprocessing */
370 <                        preload_objs();         /* preload scene */
314 <                        shm_boundary = (char *)malloc(16);
315 <                        strcpy(shm_boundary, "SHM_BOUNDARY");
370 >                        cow_memshare();         /* preloads scene */
371                          while ((rval=fork()) == 0) {    /* keep on forkin' */
372                                  pflock(1);
373                                  pfhold();
374                                  tstart = time((time_t *)NULL);
375 +                                ambsync();              /* load new values */
376                          }
377                          if (rval < 0)
378                                  error(SYSTEM, "cannot fork child for persist function");
379 <                        pfdetach();             /* parent exits */
379 >                        pfdetach();             /* parent will run then exit */
380                  }
381          }
382   runagain:
# Line 355 | Line 411 | runagain:
411                  goto runagain;
412          }
413   #endif
414 +
415 +
416 +        ray_done_pmap();           /* PMAP: free photon maps */
417 +        
418          quit(0);
419  
420   badopt:
# Line 363 | Line 423 | badopt:
423          return 1; /* pro forma return */
424  
425   #undef  check
426 < #undef  bool
426 > #undef  check_bool
427   }
428  
429  
430   void
431   wputs(                          /* warning output function */
432 <        char    *s
432 >        const char      *s
433   )
434   {
435          int  lasterrno = errno;
436 +        if (erract[WARNING].pf == NULL)
437 +                return;         /* called by calcomp or someone */
438          eputs(s);
439          errno = lasterrno;
440   }
# Line 380 | Line 442 | wputs(                         /* warning output function */
442  
443   void
444   eputs(                          /* put string to stderr */
445 <        register char  *s
445 >        const char  *s
446   )
447   {
448          static int  midline = 0;
# Line 441 | Line 503 | printdefaults(void)                    /* print default values to stdou
503                          ourview.type==VT_HEM ? "hemispherical" :
504                          ourview.type==VT_ANG ? "angular" :
505                          ourview.type==VT_CYL ? "cylindrical" :
506 +                        ourview.type==VT_PLS ? "planisphere" :
507                          "unknown");
508          printf("-vp %f %f %f\t# view point\n",
509                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
# Line 456 | Line 519 | printdefaults(void)                    /* print default values to stdou
519          printf("-vl %f\t\t\t# view lift\n", ourview.voff);
520          printf("-x  %-9d\t\t\t# x resolution\n", hresolu);
521          printf("-y  %-9d\t\t\t# y resolution\n", vresolu);
522 +        if (out_prims == stdprims)
523 +                printf("-pRGB\t\t\t\t# standard RGB color output\n");
524 +        else if (out_prims == xyzprims)
525 +                printf("-pXYZ\t\t\t\t# CIE XYZ color output\n");
526 +        else if (out_prims != NULL)
527 +                printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n",
528 +                                out_prims[RED][0], out_prims[RED][1],
529 +                                out_prims[GRN][0], out_prims[GRN][1],
530 +                                out_prims[BLU][0], out_prims[BLU][1],
531 +                                out_prims[WHT][0], out_prims[WHT][1]);
532          printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect);
533          printf("-pj %f\t\t\t# pixel jitter\n", dstrpix);
534          printf("-pm %f\t\t\t# pixel motion\n", mblur);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines