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 1.22 by greg, Mon Apr 22 14:56:28 1991 UTC vs.
Revision 2.7 by greg, Sun Mar 6 12:52:58 1994 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "glare.h"
14  
15 < #define FEQ(a,b)        ((a)-(b)<=FTINY&&(a)-(b)<=FTINY)
15 > #define FEQ(a,b)        ((a)-(b)<=FTINY&&(b)-(a)<=FTINY)
16   #define VEQ(v1,v2)      (FEQ((v1)[0],(v2)[0])&&FEQ((v1)[1],(v2)[1]) \
17                                  &&FEQ((v1)[2],(v2)[2]))
18  
19 < char    *rtargv[32] = {"rtrace", "-h", "-ov", "-fff"};
19 > char    *rtargv[32] = {"rtrace", "-h-", "-ov", "-fff"};
20   int     rtargc = 4;
21  
22   VIEW    ourview = STDVIEW;              /* our view */
# Line 55 | Line 55 | char   *argv[];
55          progname = argv[0];
56                                          /* process options */
57          for (i = 1; i < argc && argv[i][0] == '-'; i++) {
58 +                                                /* expand arguments */
59 +                while (rval = expandarg(&argc, &argv, i))
60 +                        if (rval < 0) {
61 +                                fprintf(stderr, "%s: cannot expand '%s'",
62 +                                                argv[0], argv[i]);
63 +                                exit(1);
64 +                        }
65                  rval = getviewopt(&ourview, argc-i, argv+i);
66                  if (rval >= 0) {
67                          i += rval;
# Line 75 | Line 82 | char   *argv[];
82                          }
83                          if (argv[i][2] != 'f')
84                                  goto userr;
85 <                        rval = viewfile(argv[++i], &ourview, 0, 0);
85 >                        rval = viewfile(argv[++i], &ourview, NULL);
86                          if (rval < 0) {
87                                  fprintf(stderr,
88                                  "%s: cannot open view file \"%s\"\n",
# Line 105 | Line 112 | char   *argv[];
112                          combine = !combine;
113                          break;
114                  case 'd':
115 +                        if (argv[i][2] == 'v') {
116 +                                rtargv[rtargc++] = argv[i];
117 +                                break;
118 +                        }
119 +                        /* FALL THROUGH */
120                  case 'l':
121 +                case 's':
122 +                case 'P':
123                          rtargv[rtargc++] = argv[i];
124                          rtargv[rtargc++] = argv[++i];
125                          break;
126 +                case 'w':
127 +                        rtargv[rtargc++] = argv[i];
128 +                        break;
129                  case 'a':
130                          rtargv[rtargc++] = argv[i];
131                          if (argv[i][2] == 'v') {
# Line 130 | Line 147 | char   *argv[];
147          }
148                                                  /* get view */
149          if (picture != NULL) {
150 <                rval = viewfile(picture, &pictview, 0, 0);
150 >                rval = viewfile(picture, &pictview, NULL);
151                  if (rval < 0) {
152                          fprintf(stderr, "%s: cannot open picture file \"%s\"\n",
153                                          progname, picture);
# Line 186 | Line 203 | char   *argv[];
203                  absorb_specks();                /* eliminate tiny sources */
204          cleanup();                              /* tidy up */
205                                                  /* print header */
206 +        newheader("RADIANCE", stdout);
207          printargs(argc, argv, stdout);
208          fputs(VIEWSTR, stdout);
209          fprintview(&ourview, stdout);
# Line 203 | Line 221 | userr:
221   }
222  
223  
224 + int
225 + angcmp(ap1, ap2)                /* compare two angles */
226 + ANGLE   *ap1, *ap2;
227 + {
228 +        register int    a1, a2;
229 +
230 +        a1 = *ap1;
231 +        a2 = *ap2;
232 +        if (a1 == a2) {
233 +                fprintf(stderr, "%s: duplicate glare angle (%d)\n",
234 +                                progname, a1);
235 +                exit(1);
236 +        }
237 +        return(a1-a2);
238 + }
239 +
240 +
241   init()                          /* initialize global variables */
242   {
243          double  d;
# Line 214 | Line 249 | init()                         /* initialize global variables */
249                                                  /* set direction vectors */
250          for (i = 0; glarang[i] != AEND; i++)
251                  ;
252 <        if (i > 0 && (glarang[0] <= 0 || glarang[i-1] >= 180)) {
253 <                fprintf(stderr, "%s: glare angles must be between 1 and 179\n",
252 >        qsort(glarang, i, sizeof(ANGLE), angcmp);
253 >        if (i > 0 && (glarang[0] <= 0 || glarang[i-1] > 180)) {
254 >                fprintf(stderr, "%s: glare angles must be between 1 and 180\n",
255                                  progname);
256                  exit(1);
257          }
# Line 287 | Line 323 | cleanup()                              /* close files, wait for children */
323          if (octree != NULL)
324                  done_rtrace();
325          if (npixinvw < 100*npixmiss)
326 <                fprintf(stderr, "%s: warning -- missing %ld%% of samples\n",
327 <                                progname, 100L*npixmiss/npixinvw);
326 >                fprintf(stderr, "%s: warning -- missing %d%% of samples\n",
327 >                                progname, (int)(100L*npixmiss/npixinvw));
328   }
329  
330  
# Line 336 | Line 372 | int    x, y;
372                  xo = x-hl;
373          else
374                  xo = 0;
375 <        disc = 1. - (double)(xo*xo + y*y)/(sampdens*sampdens);
376 <        if (disc <= FTINY)
375 >        disc = 1. - (double)((long)xo*xo + (long)y*y)/((long)sampdens*sampdens);
376 >        if (disc <= FTINY*FTINY)
377                  return(0.);
378          return(1./(sampdens*sampdens*sqrt(disc)));
379   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines