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

Comparing src/gen/mkillum.c (file contents):
Revision 2.31 by greg, Fri Sep 21 05:53:21 2007 UTC vs.
Revision 2.47 by greg, Wed Apr 23 02:35:26 2025 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8   #include  <signal.h>
9   #include  <ctype.h>
10  
11 < #include  "platform.h"
11 > #include  "paths.h"             /* win_popen() */
12   #include  "mkillum.h"
13 < #include  "random.h"
13 > #include  "func.h"
14  
15                                  /* default parameters */
16   #define  SAMPDENS       48              /* points per projected steradian */
# Line 25 | Line 25 | static const char RCSid[] = "$Id$";
25  
26   struct illum_args  thisillum = {        /* our illum and default values */
27                  0,
28                UDzpos,
29                0.,
28                  DFLMAT,
29                  DFLDAT,
30                  0,
31                  VOIDID,
32                  SAMPDENS,
33                  NSAMPS,
36                NULL,
34                  0.,
35          };
36  
# Line 49 | Line 46 | int    doneheader = 0;         /* printed header yet? */
46   int     warnings = 1;           /* print warnings? */
47  
48   void init(char *octnm, int np);
49 < void filter(register FILE       *infp, char     *name);
49 > void filter(FILE        *infp, char     *name);
50   void xoptions(char      *s, char        *nm);
51   void printopts(void);
52 < void printhead(register int  ac, register char  **av);
52 > void printhead(int  ac, char  **av);
53   void xobject(FILE  *fp, char  *nm);
54  
55  
# Line 65 | Line 62 | main(          /* compute illum distributions using rtrace */
62          int     nprocs = 1;
63          FILE    *fp;
64          int     rval;
65 <        register int    i;
65 >        int     i;
66                                  /* set global arguments */
67          gargv = argv;
68          progname = gargv[0];
69                                  /* set up rendering defaults */
70 <        dstrsrc = 0.25;
70 >        dstrsrc = 0.5;
71          directrelay = 3;
75        directvis = 0;
72          ambounce = 2;
73 +                                /* initialize calcomp routines */
74 +        initfunc();
75                                  /* get options from command line */
76          for (i = 1; i < argc; i++) {
77                  while ((rval = expandarg(&argc, &argv, i)) > 0)
# Line 153 | Line 151 | init(char *octnm, int np)              /* start rendering process(
151  
152   void
153   eputs(                          /* put string to stderr */
154 <        register char  *s
154 >        const char  *s
155   )
156   {
157          static int  midline = 0;
# Line 169 | Line 167 | eputs(                         /* put string to stderr */
167  
168  
169   void
170 < wputs(s)                        /* print warning if enabled */
173 < char  *s;
170 > wputs(const char *s)                    /* print warning if enabled */
171   {
172          if (warnings)
173                  eputs(s);
# Line 178 | Line 175 | char  *s;
175  
176  
177   void
178 + quit(int ec)                    /* make sure exit is called */
179 + {
180 +        if (ray_pnprocs > 0)    /* close children if any */
181 +                ray_pclose(0);
182 +        else if (ray_pnprocs < 0)
183 +                _exit(ec);      /* avoid flush() in child */
184 +        exit(ec);
185 + }
186 +
187 +
188 + void
189   filter(         /* process stream */
190 <        register FILE   *infp,
190 >        FILE    *infp,
191          char    *name
192   )
193   {
194          char    buf[512];
195          FILE    *pfp;
196 <        register int    c;
196 >        int     c;
197  
198          while ((c = getc(infp)) != EOF) {
199                  if (isspace(c))
# Line 202 | Line 210 | filter(                /* process stream */
210                                  error(SYSTEM, errmsg);
211                          }
212                          filter(pfp, buf);
213 <                        pclose(pfp);
213 >                        if (pclose(pfp) != 0) {
214 >                                sprintf(errmsg, "bad status from \"%s\"", buf);
215 >                                error(WARNING, errmsg);
216 >                        }
217                  } else {                                /* object */
218                          ungetc(c, infp);
219                          xobject(infp, name);
# Line 217 | Line 228 | xoptions(                      /* process options in string s */
228          char    *nm
229   )
230   {
220        extern FILE     *freopen();
231          char    buf[64];
232          int     negax;
233          int     nerrs = 0;
234 <        register char   *cp;
234 >        char    *cp;
235  
236          if (strncmp(s, "#@mkillum", 9) || !isspace(s[9])) {
237                  fputs(s, stdout);               /* not for us */
# Line 299 | Line 309 | xoptions(                      /* process options in string s */
309                          }
310                          cp = sskip(cp);
311                          continue;
312 <                case 'd':                       /* sample density / BSDF data */
312 >                case 'd':                       /* sample density */
313                          if (*++cp != '=')
314                                  break;
305                        if (thisillum.sd != NULL) {
306                                free_BSDF(thisillum.sd);
307                                thisillum.sd = NULL;
308                        }
315                          if (!*++cp || isspace(*cp))
316                                  continue;
317 <                        if (isintd(++cp, " \t\n\r")) {
317 >                        if (isintd(cp, " \t\n\r")) {
318                                  thisillum.sampdens = atoi(cp);
319                          } else {
320 <                                atos(buf, sizeof(buf), cp);
321 <                                thisillum.sd = load_BSDF(buf);
316 <                                if (thisillum.sd == NULL)
317 <                                        break;
320 >                                error(WARNING, "direct BSDF input unsupported");
321 >                                goto opterr;
322                          }
323                          cp = sskip(cp);
324                          continue;
# Line 360 | Line 364 | xoptions(                      /* process options in string s */
364                          }
365                          doneheader = 0;
366                          continue;
363                case 'u':                       /* up direction */
364                        if (*++cp != '=')
365                                break;
366                        if (!*++cp || isspace(*cp)) {
367                                thisillum.udir = UDunknown;
368                                continue;
369                        }
370                        negax = 0;
371                        if (*cp == '+')
372                                cp++;
373                        else if (*cp == '-') {
374                                negax++;
375                                cp++;
376                        }
377                        switch (*cp++) {
378                        case 'x':
379                        case 'X':
380                                thisillum.udir = negax ? UDxneg : UDxpos;
381                                break;
382                        case 'y':
383                        case 'Y':
384                                thisillum.udir = negax ? UDyneg : UDypos;
385                                break;
386                        case 'z':
387                        case 'Z':
388                                thisillum.udir = negax ? UDxneg : UDxpos;
389                                break;
390                        default:
391                                thisillum.udir = UDunknown;
392                                break;
393                        }
394                        if (thisillum.udir == UDunknown || !isspace(*cp))
395                                break;
396                        continue;
397                case 't':                       /* object thickness */
398                        if (*++cp != '=')
399                                break;
400                        if (!isfltd(++cp, " \t\n\r"))
401                                break;
402                        thisillum.thick = atof(cp);
403                        if (thisillum.thick < .0)
404                                thisillum.thick = .0;
405                        cp = sskip(cp);
406                        continue;
367                  case '!':                       /* processed file! */
368                          sprintf(errmsg, "(%s): already processed!", nm);
369                          error(WARNING, errmsg);
# Line 446 | Line 406 | printopts(void)                        /* print out option default values *
406                  printf("l+\t\t\t\t# light type on\n");
407          else
408                  printf("l-\t\t\t\t# light type off\n");
409 <        printf("d=%d\t\t\t\t# density of points\n", thisillum.sampdens);
410 <        printf("s=%d\t\t\t\t# samples per point\n", thisillum.nsamps);
409 >        printf("d=%d\t\t\t\t# density of directions\n", thisillum.sampdens);
410 >        printf("s=%d\t\t\t\t# samples per direction\n", thisillum.nsamps);
411          printf("b=%f\t\t\t# minimum average brightness\n", thisillum.minbrt);
452        switch (thisillum.udir) {
453        case UDzneg:
454                fputs("u=-Z\t\t\t\t# up is negative Z\n", stdout);
455                break;
456        case UDyneg:
457                fputs("u=-Y\t\t\t\t# up is negative Y\n", stdout);
458                break;
459        case UDxneg:
460                fputs("u=-X\t\t\t\t# up is negative X\n", stdout);
461                break;
462        case UDxpos:
463                fputs("u=+X\t\t\t\t# up is positive X\n", stdout);
464                break;
465        case UDypos:
466                fputs("u=+Y\t\t\t\t# up is positive Y\n", stdout);
467                break;
468        case UDzpos:
469                fputs("u=+Z\t\t\t\t# up is positive Z\n", stdout);
470                break;
471        case UDunknown:
472                break;
473        }
474        printf("t=%f\t\t\t# object thickness\n", thisillum.thick);
412   }
413  
414  
415   void
416   printhead(                      /* print out header */
417 <        register int  ac,
418 <        register char  **av
417 >        int  ac,
418 >        char  **av
419   )
420   {
421          putchar('#');

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines