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.4 by schorsch, Thu Jun 26 00:58:10 2003 UTC vs.
Revision 2.33 by greg, Mon Apr 8 17:08:15 2024 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 #ifdef _WIN32
13  #include <process.h> /* getpid */
14 #endif
12  
13   #include  "platform.h"
14 + #include  "rtprocess.h" /* getpid() */
15   #include  "ray.h"
16   #include  "source.h"
17   #include  "ambient.h"
18   #include  "random.h"
19   #include  "paths.h"
20   #include  "view.h"
21 + #include  "pmapray.h"
22  
23                                          /* persistent processes define */
24   #ifdef  F_SETLKW
# Line 29 | Line 28 | static const char      RCSid[] = "$Id$";
28   #endif
29  
30   char  *progname;                        /* argv[0] */
32
31   char  *octname;                         /* octree name */
34
32   char  *sigerr[NSIG];                    /* signal error messages */
36
33   char  *shm_boundary = NULL;             /* boundary of shared memory */
38
34   char  *errfile = NULL;                  /* error output file */
35  
36   extern time_t  time();
# Line 55 | Line 50 | extern double  dstrpix;                        /* square pixel distribution
50  
51   extern double  mblur;                   /* motion blur parameter */
52  
53 < void    onsig();
59 < void    sigdie();
60 < void    printdefaults();
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
83 < main(argc, argv)
65 < int  argc;
66 < char  *argv[];
83 > main(int  argc, char  *argv[])
84   {
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 82 | Line 99 | 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                                          /* option city */
114          for (i = 1; i < argc; i++) {
115                                                  /* expand arguments */
# Line 160 | Line 181 | char  *argv[];
181                                  check(3,"f");
182                                  mblur = atof(argv[++i]);
183                                  break;
184 +                        case 'd':                               /* aperture */
185 +                                check(3,"f");
186 +                                dblur = atof(argv[++i]);
187 +                                break;
188 +                        case 'R':                               /* standard RGB output */
189 +                                if (strcmp(argv[i]+2, "RGB"))
190 +                                        goto badopt;
191 +                                out_prims = stdprims;
192 +                                break;
193 +                        case 'X':                               /* XYZ output */
194 +                                if (strcmp(argv[i]+2, "XYZ"))
195 +                                        goto badopt;
196 +                                out_prims = xyzprims;
197 +                                break;
198 +                        case 'c': {                             /* chromaticities */
199 +                                int     j;
200 +                                check(3,"ffffffff");
201 +                                rval = 0;
202 +                                for (j = 0; j < 8; j++) {
203 +                                        our_prims[0][j] = atof(argv[++i]);
204 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
205 +                                }
206 +                                if (rval) {
207 +                                        if (!colorprimsOK(our_prims))
208 +                                                error(USER, "illegal primary chromaticities");
209 +                                        out_prims = our_prims;
210 +                                } else
211 +                                        out_prims = stdprims;
212 +                                } break;
213                          default:
214                                  goto badopt;
215                          }
# Line 210 | Line 260 | char  *argv[];
260   #endif
261                  case 'w':                               /* warnings */
262                          rval = erract[WARNING].pf != NULL;
263 <                        bool(2,rval);
263 >                        check_bool(2,rval);
264                          if (rval) erract[WARNING].pf = wputs;
265                          else erract[WARNING].pf = NULL;
266                          break;
# Line 222 | Line 272 | char  *argv[];
272                          goto badopt;
273                  }
274          }
275 +                                        /* set/check spectral sampling */
276 +        if (setspectrsamp(CNDX, WLPART) <= 0)
277 +                error(USER, "unsupported spectral sampling");
278 +
279          err = setview(&ourview);        /* set viewing parameters */
280          if (err != NULL)
281                  error(USER, err);
282                                          /* initialize object types */
283          initotypes();
284                                          /* initialize urand */
285 <        initurand(2048);
285 >        if (rand_samp) {
286 >                srandom((long)time(0));
287 >                initurand(0);
288 >        } else {
289 >                srandom(0L);
290 >                initurand(2048);
291 >        }
292                                          /* set up signal handling */
293          sigdie(SIGINT, "Interrupt");
294   #ifdef SIGHUP
# Line 281 | Line 341 | char  *argv[];
341   #endif
342          if (outfile != NULL)
343                  openheader();
284 #ifdef  _WIN32
344          SET_FILE_BINARY(stdout);
345          if (octname == NULL)
346                  SET_FILE_BINARY(stdin);
288 #endif
347          readoct(octname, loadflags, &thescene, NULL);
348          nsceneobjs = nobjects;
349  
350          if (loadflags & IO_INFO) {      /* print header */
351                  printargs(i, argv, stdout);
352                  printf("SOFTWARE= %s\n", VersionID);
295                fputnow(stdout);
353          }
354 +                  
355 +        ray_init_pmap();     /* PMAP: set up & load photon maps */
356  
357          marksources();                  /* find and mark sources */
358  
359          setambient();                   /* initialize ambient calculation */
360 +        
361 +        fflush(stdout);                 /* in case we're duplicating header */
362  
363   #ifdef  PERSIST
364          if (persist) {
304                fflush(stdout);
365                  if (outfile == NULL) {          /* reconnect stdout */
366                          dup2(duped1, fileno(stdout));
367                          close(duped1);
# Line 314 | Line 374 | char  *argv[];
374                                  pflock(1);
375                                  pfhold();
376                                  tstart = time((time_t *)NULL);
377 +                                ambsync();              /* load new values */
378                          }
379                          if (rval < 0)
380                                  error(SYSTEM, "cannot fork child for persist function");
381 <                        pfdetach();             /* parent exits */
381 >                        pfdetach();             /* parent will run then exit */
382                  }
383          }
384   runagain:
385 <        if (persist)
385 >        if (persist) {
386                  if (outfile == NULL)                    /* if out to stdout */
387                          dupheader();                    /* send header */
388                  else                                    /* if out to file */
389                          duped1 = dup(fileno(stdout));   /* hang onto pipe */
390 +        }
391   #endif
392                                          /* batch render picture(s) */
393          rpict(seqstart, outfile, zfile, recover);
# Line 351 | Line 413 | runagain:
413                  goto runagain;
414          }
415   #endif
416 +
417 +
418 +        ray_done_pmap();           /* PMAP: free photon maps */
419 +        
420          quit(0);
421  
422   badopt:
423          sprintf(errmsg, "command line error at '%s'", argv[i]);
424          error(USER, errmsg);
425 +        return 1; /* pro forma return */
426  
427   #undef  check
428 < #undef  bool
428 > #undef  check_bool
429   }
430  
431  
432   void
433 < wputs(s)                                /* warning output function */
434 < char    *s;
433 > wputs(                          /* warning output function */
434 >        const char      *s
435 > )
436   {
437          int  lasterrno = errno;
438          eputs(s);
# Line 373 | Line 441 | char   *s;
441  
442  
443   void
444 < eputs(s)                                /* put string to stderr */
445 < register char  *s;
444 > eputs(                          /* put string to stderr */
445 >        const char  *s
446 > )
447   {
448          static int  midline = 0;
449  
# Line 392 | Line 461 | register char  *s;
461   }
462  
463  
464 < void
465 < onsig(signo)                            /* fatal signal */
466 < int  signo;
464 > static void
465 > onsig(                          /* fatal signal */
466 >        int  signo
467 > )
468   {
469          static int  gotsig = 0;
470  
# Line 412 | Line 482 | int  signo;
482   }
483  
484  
485 < void
486 < sigdie(signo, msg)                      /* set fatal signal */
487 < int  signo;
488 < char  *msg;
485 > static void
486 > sigdie(                 /* set fatal signal */
487 >        int  signo,
488 >        char  *msg
489 > )
490   {
491          if (signal(signo, onsig) == SIG_IGN)
492                  signal(signo, SIG_IGN);
# Line 423 | Line 494 | char  *msg;
494   }
495  
496  
497 < void
498 < printdefaults()                 /* print default values to stdout */
497 > static void
498 > printdefaults(void)                     /* print default values to stdout */
499   {
429        register char  *cp;
430
500          printf("-vt%c\t\t\t\t# view type %s\n", ourview.type,
501                          ourview.type==VT_PER ? "perspective" :
502                          ourview.type==VT_PAR ? "parallel" :
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 449 | Line 519 | printdefaults()                        /* print default values to stdout */
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);
535 +        printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur);
536          printf("-ps %-9d\t\t\t# pixel sample\n", psample);
537          printf("-pt %f\t\t\t# pixel threshold\n", maxdiff);
538          printf("-t  %-9d\t\t\t# time between reports\n", ralrm);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines