ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/gen/mkillum.c
(Generate patch)

Comparing ray/src/gen/mkillum.c (file contents):
Revision 1.7 by greg, Thu Jul 25 12:52:16 1991 UTC vs.
Revision 2.13 by schorsch, Sun Jun 8 12:03:10 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Make illum sources for optimizing rendering process
6   */
7  
11 #include  "mkillum.h"
12
8   #include  <signal.h>
14
9   #include  <ctype.h>
10 + #include  <stdio.h>
11  
12 + #include  "platform.h"
13 + #include  "mkillum.h"
14 +
15                                  /* default parameters */
16 < #define  SAMPDENS       128             /* points per projected steradian */
16 > #define  SAMPDENS       48              /* points per projected steradian */
17   #define  NSAMPS         32              /* samples per point */
18   #define  DFLMAT         "illum_mat"     /* material name */
19 + #define  DFLDAT         "illum"         /* data file name */
20                                  /* selection options */
21   #define  S_NONE         0               /* select none */
22   #define  S_ELEM         1               /* select specified element */
# Line 25 | Line 24 | static char SCCSid[] = "$SunId$ LBL";
24   #define  S_ALL          3               /* select all */
25  
26                                  /* rtrace command and defaults */
27 < char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-di+",
27 > char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-dv-",
28                  "-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", };
29   int  rtargc = 14;
30                                  /* overriding rtrace options */
31 < char  *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", NULL };
31 > char  *myrtopts[] = { "-I-", "-i-", "-ld-", "-ov", "-h-",
32 >                        "-fff", "-y", "0", NULL };
33  
34   struct rtproc   rt;             /* our rtrace process */
35  
36   struct illum_args  thisillum = {        /* our illum and default values */
37                  0,
38                  DFLMAT,
39 <                DFLMAT,
39 >                DFLDAT,
40                  0,
41                  VOIDID,
42                  SAMPDENS,
43                  NSAMPS,
44 +                0.,
45          };
46  
47   char    matcheck[MAXSTR];       /* current material to include or exclude */
# Line 57 | Line 58 | int    doneheader = 0;         /* printed header yet? */
58  
59   int     warnings = 1;           /* print warnings? */
60  
60 extern char     *fgetline(), *fgetword(), *sskip(),
61                *atos(), *iskip(), *fskip(), *strcpy();
62 extern FILE     *popen();
61  
64
62   main(argc, argv)                /* compute illum distributions using rtrace */
63   int     argc;
64   char    *argv[];
65   {
69        extern char     *getenv(), *getpath();
66          char    *rtpath;
67          FILE    *fp;
68          register int    i;
# Line 74 | Line 70 | char   *argv[];
70          gargv = argv;
71                                  /* set up rtrace command */
72          for (i = 1; i < argc; i++) {
73 <                if (argv[i][0] == '<' && !argv[i][1])
73 >                if (argv[i][0] == '<' && argv[i][1] == '\0')
74                          break;
75                  rtargv[rtargc++] = argv[i];
76                  if (argv[i][0] == '-' && argv[i][1] == 'w')
77 <                        warnings = !warnings;
77 >                        switch (argv[i][2]) {
78 >                        case '\0':
79 >                                warnings = !warnings;
80 >                                break;
81 >                        case '+':
82 >                        case 'T': case 't':
83 >                        case 'Y': case 'y':
84 >                        case '1':
85 >                                warnings = 1;
86 >                                break;
87 >                        case '-':
88 >                        case 'F': case 'f':
89 >                        case 'N': case 'n':
90 >                        case '0':
91 >                                warnings = 0;
92 >                                break;
93 >                        }
94          }
95 <        if ((gargc = i) < 2)
84 <                error(USER, "too few arguments");
95 >        gargc = i;
96          rtargc--;
97          for (i = 0; myrtopts[i] != NULL; i++)
98                  rtargv[rtargc++] = myrtopts[i];
# Line 89 | Line 100 | char   *argv[];
100          rtargv[rtargc] = NULL;
101                                  /* just asking for defaults? */
102          if (!strcmp(argv[gargc-1], "-defaults")) {
103 +                printopts(); fflush(stdout);
104                  rtpath = getpath(rtargv[0], getenv("PATH"), X_OK);
105                  if (rtpath == NULL) {
106                          eputs(rtargv[0]);
# Line 99 | Line 111 | char   *argv[];
111                  perror(rtpath);
112                  exit(1);
113          }
114 +        if (gargc < 2 || argv[gargc-1][0] == '-')
115 +                error(USER, "missing octree argument");
116                                  /* else initialize and run our calculation */
117          init();
118          if (gargc+1 < argc)
# Line 117 | Line 131 | char   *argv[];
131   }
132  
133  
134 + void
135   quit(status)                    /* exit with status */
136   int  status;
137   {
# Line 142 | Line 157 | init()                         /* start rtrace and set up buffers */
157          ofun[OBJ_SPHERE].funp = o_sphere;
158          ofun[OBJ_RING].funp = o_ring;
159                                          /* set up signal handling */
160 + #ifndef _WIN32 /* XXX what do we use instead? */
161          signal(SIGPIPE, quit);
162 + #endif
163                                          /* start rtrace process */
164 +        errno = 0;
165          maxbytes = open_process(rt.pd, rtargv);
166          if (maxbytes == 0) {
167                  eputs(rtargv[0]);
# Line 159 | Line 177 | init()                         /* start rtrace and set up buffers */
177                  error(SYSTEM, "out of memory in init");
178          rt.nrays = 0;
179                                          /* set up urand */
180 <        initurand(2048);
180 >        initurand(16384);
181   }
182  
183  
184 + void
185   eputs(s)                                /* put string to stderr */
186   register char  *s;
187   {
# Line 178 | Line 197 | register char  *s;
197   }
198  
199  
200 + void
201   wputs(s)                        /* print warning if enabled */
202   char  *s;
203   {
# Line 237 | Line 257 | char   *nm;
257                  case ' ':
258                  case '\t':
259                  case '\n':
260 +                case '\r':
261 +                case '\f':
262                          cp++;
263                          continue;
264                  case 'm':                       /* material name */
265                          if (*++cp != '=')
266                                  break;
267 <                        if (!*++cp)
267 >                        if (!*++cp || isspace(*cp))
268                                  break;
269                          atos(thisillum.matname, MAXSTR, cp);
270                          cp = sskip(cp);
# Line 254 | Line 276 | char   *nm;
276                  case 'f':                       /* data file name */
277                          if (*++cp != '=')
278                                  break;
279 <                        if (!*++cp) {
279 >                        if (!*++cp || isspace(*cp)) {
280                                  strcpy(thisillum.datafile,thisillum.matname);
281 +                                thisillum.dfnum = 0;
282                                  thisillum.flags &= ~IL_DATCLB;
283                                  continue;
284                          }
# Line 303 | Line 326 | char   *nm;
326                  case 'd':                       /* point sample density */
327                          if (*++cp != '=')
328                                  break;
329 <                        if (!isintd(++cp, " \t\n"))
329 >                        if (!isintd(++cp, " \t\n\r"))
330                                  break;
331                          thisillum.sampdens = atoi(cp);
332                          cp = sskip(cp);
# Line 311 | Line 334 | char   *nm;
334                  case 's':                       /* point super-samples */
335                          if (*++cp != '=')
336                                  break;
337 <                        if (!isintd(++cp, " \t\n"))
337 >                        if (!isintd(++cp, " \t\n\r"))
338                                  break;
339                          thisillum.nsamps = atoi(cp);
340                          cp = sskip(cp);
# Line 326 | Line 349 | char   *nm;
349                                  break;
350                          cp++;
351                          continue;
352 +                case 'b':                       /* brightness */
353 +                        if (*++cp != '=')
354 +                                break;
355 +                        if (!isfltd(++cp, " \t\n\r"))
356 +                                break;
357 +                        thisillum.minbrt = atof(cp);
358 +                        if (thisillum.minbrt < 0.)
359 +                                thisillum.minbrt = 0.;
360 +                        cp = sskip(cp);
361 +                        continue;
362                  case 'o':                       /* output file */
363                          if (*++cp != '=')
364                                  break;
365 <                        if (!*++cp)
365 >                        if (!*++cp || isspace(*cp))
366                                  break;
367                          atos(buf, sizeof(buf), cp);
368                          cp = sskip(cp);
# Line 347 | Line 380 | char   *nm;
380                          return;
381                  }
382          opterr:                                 /* skip faulty option */
383 <                cp = sskip(cp);
383 >                while (*cp && !isspace(*cp))
384 >                        cp++;
385                  nerrs++;
386          }
387                                                  /* print header? */
# Line 366 | Line 400 | char   *nm;
400   }
401  
402  
403 + printopts()                     /* print out option default values */
404 + {
405 +        printf("m=%-15s\t\t# material name\n", thisillum.matname);
406 +        printf("f=%-15s\t\t# data file name\n", thisillum.datafile);
407 +        if (thisillum.flags & IL_COLAVG)
408 +                if (thisillum.flags & IL_COLDST)
409 +                        printf("c=d\t\t\t\t# color distribution\n");
410 +                else
411 +                        printf("c=a\t\t\t\t# color average\n");
412 +        else
413 +                printf("c=n\t\t\t\t# color none\n");
414 +        if (thisillum.flags & IL_LIGHT)
415 +                printf("l+\t\t\t\t# light type on\n");
416 +        else
417 +                printf("l-\t\t\t\t# light type off\n");
418 +        printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens);
419 +        printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps);
420 +        printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt);
421 + }
422 +
423 +
424   printhead(ac, av)                       /* print out header */
425   register int  ac;
426   register char  **av;
# Line 392 | Line 447 | char  *nm;
447          if (fgetword(str, MAXSTR, fp) == NULL)
448                  goto readerr;
449                                          /* is it an alias? */
450 <        if (!strcmp(str, ALIASID)) {
450 >        if (!strcmp(str, ALIASKEY)) {
451                  if (fgetword(str, MAXSTR, fp) == NULL)
452                          goto readerr;
453 <                printf("\n%s %s %s", thisillum.altmat, ALIASID, str);
453 >                printf("\n%s %s %s", thisillum.altmat, ALIASKEY, str);
454                  if (fgetword(str, MAXSTR, fp) == NULL)
455                          goto readerr;
456                  printf("\t%s\n", str);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines