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.3 by greg, Tue Jul 23 17:18:21 1991 UTC vs.
Revision 1.11 by greg, Tue Aug 13 14:43:49 1991 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 25 | Line 26 | static char SCCSid[] = "$SunId$ LBL";
26   #define  S_ALL          3               /* select all */
27  
28                                  /* rtrace command and defaults */
29 < char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-ab", "2",
30 <                "-ad", "256", "-as", "128", "-aa", ".15" };
31 < int  rtargc = 13;
29 > char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "3", "-di+",
30 >                "-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", };
31 > int  rtargc = 14;
32                                  /* overriding rtrace options */
33 < char  *myrtopts[] = { "-I-", "-i-", "-di+", "-ov", "-h-", "-fff", NULL };
33 > char  *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", NULL };
34  
35   struct rtproc   rt;             /* our rtrace process */
36  
37   struct illum_args  thisillum = {        /* our illum and default values */
38                  0,
39                  DFLMAT,
40 <                DFLMAT,
40 >                DFLDAT,
41                  0,
42                  VOIDID,
43                  SAMPDENS,
# Line 58 | Line 59 | int    doneheader = 0;         /* printed header yet? */
59   int     warnings = 1;           /* print warnings? */
60  
61   extern char     *fgetline(), *fgetword(), *sskip(),
62 <                *atos(), *iskip(), *fskip();
62 >                *atos(), *iskip(), *fskip(), *strcpy();
63   extern FILE     *popen();
64  
65  
# Line 89 | Line 90 | char   *argv[];
90          rtargv[rtargc] = NULL;
91                                  /* just asking for defaults? */
92          if (!strcmp(argv[gargc-1], "-defaults")) {
93 +                printopts(); fflush(stdout);
94                  rtpath = getpath(rtargv[0], getenv("PATH"), X_OK);
95                  if (rtpath == NULL) {
96                          eputs(rtargv[0]);
# Line 103 | Line 105 | char   *argv[];
105          init();
106          if (gargc+1 < argc)
107                  for (i = gargc+1; i < argc; i++) {
108 <                        if ((fp = fopen(argv[i], "r")) == NULL {
108 >                        if ((fp = fopen(argv[i], "r")) == NULL) {
109                                  sprintf(errmsg,
110                                  "cannot open scene file \"%s\"", argv[i]);
111                                  error(SYSTEM, errmsg);
# Line 135 | Line 137 | int  status;
137  
138   init()                          /* start rtrace and set up buffers */
139   {
140 <        extern int  o_face(), o_ring();
140 >        extern int  o_face(), o_sphere(), o_ring();
141          int     maxbytes;
142                                          /* set up object functions */
143          ofun[OBJ_FACE].funp = o_face;
144 +        ofun[OBJ_SPHERE].funp = o_sphere;
145          ofun[OBJ_RING].funp = o_ring;
146                                          /* set up signal handling */
147          signal(SIGPIPE, quit);
# Line 152 | Line 155 | init()                         /* start rtrace and set up buffers */
155          if (maxbytes < 0)
156                  error(SYSTEM, "cannot start rtrace process");
157          rt.bsiz = maxbytes/(6*sizeof(float));
158 <        rt.buf = (float *)malloc(rt.bsiz*(6*sizeof(float)));
159 <        if (rt.buf == NULL)
158 >        rt.buf = (float *)malloc(6*sizeof(float)*rt.bsiz--);
159 >        rt.dest = (float **)malloc(sizeof(float *)*rt.bsiz);
160 >        if (rt.buf == NULL || rt.dest == NULL)
161                  error(SYSTEM, "out of memory in init");
158        rt.bsiz--;                      /* allow for flush ray */
162          rt.nrays = 0;
163 +                                        /* set up urand */
164 +        initurand(2048);
165   }
166  
167  
# Line 252 | Line 257 | char   *nm;
257                          if (*++cp != '=')
258                                  break;
259                          if (!*++cp) {
260 +                                strcpy(thisillum.datafile,thisillum.matname);
261 +                                thisillum.dfnum = 0;
262                                  thisillum.flags &= ~IL_DATCLB;
263                                  continue;
264                          }
# Line 262 | Line 269 | char   *nm;
269                          continue;
270                  case 'i':                       /* include material */
271                  case 'e':                       /* exclude material */
272 <                        matselect = (*cp == 'i') ? S_ELEM : S_COMPL;
266 <                        if (*++cp != '=')
272 >                        if (cp[1] != '=')
273                                  break;
274 <                        atos(matcheck, MAXSTR, ++cp);
274 >                        matselect = (*cp == 'i') ? S_ELEM : S_COMPL;
275 >                        cp += 2;
276 >                        atos(matcheck, MAXSTR, cp);
277                          cp = sskip(cp);
278                          continue;
279                  case 'a':                       /* use everything */
# Line 281 | Line 289 | char   *nm;
289                                  break;
290                          switch (*++cp) {
291                          case 'a':                       /* average */
292 <                                thisillum.flags |= IL_COLAVG;
293 <                                thisillum.flags &= ~IL_COLDST;
292 >                                thisillum.flags = (thisillum.flags|IL_COLAVG)
293 >                                                        & ~IL_COLDST;
294                                  break;
295                          case 'd':                       /* distribution */
296 <                                thisillum.flags |= IL_COLDST;
289 <                                thisillum.flags &= ~IL_COLAVG;
296 >                                thisillum.flags |= (IL_COLDST|IL_COLAVG);
297                                  break;
298                          case 'n':                       /* none */
299                                  thisillum.flags &= ~(IL_COLAVG|IL_COLDST);
# Line 313 | Line 320 | char   *nm;
320                          cp = sskip(cp);
321                          continue;
322                  case 'l':                       /* light sources */
323 <                        if (*++cp != '+' && *cp != '-')
324 <                                break;
318 <                        if (*cp++ == '+')
323 >                        cp++;
324 >                        if (*cp == '+')
325                                  thisillum.flags |= IL_LIGHT;
326 <                        else
326 >                        else if (*cp == '-')
327                                  thisillum.flags &= ~IL_LIGHT;
328 +                        else
329 +                                break;
330 +                        cp++;
331                          continue;
332                  case 'o':                       /* output file */
333                          if (*++cp != '=')
# Line 334 | Line 343 | char   *nm;
343                          }
344                          doneheader = 0;
345                          continue;
346 +                case '!':                       /* processed file! */
347 +                        sprintf(errmsg, "(%s): already processed!", nm);
348 +                        error(WARNING, errmsg);
349 +                        matselect = S_NONE;
350 +                        return;
351                  }
352          opterr:                                 /* skip faulty option */
353                  cp = sskip(cp);
# Line 351 | Line 365 | char   *nm;
365                                  progname, nerrs);
366          }
367                                                  /* print pure comment */
368 <        putchar('#'); putchar(' '); fputs(s+2, stdout);
368 >        printf("# %s", s+2);
369   }
370  
371  
372 + printopts()                     /* print out option default values */
373 + {
374 +        printf("m=%-15s\t\t# material name\n", thisillum.matname);
375 +        printf("f=%-15s\t\t# data file name\n", thisillum.datafile);
376 +        printf("c=n\t\t\t\t# color none\n");
377 +        printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens);
378 +        printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps);
379 + }
380 +
381 +
382   printhead(ac, av)                       /* print out header */
383   register int  ac;
384   register char  **av;
# Line 364 | Line 388 | register char  **av;
388                  putchar(' ');
389                  fputs(*av++, stdout);
390          }
391 <        putchar('\n');
391 >        fputs("\n#@mkillum !\n", stdout);
392   }
393  
394  
# Line 387 | Line 411 | char  *nm;
411                  printf("\n%s %s %s", thisillum.altmat, ALIASID, str);
412                  if (fgetword(str, MAXSTR, fp) == NULL)
413                          goto readerr;
414 <                printf(" %s\n", str);
414 >                printf("\t%s\n", str);
415                  return;
416          }
417 <        thisobj.omod = OVOID;
417 >        thisobj.omod = OVOID;           /* unused field */
418          if ((thisobj.otype = otype(str)) < 0) {
419                  sprintf(errmsg, "(%s): unknown type \"%s\"", nm, str);
420                  error(USER, errmsg);
# Line 407 | Line 431 | char  *nm;
431                  doit = 0;
432                  break;
433          case S_ALL:
434 <                doit = issurface(thisobj.otype);
434 >                doit = 1;
435                  break;
436          case S_ELEM:
437                  doit = !strcmp(thisillum.altmat, matcheck);
# Line 416 | Line 440 | char  *nm;
440                  doit = strcmp(thisillum.altmat, matcheck);
441                  break;
442          }
443 <        if (doit && ofun[thisobj.otype].funp == o_default) {
420 <                sprintf(errmsg, "(%s): cannot make illum for %s \"%s\"",
421 <                                nm, ofun[thisobj.otype].funame, thisobj.oname);
422 <                error(WARNING, errmsg);
423 <                doit = 0;
424 <        }
443 >        doit = doit && issurface(thisobj.otype);
444                                                  /* print header? */
445          checkhead();
446                                                  /* process object */
447          if (doit)
448 <                (*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt);
448 >                (*ofun[thisobj.otype].funp)(&thisobj, &thisillum, &rt, nm);
449          else
450                  printobj(thisillum.altmat, &thisobj);
451                                                  /* free arguments */
# Line 436 | Line 455 | readerr:
455          sprintf(errmsg, "(%s): error reading scene", nm);
456          error(USER, errmsg);
457   }
439
440
441 int
442 otype(ofname)                   /* get object function number from its name */
443 char  *ofname;
444 {
445        register int  i;
446
447        for (i = 0; i < NUMOTYPE; i++)
448                if (!strcmp(ofun[i].funame, ofname))
449                        return(i);
450
451        return(-1);             /* not found */
452 }
453
454
455 o_default() {}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines