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.8 by greg, Tue Mar 19 17:21:34 1991 UTC vs.
Revision 1.17 by greg, Fri Apr 12 10:28:40 1991 UTC

# Line 40 | Line 40 | int    hlim;                           /* central limit of horizontal */
40  
41   struct illum    *indirect;              /* array of indirect illuminances */
42  
43 + long    npixinvw;                       /* number of pixels in view */
44 + long    npixmiss;                       /* number of pixels missed */
45  
46 +
47   main(argc, argv)
48   int     argc;
49   char    *argv[];
50   {
51 +        int     combine = 1;
52          int     gotview = 0;
53          int     rval, i;
54          char    *err;
# Line 98 | Line 102 | char   *argv[];
102                  case 'p':
103                          picture = argv[++i];
104                          break;
105 +                case 'c':
106 +                        combine = !combine;
107 +                        break;
108                  case 'd':
109                  case 'l':
110                          rtargv[rtargc++] = argv[i];
# Line 176 | Line 183 | char   *argv[];
183          if (threshold <= FTINY)
184                  comp_thresh();                  /* compute glare threshold */
185          analyze();                              /* analyze view */
186 +        if (combine)
187 +                absorb_specks();                /* eliminate tiny sources */
188          cleanup();                              /* tidy up */
189                                                  /* print header */
190          printargs(argc, argv, stdout);
# Line 204 | Line 213 | init()                         /* initialize global variables */
213                                                  /* set direction vectors */
214          for (i = 0; glarang[i] != AEND; i++)
215                  ;
216 <        if (i > 0 && glarang[0] <= 0 || glarang[i-1] >= 180) {
216 >        if (i > 0 && (glarang[0] <= 0 || glarang[i-1] >= 180)) {
217                  fprintf(stderr, "%s: glare angles must be between 1 and 179\n",
218                                  progname);
219                  exit(1);
# Line 223 | Line 232 | init()                         /* initialize global variables */
232          indirect = (struct illum *)calloc(nglardirs, sizeof(struct illum));
233          if (indirect == NULL)
234                  memerr("indirect illuminances");
235 +        npixinvw = npixmiss = 0L;
236          copystruct(&leftview, &ourview);
237          copystruct(&rightview, &ourview);
238          spinvector(leftview.vdir, ourview.vdir, ourview.vup, maxtheta);
# Line 231 | Line 241 | init()                         /* initialize global variables */
241          setview(&rightview);
242          indirect[nglarangs].lcos =
243          indirect[nglarangs].rcos = cos(maxtheta);
244 <        indirect[nglarangs].lsin =
245 <        -(indirect[nglarangs].rsin = sin(maxtheta));
244 >        indirect[nglarangs].rsin =
245 >        -(indirect[nglarangs].lsin = sin(maxtheta));
246          indirect[nglarangs].theta = 0.0;
247          for (i = 0; i < nglarangs; i++) {
248                  d = (glarang[nglarangs-1] - glarang[i])*(PI/180.);
249                  indirect[nglarangs-i-1].lcos =
250                  indirect[nglarangs+i+1].rcos = cos(d);
251 <                indirect[nglarangs-i-1].lsin =
252 <                -(indirect[nglarangs+i+1].rsin = sin(d));
251 >                indirect[nglarangs+i+1].rsin =
252 >                -(indirect[nglarangs-i-1].lsin = sin(d));
253                  d = (glarang[nglarangs-1] + glarang[i])*(PI/180.);
254                  indirect[nglarangs-i-1].rcos =
255                  indirect[nglarangs+i+1].lcos = cos(d);
256 <                indirect[nglarangs+i+1].lsin =
257 <                -(indirect[nglarangs-i-1].rsin = sin(d));
258 <                indirect[nglarangs-i-1].theta = -(PI/180.)*glarang[i];
259 <                indirect[nglarangs+i+1].theta = (PI/180.)*glarang[i];
256 >                indirect[nglarangs-i-1].rsin =
257 >                -(indirect[nglarangs+i+1].lsin = sin(d));
258 >                indirect[nglarangs-i-1].theta = (PI/180.)*glarang[i];
259 >                indirect[nglarangs+i+1].theta = -(PI/180.)*glarang[i];
260          }
261                                                  /* open picture */
262          if (picture != NULL) {
# Line 271 | Line 281 | init()                         /* initialize global variables */
281   cleanup()                               /* close files, wait for children */
282   {
283          if (verbose)
284 <                fprintf(stderr, "%s: cleaning up...\n", progname);
284 >                fprintf(stderr, "%s: cleaning up...        \n", progname);
285          if (picture != NULL)
286                  close_pict();
287          if (octree != NULL)
288                  done_rtrace();
289 +        if (npixinvw < 100*npixmiss)
290 +                fprintf(stderr, "%s: warning -- missing %ld%% of samples\n",
291 +                                progname, 100L*npixmiss/npixinvw);
292   }
293  
294  
295 < compdir(vd, x, y)                       /* compute direction for x,y */
295 > compdir(vd, x, y, se)                   /* compute direction for x,y */
296   FVECT   vd;
297   int     x, y;
298 + SPANERR *se;
299   {
300          FVECT   org;                    /* dummy variable */
301  
302          if (x <= -hlim)                 /* left region */
303                  return(viewray(org, vd, &leftview,
304 <                                (x+hlim)/(2.*sampdens)+.5,
305 <                                y/(2.*sampdens)+.5));
304 >                                (double)(x+hlim)/(2*sampdens)+.5,
305 >                                (double)y/(2*sampdens)+.5));
306          if (x >= hlim)                  /* right region */
307                  return(viewray(org, vd, &rightview,
308 <                                (x-hlim)/(2.*sampdens)+.5,
309 <                                y/(2.*sampdens)+.5));
310 <                                                /* central region */
311 <        if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0)
308 >                                (double)(x-hlim)/(2*sampdens)+.5,
309 >                                (double)y/(2*sampdens)+.5));
310 >                                        /* central region */
311 >        if (se != NULL) {       /* avoid over-counting of poles */
312 >                se->err += se->prob;
313 >                if (se->err <= 0.5)
314 >                        return(-1);
315 >                se->err -= 1.0;
316 >        }
317 >        if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0)
318                  return(-1);
319          spinvector(vd, vd, ourview.vup, h_theta(x));
320          return(0);
321   }
322  
323  
324 + setspanerr(se, y)               /* initialize span error at y */
325 + register SPANERR        *se;
326 + int     y;
327 + {
328 +        se->err = 0.0;
329 +        se->prob = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize));
330 + }
331 +
332 +
333   memerr(s)                       /* malloc failure */
334   char    *s;
335   {
# Line 328 | Line 357 | printillum()                   /* print out indirect illuminances */
357  
358          printf("BEGIN indirect illuminance\n");
359          for (i = 0; i < nglardirs; i++)
360 <                printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
361 <                                PI * indirect[i].sum / (double)indirect[i].n);
360 >                if (indirect[i].n > FTINY)
361 >                        printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
362 >                                        PI * indirect[i].sum / indirect[i].n);
363          printf("END indirect illuminance\n");
364   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines