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.5 by greg, Thu Jul 3 18:03:58 2003 UTC vs.
Revision 2.27 by greg, Tue Aug 15 01:19:37 2023 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 + static void onsig(int signo);
56 + static void sigdie(int  signo, char  *msg);
57 + static void printdefaults(void);
58 +                                        /* rpict additional features */
59 + #ifdef PERSIST
60 + #define RPICT_FEATURES  "Persist\nParallelPersist\n" \
61 +                "ParticipatingMedia=Mist\n" \
62 +                "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
63 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
64 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
65 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
66 +                "AdaptiveShadowTesting\nOutputs=v,l\n"
67 + #else
68 + #define RPICT_FEATURES  "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
69 +                "ParticipatingMedia=Mist\n" \
70 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
71 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
72 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
73 +                "AdaptiveShadowTesting\nOutputs=v,l\n"
74 + #endif
75  
76 +
77   int
78 < main(argc, argv)
65 < int  argc;
66 < char  *argv[];
78 > main(int  argc, char  *argv[])
79   {
80   #define  check(ol,al)           if (argv[i][ol] || \
81                                  badarg(argc-i-1,argv+i+1,al)) \
82                                  goto badopt
83 < #define  bool(olen,var)         switch (argv[i][olen]) { \
83 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
84                                  case '\0': var = !var; break; \
85                                  case 'y': case 'Y': case 't': case 'T': \
86                                  case '+': case '1': var = 1; break; \
# Line 82 | Line 94 | char  *argv[];
94          int  loadflags = ~IO_FILES;
95          int  seqstart = 0;
96          int  persist = 0;
97 <        int  duped1;
97 >        int  duped1 = -1;
98          int  rval;
99          int  i;
100                                          /* record start time */
101          tstart = time((time_t *)NULL);
102                                          /* global program name */
103          progname = argv[0] = fixargv0(argv[0]);
104 +                                        /* feature check only? */
105 +        strcat(RFeatureList, RPICT_FEATURES);
106 +        if (argc > 1 && !strcmp(argv[1], "-features"))
107 +                return feature_status(argc-2, argv+2);
108                                          /* option city */
109          for (i = 1; i < argc; i++) {
110                                                  /* expand arguments */
# Line 160 | Line 176 | char  *argv[];
176                                  check(3,"f");
177                                  mblur = atof(argv[++i]);
178                                  break;
179 +                        case 'd':                               /* aperture */
180 +                                check(3,"f");
181 +                                dblur = atof(argv[++i]);
182 +                                break;
183                          default:
184                                  goto badopt;
185                          }
# Line 210 | Line 230 | char  *argv[];
230   #endif
231                  case 'w':                               /* warnings */
232                          rval = erract[WARNING].pf != NULL;
233 <                        bool(2,rval);
233 >                        check_bool(2,rval);
234                          if (rval) erract[WARNING].pf = wputs;
235                          else erract[WARNING].pf = NULL;
236                          break;
# Line 228 | Line 248 | char  *argv[];
248                                          /* initialize object types */
249          initotypes();
250                                          /* initialize urand */
251 <        initurand(2048);
251 >        if (rand_samp) {
252 >                srandom((long)time(0));
253 >                initurand(0);
254 >        } else {
255 >                srandom(0L);
256 >                initurand(2048);
257 >        }
258                                          /* set up signal handling */
259          sigdie(SIGINT, "Interrupt");
260   #ifdef SIGHUP
# Line 281 | Line 307 | char  *argv[];
307   #endif
308          if (outfile != NULL)
309                  openheader();
284 #ifdef  _WIN32
310          SET_FILE_BINARY(stdout);
311          if (octname == NULL)
312                  SET_FILE_BINARY(stdin);
288 #endif
313          readoct(octname, loadflags, &thescene, NULL);
314          nsceneobjs = nobjects;
315  
# Line 293 | Line 317 | char  *argv[];
317                  printargs(i, argv, stdout);
318                  printf("SOFTWARE= %s\n", VersionID);
319          }
320 +                  
321 +        ray_init_pmap();     /* PMAP: set up & load photon maps */
322  
323          marksources();                  /* find and mark sources */
324  
325          setambient();                   /* initialize ambient calculation */
326 +        
327 +        fflush(stdout);                 /* in case we're duplicating header */
328  
329   #ifdef  PERSIST
330          if (persist) {
303                fflush(stdout);
331                  if (outfile == NULL) {          /* reconnect stdout */
332                          dup2(duped1, fileno(stdout));
333                          close(duped1);
# Line 313 | Line 340 | char  *argv[];
340                                  pflock(1);
341                                  pfhold();
342                                  tstart = time((time_t *)NULL);
343 +                                ambsync();              /* load new values */
344                          }
345                          if (rval < 0)
346                                  error(SYSTEM, "cannot fork child for persist function");
347 <                        pfdetach();             /* parent exits */
347 >                        pfdetach();             /* parent will run then exit */
348                  }
349          }
350   runagain:
351 <        if (persist)
351 >        if (persist) {
352                  if (outfile == NULL)                    /* if out to stdout */
353                          dupheader();                    /* send header */
354                  else                                    /* if out to file */
355                          duped1 = dup(fileno(stdout));   /* hang onto pipe */
356 +        }
357   #endif
358                                          /* batch render picture(s) */
359          rpict(seqstart, outfile, zfile, recover);
# Line 350 | Line 379 | runagain:
379                  goto runagain;
380          }
381   #endif
382 +
383 +
384 +        ray_done_pmap();           /* PMAP: free photon maps */
385 +        
386          quit(0);
387  
388   badopt:
389          sprintf(errmsg, "command line error at '%s'", argv[i]);
390          error(USER, errmsg);
391 +        return 1; /* pro forma return */
392  
393   #undef  check
394 < #undef  bool
394 > #undef  check_bool
395   }
396  
397  
398   void
399 < wputs(s)                                /* warning output function */
400 < char    *s;
399 > wputs(                          /* warning output function */
400 >        const char      *s
401 > )
402   {
403          int  lasterrno = errno;
404          eputs(s);
# Line 372 | Line 407 | char   *s;
407  
408  
409   void
410 < eputs(s)                                /* put string to stderr */
411 < register char  *s;
410 > eputs(                          /* put string to stderr */
411 >        const char  *s
412 > )
413   {
414          static int  midline = 0;
415  
# Line 391 | Line 427 | register char  *s;
427   }
428  
429  
430 < void
431 < onsig(signo)                            /* fatal signal */
432 < int  signo;
430 > static void
431 > onsig(                          /* fatal signal */
432 >        int  signo
433 > )
434   {
435          static int  gotsig = 0;
436  
# Line 411 | Line 448 | int  signo;
448   }
449  
450  
451 < void
452 < sigdie(signo, msg)                      /* set fatal signal */
453 < int  signo;
454 < char  *msg;
451 > static void
452 > sigdie(                 /* set fatal signal */
453 >        int  signo,
454 >        char  *msg
455 > )
456   {
457          if (signal(signo, onsig) == SIG_IGN)
458                  signal(signo, SIG_IGN);
# Line 422 | Line 460 | char  *msg;
460   }
461  
462  
463 < void
464 < printdefaults()                 /* print default values to stdout */
463 > static void
464 > printdefaults(void)                     /* print default values to stdout */
465   {
428        register char  *cp;
429
466          printf("-vt%c\t\t\t\t# view type %s\n", ourview.type,
467                          ourview.type==VT_PER ? "perspective" :
468                          ourview.type==VT_PAR ? "parallel" :
469                          ourview.type==VT_HEM ? "hemispherical" :
470                          ourview.type==VT_ANG ? "angular" :
471                          ourview.type==VT_CYL ? "cylindrical" :
472 +                        ourview.type==VT_PLS ? "planisphere" :
473                          "unknown");
474          printf("-vp %f %f %f\t# view point\n",
475                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
# Line 451 | Line 488 | printdefaults()                        /* print default values to stdout */
488          printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect);
489          printf("-pj %f\t\t\t# pixel jitter\n", dstrpix);
490          printf("-pm %f\t\t\t# pixel motion\n", mblur);
491 +        printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur);
492          printf("-ps %-9d\t\t\t# pixel sample\n", psample);
493          printf("-pt %f\t\t\t# pixel threshold\n", maxdiff);
494          printf("-t  %-9d\t\t\t# time between reports\n", ralrm);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines