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.12 by greg, Wed Jun 15 15:36:52 2005 UTC vs.
Revision 2.23 by greg, Tue Feb 24 19:39:27 2015 UTC

# Line 17 | Line 17 | static const char      RCSid[] = "$Id$";
17   #include  "ambient.h"
18   #include  "random.h"
19   #include  "paths.h"
20 + #include  "pmapray.h"
21  
22 + extern char     *progname;              /* global argv[0] */
23 +
24 + extern char     *shm_boundary;          /* boundary of shared memory */
25 +
26                                          /* persistent processes define */
27   #ifdef  F_SETLKW
28   #define  PERSIST        1               /* normal persist */
# Line 25 | Line 30 | static const char      RCSid[] = "$Id$";
30   #define  PCHILD         3               /* child of normal persist */
31   #endif
32  
28 char  *progname;                        /* argv[0] */
29 char  *octname;                         /* octree name */
33   char  *sigerr[NSIG];                    /* signal error messages */
31 char  *shm_boundary = NULL;             /* boundary of shared memory */
34   char  *errfile = NULL;                  /* error output file */
35  
36 + int  nproc = 1;                         /* number of processes */
37 +
38   extern char  *formstr();                /* string from format */
39 < extern int  inform;                     /* input format */
40 < extern int  outform;                    /* output format */
41 < extern char  *outvals;                  /* output values */
39 > int  inform = 'a';                      /* input format */
40 > int  outform = 'a';                     /* output format */
41 > char  *outvals = "v";                   /* output specification */
42  
43 < extern int  hresolu;                    /* horizontal resolution */
44 < extern int  vresolu;                    /* vertical resolution */
43 > int  hresolu = 0;                       /* horizontal (scan) size */
44 > int  vresolu = 0;                       /* vertical resolution */
45  
46 < extern int  imm_irrad;                  /* compute immediate irradiance? */
47 < extern int  lim_dist;                   /* limit distance? */
46 > int  imm_irrad = 0;                     /* compute immediate irradiance? */
47 > int  lim_dist = 0;                      /* limit distance? */
48  
49 < extern char  *tralist[];                /* list of modifers to trace (or no) */
50 < extern int  traincl;                    /* include == 1, exclude == 0 */
49 > #ifndef MAXMODLIST
50 > #define MAXMODLIST      1024            /* maximum modifiers we'll track */
51 > #endif
52  
53 + extern void  (*addobjnotify[])();       /* object notification calls */
54 + extern void  tranotify(OBJECT obj);
55 +
56 + char  *tralist[MAXMODLIST];             /* list of modifers to trace (or no) */
57 + int  traincl = -1;                      /* include == 1, exclude == 0 */
58 +
59   static int  loadflags = ~IO_FILES;      /* what to load from octree */
60  
61   static void onsig(int  signo);
# Line 66 | Line 77 | main(int  argc, char  *argv[])
77                                  case '-': case '0': var = 0; break; \
78                                  default: goto badopt; }
79          int  persist = 0;
80 <        char  **tralp;
81 <        int  duped1;
80 >        char  *octnm = NULL;
81 >        char  **tralp = NULL;
82 >        int  duped1 = -1;
83          int  rval;
84          int  i;
85                                          /* global program name */
86          progname = argv[0] = fixargv0(argv[0]);
87 +                                        /* add trace notify function */
88 +        for (i = 0; addobjnotify[i] != NULL; i++)
89 +                ;
90 +        addobjnotify[i] = tranotify;
91 +                                        /* set our defaults */
92 +        rand_samp = 1;
93 +        maxdepth = -10;
94 +        minweight = 2e-3;
95                                          /* option city */
96          for (i = 1; i < argc; i++) {
97                                                  /* expand arguments */
# Line 98 | Line 118 | main(int  argc, char  *argv[])
118                          continue;
119                  }
120                  switch (argv[i][1]) {
121 +                case 'n':                               /* number of cores */
122 +                        check(2,"i");
123 +                        nproc = atoi(argv[++i]);
124 +                        if (nproc <= 0)
125 +                                error(USER, "bad number of processes");
126 +                        break;
127                  case 'x':                               /* x resolution */
128                          check(2,"i");
129                          hresolu = atoi(argv[++i]);
# Line 224 | Line 250 | main(int  argc, char  *argv[])
250                          goto badopt;
251                  }
252          }
253 +        if (nproc > 1) {
254 +                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 +        }
261                                          /* initialize object types */
262          initotypes();
263                                          /* initialize urand */
264 <        initurand(2048);
265 <        srandom(rand_samp ? (long)time(0) : 0L);
264 >        if (rand_samp) {
265 >                srandom((long)time(0));
266 >                initurand(0);
267 >        } else {
268 >                srandom(0L);
269 >                initurand(2048);
270 >        }
271                                          /* set up signal handling */
272          sigdie(SIGINT, "Interrupt");
273   #ifdef SIGHUP
# Line 260 | Line 299 | main(int  argc, char  *argv[])
299   #endif
300                                          /* get octree */
301          if (i == argc)
302 <                octname = NULL;
302 >                octnm = NULL;
303          else if (i == argc-1)
304 <                octname = argv[i];
304 >                octnm = argv[i];
305          else
306                  goto badopt;
307 <        if (octname == NULL)
307 >        if (octnm == NULL)
308                  error(USER, "missing octree argument");
309                                          /* set up output */
310   #ifdef  PERSIST
# Line 276 | Line 315 | main(int  argc, char  *argv[])
315   #endif
316          if (outform != 'a')
317                  SET_FILE_BINARY(stdout);
318 <        readoct(octname, loadflags, &thescene, NULL);
318 >        readoct(octnm, loadflags, &thescene, NULL);
319          nsceneobjs = nobjects;
320  
321          if (loadflags & IO_INFO) {      /* print header */
# Line 286 | Line 325 | main(int  argc, char  *argv[])
325                  fputformat(formstr(outform), stdout);
326                  putchar('\n');
327          }
328 <
328 >        
329 >        ray_init_pmap();     /* PMAP: set up & load photon maps */
330 >        
331          marksources();                  /* find and mark sources */
332  
333          setambient();                   /* initialize ambient calculation */
334 <
334 >        
335   #ifdef  PERSIST
336          if (persist) {
337                  fflush(stdout);
# Line 304 | Line 345 | main(int  argc, char  *argv[])
345                          while ((rval=fork()) == 0) {    /* keep on forkin' */
346                                  pflock(1);
347                                  pfhold();
348 +                                ambsync();              /* load new values */
349                          }
350                          if (rval < 0)
351                                  error(SYSTEM, "cannot fork child for persist function");
352 <                        pfdetach();             /* parent exits */
352 >                        pfdetach();             /* parent will run then exit */
353                  }
354          }
355   runagain:
# Line 315 | Line 357 | runagain:
357                  dupheader();                    /* send header to stdout */
358   #endif
359                                          /* trace rays */
360 <        rtrace(NULL);
360 >        rtrace(NULL, nproc);
361                                          /* flush ambient file */
362          ambsync();
363   #ifdef  PERSIST
# Line 330 | Line 372 | runagain:
372                  }
373          }
374          if (persist == PCHILD) {        /* wait for a signal then go again */
333                close(duped1);                  /* release output handle */
375                  pfhold();
376                  raynum = nrays = 0;             /* reinitialize */
377                  goto runagain;
378          }
379   #endif
380 +
381 +        ray_done_pmap();           /* PMAP: free photon maps */
382 +        
383          quit(0);
384  
385   badopt:
# Line 420 | Line 464 | printdefaults(void)                    /* print default values to stdou
464  
465          if (imm_irrad)
466                  printf("-I+\t\t\t\t# immediate irradiance on\n");
467 <        printf("-x  %-9d\t\t\t# x resolution (flush interval)\n", hresolu);
468 <        printf("-y  %-9d\t\t\t# y resolution\n", vresolu);
467 >        printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
468 >        printf("-x %-9d\t\t\t# %s\n", hresolu,
469 >                        vresolu && hresolu ? "x resolution" : "flush interval");
470 >        printf("-y %-9d\t\t\t# y resolution\n", vresolu);
471          printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" :
472                          "-ld-\t\t\t\t# limit distance off\n");
473          printf("-h%c\t\t\t\t# %s header\n", loadflags & IO_INFO ? '+' : '-',
# Line 435 | Line 481 | printdefaults(void)                    /* print default values to stdou
481                  case 'o': printf(" origin"); break;
482                  case 'd': printf(" direction"); break;
483                  case 'v': printf(" value"); break;
484 +                case 'V': printf(" contribution"); break;
485                  case 'l': printf(" length"); break;
486                  case 'L': printf(" first_length"); break;
487                  case 'p': printf(" point"); break;
# Line 442 | Line 489 | printdefaults(void)                    /* print default values to stdou
489                  case 'N': printf(" unperturbed_normal"); break;
490                  case 's': printf(" surface"); break;
491                  case 'w': printf(" weight"); break;
492 +                case 'W': printf(" coefficient"); break;
493                  case 'm': printf(" modifier"); break;
494                  case 'M': printf(" material"); break;
447                case 'W': printf(" contribution"); break;
495                  case '-': printf(" stroke"); break;
496                  }
497          putchar('\n');

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines