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.20 by greg, Mon Apr 22 08:21:01 1991 UTC vs.
Revision 2.4 by greg, Mon Dec 7 09:13:58 1992 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 75 | Line 75 | char   *argv[];
75                          }
76                          if (argv[i][2] != 'f')
77                                  goto userr;
78 <                        rval = viewfile(argv[++i], &ourview, 0, 0);
78 >                        rval = viewfile(argv[++i], &ourview, NULL);
79                          if (rval < 0) {
80                                  fprintf(stderr,
81                                  "%s: cannot open view file \"%s\"\n",
# Line 105 | Line 105 | char   *argv[];
105                          combine = !combine;
106                          break;
107                  case 'd':
108 +                        if (argv[i][2] == 'v') {
109 +                                rtargv[rtargc++] = argv[i];
110 +                                break;
111 +                        }
112 +                        /* FALL THROUGH */
113                  case 'l':
114 +                case 's':
115                          rtargv[rtargc++] = argv[i];
116                          rtargv[rtargc++] = argv[++i];
117                          break;
118 +                case 'w':
119 +                        rtargv[rtargc++] = argv[i];
120 +                        break;
121                  case 'a':
122                          rtargv[rtargc++] = argv[i];
123                          if (argv[i][2] == 'v') {
# Line 130 | Line 139 | char   *argv[];
139          }
140                                                  /* get view */
141          if (picture != NULL) {
142 <                rval = viewfile(picture, &pictview, 0, 0);
142 >                rval = viewfile(picture, &pictview, NULL);
143                  if (rval < 0) {
144                          fprintf(stderr, "%s: cannot open picture file \"%s\"\n",
145                                          progname, picture);
# Line 190 | Line 199 | char   *argv[];
199          fputs(VIEWSTR, stdout);
200          fprintview(&ourview, stdout);
201          printf("\n");
202 <        fputformat("ASCII", stdout);
202 >        fputformat("ascii", stdout);
203          printf("\n");
204          printsources();                         /* print glare sources */
205          printillum();                           /* print illuminances */
# Line 203 | Line 212 | userr:
212   }
213  
214  
215 + int
216 + angcmp(ap1, ap2)                /* compare two angles */
217 + ANGLE   *ap1, *ap2;
218 + {
219 +        register int    a1, a2;
220 +
221 +        a1 = *ap1;
222 +        a2 = *ap2;
223 +        if (a1 == a2) {
224 +                fprintf(stderr, "%s: duplicate glare angle (%d)\n",
225 +                                progname, a1);
226 +                exit(1);
227 +        }
228 +        return(a1-a2);
229 + }
230 +
231 +
232   init()                          /* initialize global variables */
233   {
234          double  d;
# Line 214 | Line 240 | init()                         /* initialize global variables */
240                                                  /* set direction vectors */
241          for (i = 0; glarang[i] != AEND; i++)
242                  ;
243 <        if (i > 0 && (glarang[0] <= 0 || glarang[i-1] >= 180)) {
244 <                fprintf(stderr, "%s: glare angles must be between 1 and 179\n",
243 >        qsort(glarang, i, sizeof(ANGLE), angcmp);
244 >        if (i > 0 && (glarang[0] <= 0 || glarang[i-1] > 180)) {
245 >                fprintf(stderr, "%s: glare angles must be between 1 and 180\n",
246                                  progname);
247                  exit(1);
248          }
# Line 287 | Line 314 | cleanup()                              /* close files, wait for children */
314          if (octree != NULL)
315                  done_rtrace();
316          if (npixinvw < 100*npixmiss)
317 <                fprintf(stderr, "%s: warning -- missing %ld%% of samples\n",
318 <                                progname, 100L*npixmiss/npixinvw);
317 >                fprintf(stderr, "%s: warning -- missing %d%% of samples\n",
318 >                                progname, (int)(100L*npixmiss/npixinvw));
319   }
320  
321  
# Line 300 | Line 327 | int    x, y;
327          FVECT   org;                    /* dummy variable */
328  
329          hl = hlim(y);
330 <        if (x <= -hl)                   /* left region */
330 >        if (x <= -hl) {                 /* left region */
331 >                if (x <= -hl-sampdens)
332 >                        return(-1);
333                  return(viewray(org, vd, &leftview,
334                                  (double)(x+hl)/(2*sampdens)+.5,
335                                  (double)y/(2*sampdens)+.5));
336 <        if (x >= hl)                    /* right region */
336 >        }
337 >        if (x >= hl) {                  /* right region */
338 >                if (x >= hl+sampdens)
339 >                        return(-1);
340                  return(viewray(org, vd, &rightview,
341                                  (double)(x-hl)/(2*sampdens)+.5,
342                                  (double)y/(2*sampdens)+.5));
343 +        }
344                                          /* central region */
345          if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0)
346                  return(-1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines