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.9 by schorsch, Tue Mar 30 16:13:01 2004 UTC vs.
Revision 2.22 by greg, Wed Aug 7 05:10:09 2013 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7  
8   #include "copyright.h"
9  
10 #include  <sys/types.h>
10   #include  <signal.h>
11  
12   #include  "platform.h"
# Line 19 | Line 18 | static const char      RCSid[] = "$Id$";
18   #include  "random.h"
19   #include  "paths.h"
20  
21 + extern char     *progname;              /* global argv[0] */
22 +
23 + extern char     *shm_boundary;          /* boundary of shared memory */
24 +
25                                          /* persistent processes define */
26   #ifdef  F_SETLKW
27   #define  PERSIST        1               /* normal persist */
# Line 26 | Line 29 | static const char      RCSid[] = "$Id$";
29   #define  PCHILD         3               /* child of normal persist */
30   #endif
31  
29 char  *progname;                        /* argv[0] */
30 char  *octname;                         /* octree name */
32   char  *sigerr[NSIG];                    /* signal error messages */
32 char  *shm_boundary = NULL;             /* boundary of shared memory */
33   char  *errfile = NULL;                  /* error output file */
34  
35 + int  nproc = 1;                         /* number of processes */
36 +
37   extern char  *formstr();                /* string from format */
38 < extern int  inform;                     /* input format */
39 < extern int  outform;                    /* output format */
40 < extern char  *outvals;                  /* output values */
38 > int  inform = 'a';                      /* input format */
39 > int  outform = 'a';                     /* output format */
40 > char  *outvals = "v";                   /* output specification */
41  
42 < extern int  hresolu;                    /* horizontal resolution */
43 < extern int  vresolu;                    /* vertical resolution */
42 > int  hresolu = 0;                       /* horizontal (scan) size */
43 > int  vresolu = 0;                       /* vertical resolution */
44  
45 < extern int  imm_irrad;                  /* compute immediate irradiance? */
46 < extern int  lim_dist;                   /* limit distance? */
45 > int  imm_irrad = 0;                     /* compute immediate irradiance? */
46 > int  lim_dist = 0;                      /* limit distance? */
47  
48 < extern char  *tralist[];                /* list of modifers to trace (or no) */
49 < extern int  traincl;                    /* include == 1, exclude == 0 */
48 > #ifndef MAXMODLIST
49 > #define MAXMODLIST      1024            /* maximum modifiers we'll track */
50 > #endif
51  
52 + extern void  (*addobjnotify[])();       /* object notification calls */
53 + extern void  tranotify(OBJECT obj);
54 +
55 + char  *tralist[MAXMODLIST];             /* list of modifers to trace (or no) */
56 + int  traincl = -1;                      /* include == 1, exclude == 0 */
57 +
58 + static int  loadflags = ~IO_FILES;      /* what to load from octree */
59 +
60   static void onsig(int  signo);
61   static void sigdie(int  signo, char  *msg);
62   static void printdefaults(void);
# Line 64 | Line 75 | main(int  argc, char  *argv[])
75                                  case 'n': case 'N': case 'f': case 'F': \
76                                  case '-': case '0': var = 0; break; \
77                                  default: goto badopt; }
67        int  loadflags = ~IO_FILES;
78          int  persist = 0;
79 <        char  **tralp;
80 <        int  duped1;
79 >        char  *octnm = NULL;
80 >        char  **tralp = NULL;
81 >        int  duped1 = -1;
82          int  rval;
83          int  i;
84                                          /* global program name */
85          progname = argv[0] = fixargv0(argv[0]);
86 +                                        /* add trace notify function */
87 +        for (i = 0; addobjnotify[i] != NULL; i++)
88 +                ;
89 +        addobjnotify[i] = tranotify;
90 +                                        /* set our defaults */
91 +        rand_samp = 1;
92 +        maxdepth = -10;
93 +        minweight = 2e-3;
94                                          /* option city */
95          for (i = 1; i < argc; i++) {
96                                                  /* expand arguments */
# Line 98 | Line 117 | main(int  argc, char  *argv[])
117                          continue;
118                  }
119                  switch (argv[i][1]) {
120 +                case 'n':                               /* number of cores */
121 +                        check(2,"i");
122 +                        nproc = atoi(argv[++i]);
123 +                        if (nproc <= 0)
124 +                                error(USER, "bad number of processes");
125 +                        break;
126                  case 'x':                               /* x resolution */
127                          check(2,"i");
128                          hresolu = atoi(argv[++i]);
# Line 224 | Line 249 | main(int  argc, char  *argv[])
249                          goto badopt;
250                  }
251          }
252 +        if (nproc > 1) {
253 +                if (persist)
254 +                        error(USER, "multiprocessing incompatible with persist file");
255 +                if (!vresolu && hresolu > 0 && hresolu < nproc)
256 +                        error(WARNING, "number of cores should not exceed horizontal resolution");
257 +                if (trace != NULL)
258 +                        error(WARNING, "multiprocessing does not work properly with trace mode");
259 +        }
260                                          /* initialize object types */
261          initotypes();
262                                          /* initialize urand */
263 <        initurand(2048);
263 >        if (rand_samp) {
264 >                srandom((long)time(0));
265 >                initurand(0);
266 >        } else {
267 >                srandom(0L);
268 >                initurand(2048);
269 >        }
270                                          /* set up signal handling */
271          sigdie(SIGINT, "Interrupt");
272   #ifdef SIGHUP
# Line 259 | Line 298 | main(int  argc, char  *argv[])
298   #endif
299                                          /* get octree */
300          if (i == argc)
301 <                octname = NULL;
301 >                octnm = NULL;
302          else if (i == argc-1)
303 <                octname = argv[i];
303 >                octnm = argv[i];
304          else
305                  goto badopt;
306 <        if (octname == NULL)
306 >        if (octnm == NULL)
307                  error(USER, "missing octree argument");
308                                          /* set up output */
309   #ifdef  PERSIST
# Line 273 | Line 312 | main(int  argc, char  *argv[])
312                  openheader();
313          }
314   #endif
276 #ifdef  _WIN32
315          if (outform != 'a')
316                  SET_FILE_BINARY(stdout);
317 <        if (octname == NULL)
280 <                SET_FILE_BINARY(stdin);
281 < #endif
282 <        readoct(octname, loadflags, &thescene, NULL);
317 >        readoct(octnm, loadflags, &thescene, NULL);
318          nsceneobjs = nobjects;
319  
320          if (loadflags & IO_INFO) {      /* print header */
# Line 307 | Line 342 | main(int  argc, char  *argv[])
342                          while ((rval=fork()) == 0) {    /* keep on forkin' */
343                                  pflock(1);
344                                  pfhold();
345 +                                ambsync();              /* load new values */
346                          }
347                          if (rval < 0)
348                                  error(SYSTEM, "cannot fork child for persist function");
349 <                        pfdetach();             /* parent exits */
349 >                        pfdetach();             /* parent will run then exit */
350                  }
351          }
352   runagain:
# Line 318 | Line 354 | runagain:
354                  dupheader();                    /* send header to stdout */
355   #endif
356                                          /* trace rays */
357 <        rtrace(NULL);
357 >        rtrace(NULL, nproc);
358                                          /* flush ambient file */
359          ambsync();
360   #ifdef  PERSIST
# Line 333 | Line 369 | runagain:
369                  }
370          }
371          if (persist == PCHILD) {        /* wait for a signal then go again */
336                close(duped1);                  /* release output handle */
372                  pfhold();
373                  raynum = nrays = 0;             /* reinitialize */
374                  goto runagain;
# Line 423 | Line 458 | printdefaults(void)                    /* print default values to stdou
458  
459          if (imm_irrad)
460                  printf("-I+\t\t\t\t# immediate irradiance on\n");
461 <        printf("-x  %-9d\t\t\t# x resolution\n", hresolu);
462 <        printf("-y  %-9d\t\t\t# y resolution\n", vresolu);
461 >        printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
462 >        printf("-x %-9d\t\t\t# %s\n", hresolu,
463 >                        vresolu && hresolu ? "x resolution" : "flush interval");
464 >        printf("-y %-9d\t\t\t# y resolution\n", vresolu);
465          printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" :
466                          "-ld-\t\t\t\t# limit distance off\n");
467 +        printf("-h%c\t\t\t\t# %s header\n", loadflags & IO_INFO ? '+' : '-',
468 +                        loadflags & IO_INFO ? "output" : "no");
469          printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n",
470                          inform, outform, formstr(inform), formstr(outform));
471 <        printf("-o%s\t\t\t\t# output", outvals);
471 >        printf("-o%-9s\t\t\t# output", outvals);
472          for (cp = outvals; *cp; cp++)
473                  switch (*cp) {
474 <                case 't': printf(" trace"); break;
474 >                case 't': case 'T': printf(" trace"); break;
475                  case 'o': printf(" origin"); break;
476                  case 'd': printf(" direction"); break;
477                  case 'v': printf(" value"); break;
478 +                case 'V': printf(" contribution"); break;
479                  case 'l': printf(" length"); break;
480                  case 'L': printf(" first_length"); break;
481                  case 'p': printf(" point"); break;
# Line 443 | Line 483 | printdefaults(void)                    /* print default values to stdou
483                  case 'N': printf(" unperturbed_normal"); break;
484                  case 's': printf(" surface"); break;
485                  case 'w': printf(" weight"); break;
486 +                case 'W': printf(" coefficient"); break;
487                  case 'm': printf(" modifier"); break;
488 +                case 'M': printf(" material"); break;
489 +                case '-': printf(" stroke"); break;
490                  }
491          putchar('\n');
492          printf(erract[WARNING].pf != NULL ?

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines