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.1 by greg, Tue Nov 12 17:19:13 1991 UTC vs.
Revision 2.15 by greg, Fri Feb 12 00:53:56 2021 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   * Find glare sources in a scene or image.
6   *
# Line 12 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
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]) \
17 <                                &&FEQ((v1)[2],(v2)[2]))
12 > char    *rtargv[64] = {"rtrace", "-h-", "-ov", "-fff", "-ld-", "-i-", "-I-"};
13 > int     rtargc = 7;
14  
19 char    *rtargv[32] = {"rtrace", "-h-", "-ov", "-fff"};
20 int     rtargc = 4;
21
15   VIEW    ourview = STDVIEW;              /* our view */
16   VIEW    pictview = STDVIEW;             /* picture view */
17   VIEW    leftview, rightview;            /* leftmost and rightmost views */
# Line 42 | Line 35 | struct illum   *indirect;              /* array of indirect illumina
35   long    npixinvw;                       /* number of pixels in view */
36   long    npixmiss;                       /* number of pixels missed */
37  
38 + static int angcmp(const void *ap1, const void *ap2);
39 + static void init(void);
40 + static void cleanup(void);
41 + static void printsources(void);
42 + static void printillum(void);
43  
44 < main(argc, argv)
45 < int     argc;
46 < char    *argv[];
44 >
45 >
46 > int
47 > main(
48 >        int     argc,
49 >        char    *argv[]
50 > )
51   {
52          int     combine = 1;
53          int     gotview = 0;
# Line 55 | Line 57 | char   *argv[];
57          progname = argv[0];
58                                          /* process options */
59          for (i = 1; i < argc && argv[i][0] == '-'; i++) {
60 +                                                /* expand arguments */
61 +                while ((rval = expandarg(&argc, &argv, i)) > 0)
62 +                        ;
63 +                if (rval < 0) {
64 +                        fprintf(stderr, "%s: cannot expand '%s'\n",
65 +                                        argv[0], argv[i]);
66 +                        exit(1);
67 +                }
68                  rval = getviewopt(&ourview, argc-i, argv+i);
69                  if (rval >= 0) {
70                          i += rval;
# Line 75 | Line 85 | char   *argv[];
85                          }
86                          if (argv[i][2] != 'f')
87                                  goto userr;
88 <                        rval = viewfile(argv[++i], &ourview, 0, 0);
88 >                        rval = viewfile(argv[++i], &ourview, NULL);
89                          if (rval < 0) {
90                                  fprintf(stderr,
91                                  "%s: cannot open view file \"%s\"\n",
# Line 105 | Line 115 | char   *argv[];
115                          combine = !combine;
116                          break;
117                  case 'd':
118 +                        rtargv[rtargc++] = argv[i];
119 +                        if (argv[i][2] != 'v')
120 +                                rtargv[rtargc++] = argv[++i];
121 +                        break;
122                  case 'l':
123 +                        if (argv[i][2] == 'd')
124 +                                break;
125 +                        /* FALL THROUGH */
126 +                case 's':
127 +                case 'P':
128 +                case 'n':
129                          rtargv[rtargc++] = argv[i];
130                          rtargv[rtargc++] = argv[++i];
131                          break;
132 +                case 'w':
133 +                case 'u':
134 +                case 'b':
135 +                        rtargv[rtargc++] = argv[i];
136 +                        break;
137                  case 'a':
138                          rtargv[rtargc++] = argv[i];
139                          if (argv[i][2] == 'v') {
# Line 117 | Line 142 | char   *argv[];
142                          }
143                          rtargv[rtargc++] = argv[++i];
144                          break;
145 +                case 'm':
146 +                        rtargv[rtargc++] = argv[i];
147 +                        if ((argv[i][2] == 'e') | (argv[i][2] == 'a')) {
148 +                                rtargv[rtargc++] = argv[++i];
149 +                                rtargv[rtargc++] = argv[++i];
150 +                        }
151 +                        rtargv[rtargc++] = argv[++i];
152 +                        break;
153                  default:
154                          goto userr;
155                  }
# Line 130 | Line 163 | char   *argv[];
163          }
164                                                  /* get view */
165          if (picture != NULL) {
166 <                rval = viewfile(picture, &pictview, 0, 0);
166 >                rval = viewfile(picture, &pictview, NULL);
167                  if (rval < 0) {
168                          fprintf(stderr, "%s: cannot open picture file \"%s\"\n",
169                                          progname, picture);
# Line 157 | Line 190 | char   *argv[];
190                                          progname);
191                          exit(1);
192                  }
193 <                copystruct(&ourview, &pictview);
194 <        } else if (picture != NULL && !VEQ(ourview.vp, pictview.vp)) {
193 >                ourview = pictview;
194 >        } else if (picture != NULL && !VABSEQ(ourview.vp, pictview.vp)) {
195                  fprintf(stderr, "%s: picture must have same viewpoint\n",
196                                  progname);
197                  exit(1);
# Line 186 | Line 219 | char   *argv[];
219                  absorb_specks();                /* eliminate tiny sources */
220          cleanup();                              /* tidy up */
221                                                  /* print header */
222 +        newheader("RADIANCE", stdout);
223          printargs(argc, argv, stdout);
224          fputs(VIEWSTR, stdout);
225          fprintview(&ourview, stdout);
# Line 203 | Line 237 | userr:
237   }
238  
239  
240 < int
241 < angcmp(ap1, ap2)                /* compare two angles */
242 < ANGLE   *ap1, *ap2;
240 > static int
241 > angcmp(         /* compare two angles */
242 >        const void      *ap1,
243 >        const void      *ap2
244 > )
245   {
246          register int    a1, a2;
247  
248 <        a1 = *ap1;
249 <        a2 = *ap2;
248 >        a1 = *(ANGLE *)ap1;
249 >        a2 = *(ANGLE *)ap2;
250          if (a1 == a2) {
251                  fprintf(stderr, "%s: duplicate glare angle (%d)\n",
252                                  progname, a1);
# Line 220 | Line 256 | ANGLE  *ap1, *ap2;
256   }
257  
258  
259 < init()                          /* initialize global variables */
259 > static void
260 > init(void)                              /* initialize global variables */
261   {
262          double  d;
263          register int    i;
# Line 251 | Line 288 | init()                         /* initialize global variables */
288          if (indirect == NULL)
289                  memerr("indirect illuminances");
290          npixinvw = npixmiss = 0L;
291 <        copystruct(&leftview, &ourview);
292 <        copystruct(&rightview, &ourview);
291 >        leftview = ourview;
292 >        rightview = ourview;
293          spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta);
294          spinvector(rightview.vdir, ourview.vdir, ourview.vup, -maxtheta);
295          setview(&leftview);
# Line 296 | Line 333 | init()                         /* initialize global variables */
333   }
334  
335  
336 < cleanup()                               /* close files, wait for children */
336 > static void
337 > cleanup(void)                           /* close files, wait for children */
338   {
339          if (verbose)
340                  fprintf(stderr, "%s: cleaning up...        \n", progname);
# Line 305 | Line 343 | cleanup()                              /* close files, wait for children */
343          if (octree != NULL)
344                  done_rtrace();
345          if (npixinvw < 100*npixmiss)
346 <                fprintf(stderr, "%s: warning -- missing %ld%% of samples\n",
347 <                                progname, 100L*npixmiss/npixinvw);
346 >                fprintf(stderr, "%s: warning -- missing %d%% of samples\n",
347 >                                progname, (int)(100L*npixmiss/npixinvw));
348   }
349  
350  
351 < compdir(vd, x, y)                       /* compute direction for x,y */
352 < FVECT   vd;
353 < int     x, y;
351 > extern int
352 > compdir(                        /* compute direction for x,y */
353 >        FVECT   vd,
354 >        int     x,
355 >        int     y
356 > )
357   {
358          int     hl;
359          FVECT   org;                    /* dummy variable */
# Line 340 | Line 381 | int    x, y;
381   }
382  
383  
384 < double
385 < pixsize(x, y)           /* return the solid angle of pixel at (x,y) */
386 < int     x, y;
384 > extern double
385 > pixsize(                /* return the solid angle of pixel at (x,y) */
386 >        int     x,
387 >        int     y
388 > )
389   {
390          register int    hl, xo;
391          double  disc;
# Line 354 | Line 397 | int    x, y;
397                  xo = x-hl;
398          else
399                  xo = 0;
400 <        disc = 1. - (double)(xo*xo + y*y)/(sampdens*sampdens);
401 <        if (disc <= FTINY)
400 >        disc = 1. - (double)((long)xo*xo + (long)y*y)/((long)sampdens*sampdens);
401 >        if (disc <= FTINY*FTINY)
402                  return(0.);
403          return(1./(sampdens*sampdens*sqrt(disc)));
404   }
405  
406  
407 < memerr(s)                       /* malloc failure */
408 < char    *s;
407 > extern void
408 > memerr(                 /* malloc failure */
409 >        char    *s
410 > )
411   {
412          fprintf(stderr, "%s: out of memory for %s\n", progname, s);
413          exit(1);
414   }
415  
416  
417 < printsources()                  /* print out glare sources */
417 > static void
418 > printsources(void)                      /* print out glare sources */
419   {
420          register struct source  *sp;
421  
# Line 382 | Line 428 | printsources()                 /* print out glare sources */
428   }
429  
430  
431 < printillum()                    /* print out indirect illuminances */
431 > static void
432 > printillum(void)                        /* print out indirect illuminances */
433   {
434          register int    i;
435  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines