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.11 by greg, Thu Mar 21 17:11:46 1991 UTC vs.
Revision 1.16 by greg, Wed Apr 10 15:59:07 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 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 276 | Line 286 | cleanup()                              /* close files, wait for children */
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  
# Line 283 | Line 296 | compdir(vd, x, y)                      /* compute direction for x,y */
296   FVECT   vd;
297   int     x, y;
298   {
299 +        static int      cury = 10000;
300 +        static double   err, cmpval;
301 +        long    t;
302          FVECT   org;                    /* dummy variable */
303  
304          if (x <= -hlim)                 /* left region */
305                  return(viewray(org, vd, &leftview,
306 <                                (x+hlim)/(2.*sampdens)+.5,
307 <                                y/(2.*sampdens)+.5));
306 >                                (double)(x+hlim)/(2*sampdens)+.5,
307 >                                (double)y/(2*sampdens)+.5));
308          if (x >= hlim)                  /* right region */
309                  return(viewray(org, vd, &rightview,
310 <                                (x-hlim)/(2.*sampdens)+.5,
311 <                                y/(2.*sampdens)+.5));
312 <                                                /* central region */
313 <        if (viewray(org, vd, &ourview, .5, y/(2.*sampdens)+.5) < 0)
310 >                                (double)(x-hlim)/(2*sampdens)+.5,
311 >                                (double)y/(2*sampdens)+.5));
312 >                                        /* central region */
313 >                                /* avoid over-counting of poles */
314 >        if (cury != y) {
315 >                err = 0.0;
316 >                cmpval = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize));
317 >                cury = y;
318 >        }
319 >        err += cmpval;
320 >        if (err <= 0.5)
321                  return(-1);
322 +        err -= 1.0;
323 +        if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0)
324 +                return(-1);
325          spinvector(vd, vd, ourview.vup, h_theta(x));
326          return(0);
327   }
# Line 328 | Line 354 | printillum()                   /* print out indirect illuminances */
354  
355          printf("BEGIN indirect illuminance\n");
356          for (i = 0; i < nglardirs; i++)
357 <                printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
358 <                                PI * indirect[i].sum / indirect[i].n);
357 >                if (indirect[i].n > FTINY)
358 >                        printf("\t%.0f\t%f\n", (180.0/PI)*indirect[i].theta,
359 >                                        PI * indirect[i].sum / indirect[i].n);
360          printf("END indirect illuminance\n");
361   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines