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

Comparing ray/src/util/findglare.c (file contents):
Revision 2.10 by schorsch, Mon Jul 21 22:30:19 2003 UTC vs.
Revision 2.18 by greg, Tue Jun 3 21:31:51 2025 UTC

# Line 9 | Line 9 | static const char      RCSid[] = "$Id$";
9  
10   #include "glare.h"
11  
12 #define FEQ(a,b)        ((a)-(b)<=FTINY&&(b)-(a)<=FTINY)
13 #define VEQ(v1,v2)      (FEQ((v1)[0],(v2)[0])&&FEQ((v1)[1],(v2)[1]) \
14                                &&FEQ((v1)[2],(v2)[2]))
15
12   char    *rtargv[64] = {"rtrace", "-h-", "-ov", "-fff", "-ld-", "-i-", "-I-"};
13   int     rtargc = 7;
14  
# Line 24 | Line 20 | char   *picture = NULL;                /* picture file name */
20   char    *octree = NULL;                 /* octree file name */
21  
22   int     verbose = 0;                    /* verbose reporting */
27 char    *progname;                      /* global argv[0] */
23  
24   double  threshold = 0.;                 /* glare threshold */
25  
# Line 39 | Line 34 | struct illum   *indirect;              /* array of indirect illumina
34   long    npixinvw;                       /* number of pixels in view */
35   long    npixmiss;                       /* number of pixels missed */
36  
37 + static int angcmp(const void *ap1, const void *ap2);
38 + static void init(void);
39 + static void cleanup(void);
40 + static void printsources(void);
41 + static void printillum(void);
42  
43 < main(argc, argv)
44 < int     argc;
45 < char    *argv[];
43 >
44 >
45 > int
46 > main(
47 >        int     argc,
48 >        char    *argv[]
49 > )
50   {
51          int     combine = 1;
52          int     gotview = 0;
53          int     rval, i;
54          char    *err;
55 <
56 <        progname = argv[0];
55 >                                        /* set global progname */
56 >        fixargv0(argv[0]);
57                                          /* process options */
58          for (i = 1; i < argc && argv[i][0] == '-'; i++) {
59                                                  /* expand arguments */
60                  while ((rval = expandarg(&argc, &argv, i)) > 0)
61                          ;
62                  if (rval < 0) {
63 <                        fprintf(stderr, "%s: cannot expand '%s'",
63 >                        fprintf(stderr, "%s: cannot expand '%s'\n",
64                                          argv[0], argv[i]);
65                          exit(1);
66                  }
# Line 120 | Line 124 | char   *argv[];
124                          /* FALL THROUGH */
125                  case 's':
126                  case 'P':
127 +                case 'n':
128                          rtargv[rtargc++] = argv[i];
129                          rtargv[rtargc++] = argv[++i];
130                          break;
131                  case 'w':
132 +                case 'u':
133 +                case 'b':
134                          rtargv[rtargc++] = argv[i];
135                          break;
136                  case 'a':
# Line 134 | Line 141 | char   *argv[];
141                          }
142                          rtargv[rtargc++] = argv[++i];
143                          break;
144 +                case 'm':
145 +                        rtargv[rtargc++] = argv[i];
146 +                        if ((argv[i][2] == 'e') | (argv[i][2] == 'a')) {
147 +                                rtargv[rtargc++] = argv[++i];
148 +                                rtargv[rtargc++] = argv[++i];
149 +                        }
150 +                        rtargv[rtargc++] = argv[++i];
151 +                        break;
152                  default:
153                          goto userr;
154                  }
# Line 175 | Line 190 | char   *argv[];
190                          exit(1);
191                  }
192                  ourview = pictview;
193 <        } else if (picture != NULL && !VEQ(ourview.vp, pictview.vp)) {
193 >        } else if (picture != NULL && !VABSEQ(ourview.vp, pictview.vp)) {
194                  fprintf(stderr, "%s: picture must have same viewpoint\n",
195                                  progname);
196                  exit(1);
# Line 221 | Line 236 | userr:
236   }
237  
238  
239 < int
240 < angcmp(ap1, ap2)                /* compare two angles */
241 < ANGLE   *ap1, *ap2;
239 > static int
240 > angcmp(         /* compare two angles */
241 >        const void      *ap1,
242 >        const void      *ap2
243 > )
244   {
245 <        register int    a1, a2;
245 >        int     a1, a2;
246  
247 <        a1 = *ap1;
248 <        a2 = *ap2;
247 >        a1 = *(ANGLE *)ap1;
248 >        a2 = *(ANGLE *)ap2;
249          if (a1 == a2) {
250                  fprintf(stderr, "%s: duplicate glare angle (%d)\n",
251                                  progname, a1);
# Line 238 | Line 255 | ANGLE  *ap1, *ap2;
255   }
256  
257  
258 < init()                          /* initialize global variables */
258 > static void
259 > init(void)                              /* initialize global variables */
260   {
261          double  d;
262 <        register int    i;
262 >        int     i;
263  
264          if (verbose)
265                  fprintf(stderr, "%s: initializing data structures...\n",
# Line 314 | Line 332 | init()                         /* initialize global variables */
332   }
333  
334  
335 < cleanup()                               /* close files, wait for children */
335 > static void
336 > cleanup(void)                           /* close files, wait for children */
337   {
338          if (verbose)
339                  fprintf(stderr, "%s: cleaning up...        \n", progname);
# Line 328 | Line 347 | cleanup()                              /* close files, wait for children */
347   }
348  
349  
350 < compdir(vd, x, y)                       /* compute direction for x,y */
351 < FVECT   vd;
352 < int     x, y;
350 > int
351 > compdir(                        /* compute direction for x,y */
352 >        FVECT   vd,
353 >        int     x,
354 >        int     y
355 > )
356   {
357          int     hl;
358          FVECT   org;                    /* dummy variable */
# Line 359 | Line 381 | int    x, y;
381  
382  
383   double
384 < pixsize(x, y)           /* return the solid angle of pixel at (x,y) */
385 < int     x, y;
384 > pixsize(                /* return the solid angle of pixel at (x,y) */
385 >        int     x,
386 >        int     y
387 > )
388   {
389 <        register int    hl, xo;
389 >        int     hl, xo;
390          double  disc;
391  
392          hl = hlim(y);
# Line 379 | Line 403 | int    x, y;
403   }
404  
405  
406 < memerr(s)                       /* malloc failure */
407 < char    *s;
406 > void
407 > memerr(                 /* malloc failure */
408 >        char    *s
409 > )
410   {
411          fprintf(stderr, "%s: out of memory for %s\n", progname, s);
412          exit(1);
413   }
414  
415  
416 < printsources()                  /* print out glare sources */
416 > static void
417 > printsources(void)                      /* print out glare sources */
418   {
419 <        register struct source  *sp;
419 >        struct source   *sp;
420  
421          printf("BEGIN glare source\n");
422          for (sp = donelist; sp != NULL; sp = sp->next)
423 <                printf("\t%f %f %f\t%f\t%f\n",
423 >                printf("\t%f %f %f\t%e\t%e\n",
424                                  sp->dir[0], sp->dir[1], sp->dir[2],
425                                  sp->dom, sp->brt);
426          printf("END glare source\n");
427   }
428  
429  
430 < printillum()                    /* print out indirect illuminances */
430 > static void
431 > printillum(void)                        /* print out indirect illuminances */
432   {
433 <        register int    i;
433 >        int     i;
434  
435          printf("BEGIN indirect illuminance\n");
436          for (i = 0; i < nglardirs; i++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines