12 |
|
|
13 |
|
#include "glare.h" |
14 |
|
|
15 |
– |
#include "random.h" |
16 |
– |
|
15 |
|
#define FEQ(a,b) ((a)-(b)<=FTINY&&(a)-(b)<=FTINY) |
16 |
|
#define VEQ(v1,v2) (FEQ((v1)[0],(v2)[0])&&FEQ((v1)[1],(v2)[1]) \ |
17 |
|
&&FEQ((v1)[2],(v2)[2])) |
48 |
|
int argc; |
49 |
|
char *argv[]; |
50 |
|
{ |
51 |
+ |
int combine = 1; |
52 |
|
int gotview = 0; |
53 |
|
int rval, i; |
54 |
|
char *err; |
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]; |
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); |
191 |
|
fputs(VIEWSTR, stdout); |
192 |
|
fprintview(&ourview, stdout); |
193 |
< |
printf("\n\n"); |
193 |
> |
printf("\n"); |
194 |
> |
fputformat("ASCII", stdout); |
195 |
> |
printf("\n"); |
196 |
|
printsources(); /* print glare sources */ |
197 |
|
printillum(); /* print illuminances */ |
198 |
|
exit(0); |
283 |
|
cleanup() /* close files, wait for children */ |
284 |
|
{ |
285 |
|
if (verbose) |
286 |
< |
fprintf(stderr, "%s: cleaning up...\n", progname); |
286 |
> |
fprintf(stderr, "%s: cleaning up... \n", progname); |
287 |
|
if (picture != NULL) |
288 |
|
close_pict(); |
289 |
|
if (octree != NULL) |
294 |
|
} |
295 |
|
|
296 |
|
|
297 |
< |
compdir(vd, x, y) /* compute direction for x,y */ |
297 |
> |
compdir(vd, x, y, se) /* compute direction for x,y */ |
298 |
|
FVECT vd; |
299 |
|
int x, y; |
300 |
+ |
SPANERR *se; |
301 |
|
{ |
295 |
– |
long t; |
302 |
|
FVECT org; /* dummy variable */ |
303 |
|
|
304 |
|
if (x <= -hlim) /* left region */ |
310 |
|
(double)(x-hlim)/(2*sampdens)+.5, |
311 |
|
(double)y/(2*sampdens)+.5)); |
312 |
|
/* central region */ |
313 |
< |
/* avoid over-counting of poles */ |
314 |
< |
t = random() % vsize; |
315 |
< |
if (t*t >= (long)vsize*vsize - (long)y*y) |
316 |
< |
return(-1); |
313 |
> |
if (se != NULL) { /* avoid over-counting of poles */ |
314 |
> |
se->err += se->prob; |
315 |
> |
if (se->err <= 0.5) |
316 |
> |
return(-1); |
317 |
> |
se->err -= 1.0; |
318 |
> |
} |
319 |
|
if (viewray(org, vd, &ourview, .5, (double)y/(2*sampdens)+.5) < 0) |
320 |
|
return(-1); |
321 |
|
spinvector(vd, vd, ourview.vup, h_theta(x)); |
322 |
|
return(0); |
323 |
+ |
} |
324 |
+ |
|
325 |
+ |
|
326 |
+ |
setspanerr(se, y) /* initialize span error at y */ |
327 |
+ |
register SPANERR *se; |
328 |
+ |
int y; |
329 |
+ |
{ |
330 |
+ |
se->err = 0.0; |
331 |
+ |
se->prob = sqrt(1.0 - (double)((long)y*y)/((long)vsize*vsize)); |
332 |
|
} |
333 |
|
|
334 |
|
|