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 2.6 by greg, Tue Sep 21 17:09:59 1993 UTC vs.
Revision 2.16 by schorsch, Mon Jul 21 22:30:18 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  
11 + #include  "mkillum.h"
12 + #include  "platform.h"
13 +
14                                  /* default parameters */
15   #define  SAMPDENS       48              /* points per projected steradian */
16   #define  NSAMPS         32              /* samples per point */
# Line 30 | Line 27 | char  *rtargv[64] = { "rtrace", "-dj", ".25", "-dr", "
27                  "-ab", "2", "-ad", "256", "-as", "128", "-aa", ".15", };
28   int  rtargc = 14;
29                                  /* overriding rtrace options */
30 < char  *myrtopts[] = { "-I-", "-i-", "-ov", "-h-", "-fff", "-y", "0", NULL };
30 > char  *myrtopts[] = { "-I-", "-i-", "-ld-", "-ov", "-h-",
31 >                        "-fff", "-y", "0", NULL };
32  
33   struct rtproc   rt;             /* our rtrace process */
34  
# Line 59 | Line 57 | int    doneheader = 0;         /* printed header yet? */
57  
58   int     warnings = 1;           /* print warnings? */
59  
62 extern char     *fgetline(), *fgetword(), *sskip(),
63                *atos(), *iskip(), *fskip(), *strcpy();
64 extern FILE     *popen();
60  
66
61   main(argc, argv)                /* compute illum distributions using rtrace */
62   int     argc;
63   char    *argv[];
64   {
71        extern char     *getenv(), *getpath();
65          char    *rtpath;
66          FILE    *fp;
67          register int    i;
# Line 137 | Line 130 | char   *argv[];
130   }
131  
132  
133 + void
134   quit(status)                    /* exit with status */
135   int  status;
136   {
137          int     rtstat;
138  
139 <        rtstat = close_process(rt.pd);
140 <        if (status == 0)
139 >        rtstat = close_process(&(rt.pd));
140 >        if (status == 0) {
141                  if (rtstat < 0)
142                          error(WARNING,
143                          "unknown return status from rtrace process");
144                  else
145                          status = rtstat;
146 +        }
147          exit(status);
148   }
149  
# Line 162 | 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 + #ifdef SIGPIPE /* not present on Windows */
161          signal(SIGPIPE, quit);
162 + #endif
163                                          /* start rtrace process */
164          errno = 0;
165 <        maxbytes = open_process(rt.pd, rtargv);
165 >        maxbytes = open_process(&(rt.pd), rtargv);
166          if (maxbytes == 0) {
167                  eputs(rtargv[0]);
168                  eputs(": command not found\n");
# Line 180 | 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 199 | Line 197 | register char  *s;
197   }
198  
199  
200 + void
201   wputs(s)                        /* print warning if enabled */
202   char  *s;
203   {
# Line 258 | 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 275 | 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;
# Line 325 | 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 333 | 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 351 | Line 352 | char   *nm;
352                  case 'b':                       /* brightness */
353                          if (*++cp != '=')
354                                  break;
355 <                        if (!isfltd(++cp, " \t\n"))
355 >                        if (!isfltd(++cp, " \t\n\r"))
356                                  break;
357                          thisillum.minbrt = atof(cp);
358                          if (thisillum.minbrt < 0.)
# Line 361 | Line 362 | char   *nm;
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 379 | 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 445 | 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