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.5 by greg, Wed Jul 24 16:48:22 1991 UTC vs.
Revision 2.2 by greg, Wed Mar 11 11:09:57 1992 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include  <ctype.h>
16  
17                                  /* default parameters */
18 < #define  SAMPDENS       128             /* points per projected steradian */
18 > #define  SAMPDENS       48              /* points per projected steradian */
19   #define  NSAMPS         32              /* samples per point */
20   #define  DFLMAT         "illum_mat"     /* material name */
21 + #define  DFLDAT         "illum"         /* data file name */
22                                  /* selection options */
23   #define  S_NONE         0               /* select none */
24   #define  S_ELEM         1               /* select specified element */
# Line 36 | Line 37 | struct rtproc  rt;             /* our rtrace process */
37   struct illum_args  thisillum = {        /* our illum and default values */
38                  0,
39                  DFLMAT,
40 <                DFLMAT,
40 >                DFLDAT,
41                  0,
42                  VOIDID,
43                  SAMPDENS,
44                  NSAMPS,
45 +                0.,
46          };
47  
48   char    matcheck[MAXSTR];       /* current material to include or exclude */
# Line 58 | Line 60 | int    doneheader = 0;         /* printed header yet? */
60   int     warnings = 1;           /* print warnings? */
61  
62   extern char     *fgetline(), *fgetword(), *sskip(),
63 <                *atos(), *iskip(), *fskip();
63 >                *atos(), *iskip(), *fskip(), *strcpy();
64   extern FILE     *popen();
65  
66  
# Line 89 | Line 91 | char   *argv[];
91          rtargv[rtargc] = NULL;
92                                  /* just asking for defaults? */
93          if (!strcmp(argv[gargc-1], "-defaults")) {
94 +                printopts(); fflush(stdout);
95                  rtpath = getpath(rtargv[0], getenv("PATH"), X_OK);
96                  if (rtpath == NULL) {
97                          eputs(rtargv[0]);
# Line 144 | Line 147 | init()                         /* start rtrace and set up buffers */
147                                          /* set up signal handling */
148          signal(SIGPIPE, quit);
149                                          /* start rtrace process */
150 +        errno = 0;
151          maxbytes = open_process(rt.pd, rtargv);
152          if (maxbytes == 0) {
153                  eputs(rtargv[0]);
# Line 158 | Line 162 | init()                         /* start rtrace and set up buffers */
162          if (rt.buf == NULL || rt.dest == NULL)
163                  error(SYSTEM, "out of memory in init");
164          rt.nrays = 0;
165 +                                        /* set up urand */
166 +        initurand(2048);
167   }
168  
169  
# Line 253 | Line 259 | char   *nm;
259                          if (*++cp != '=')
260                                  break;
261                          if (!*++cp) {
262 +                                strcpy(thisillum.datafile,thisillum.matname);
263 +                                thisillum.dfnum = 0;
264                                  thisillum.flags &= ~IL_DATCLB;
265                                  continue;
266                          }
# Line 263 | Line 271 | char   *nm;
271                          continue;
272                  case 'i':                       /* include material */
273                  case 'e':                       /* exclude material */
274 <                        matselect = (*cp == 'i') ? S_ELEM : S_COMPL;
267 <                        if (*++cp != '=')
274 >                        if (cp[1] != '=')
275                                  break;
276 <                        atos(matcheck, MAXSTR, ++cp);
276 >                        matselect = (*cp == 'i') ? S_ELEM : S_COMPL;
277 >                        cp += 2;
278 >                        atos(matcheck, MAXSTR, cp);
279                          cp = sskip(cp);
280                          continue;
281                  case 'a':                       /* use everything */
# Line 282 | Line 291 | char   *nm;
291                                  break;
292                          switch (*++cp) {
293                          case 'a':                       /* average */
294 <                                thisillum.flags |= IL_COLAVG;
295 <                                thisillum.flags &= ~IL_COLDST;
294 >                                thisillum.flags = (thisillum.flags|IL_COLAVG)
295 >                                                        & ~IL_COLDST;
296                                  break;
297                          case 'd':                       /* distribution */
298                                  thisillum.flags |= (IL_COLDST|IL_COLAVG);
# Line 322 | Line 331 | char   *nm;
331                                  break;
332                          cp++;
333                          continue;
334 +                case 'b':                       /* brightness */
335 +                        if (*++cp != '=')
336 +                                break;
337 +                        if (!isfltd(++cp, " \t\n"))
338 +                                break;
339 +                        thisillum.minbrt = atof(cp);
340 +                        if (thisillum.minbrt < 0.)
341 +                                thisillum.minbrt = 0.;
342 +                        cp = sskip(cp);
343 +                        continue;
344                  case 'o':                       /* output file */
345                          if (*++cp != '=')
346                                  break;
# Line 336 | Line 355 | char   *nm;
355                          }
356                          doneheader = 0;
357                          continue;
358 +                case '!':                       /* processed file! */
359 +                        sprintf(errmsg, "(%s): already processed!", nm);
360 +                        error(WARNING, errmsg);
361 +                        matselect = S_NONE;
362 +                        return;
363                  }
364          opterr:                                 /* skip faulty option */
365                  cp = sskip(cp);
# Line 357 | Line 381 | char   *nm;
381   }
382  
383  
384 + printopts()                     /* print out option default values */
385 + {
386 +        printf("m=%-15s\t\t# material name\n", thisillum.matname);
387 +        printf("f=%-15s\t\t# data file name\n", thisillum.datafile);
388 +        if (thisillum.flags & IL_COLAVG)
389 +                if (thisillum.flags & IL_COLDST)
390 +                        printf("c=d\t\t\t\t# color distribution\n");
391 +                else
392 +                        printf("c=a\t\t\t\t# color average\n");
393 +        else
394 +                printf("c=n\t\t\t\t# color none\n");
395 +        if (thisillum.flags & IL_LIGHT)
396 +                printf("l+\t\t\t\t# light type on\n");
397 +        else
398 +                printf("l-\t\t\t\t# light type off\n");
399 +        printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens);
400 +        printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps);
401 +        printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt);
402 + }
403 +
404 +
405   printhead(ac, av)                       /* print out header */
406   register int  ac;
407   register char  **av;
# Line 366 | Line 411 | register char  **av;
411                  putchar(' ');
412                  fputs(*av++, stdout);
413          }
414 <        putchar('\n');
414 >        fputs("\n#@mkillum !\n", stdout);
415   }
416  
417  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines