27 |
|
#define wscan(y) (ourweigh+(y)*hresolu) |
28 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
29 |
|
#define averaging (ourweigh != NULL) |
30 |
+ |
#define usematrix (hasmatrix & !averaging) |
31 |
+ |
#define zisnorm (!usematrix | ourview.type != VT_PER) |
32 |
|
|
33 |
|
#define MAXWT 1000. /* maximum pixel weight (averaging) */ |
34 |
|
|
69 |
|
COLR backcolr = BLKCOLR; /* background color */ |
70 |
|
COLOR backcolor = BLKCOLOR; /* background color (float) */ |
71 |
|
double backz = 0.0; /* background z value */ |
72 |
< |
int normdist = 1; /* normalized distance? */ |
72 |
> |
int normdist = 1; /* i/o normalized distance? */ |
73 |
|
double ourexp = -1; /* original picture exposure */ |
74 |
|
int expadj = 0; /* exposure adjustment (f-stops) */ |
75 |
|
double rexpadj = 1; /* real exposure adjustment */ |
586 |
|
|
587 |
|
if (pos[2] <= 0) /* empty pixel */ |
588 |
|
return(0); |
589 |
< |
if (!averaging && hasmatrix) { |
589 |
> |
if (usematrix) { |
590 |
|
pos[0] += theirview.hoff - .5; |
591 |
|
pos[1] += theirview.voff - .5; |
592 |
|
if (theirview.type == VT_PER) { |
608 |
|
} else { |
609 |
|
if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY) |
610 |
|
return(0); |
611 |
< |
if (!normdist && theirview.type == VT_PER) /* adjust */ |
611 |
> |
if (!normdist & theirview.type == VT_PER) /* adjust */ |
612 |
|
pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
613 |
|
+ pos[1]*pos[1]*theirview.vn2); |
614 |
|
pt[0] += tdir[0]*pos[2]; |
841 |
|
clipaft() /* perform aft clipping as indicated */ |
842 |
|
{ |
843 |
|
register int x, y; |
844 |
+ |
int adjtest = ourview.type == VT_PER & zisnorm; |
845 |
|
double tstdist; |
846 |
|
double yzn2, vx; |
847 |
|
|
849 |
|
return; |
850 |
|
tstdist = ourview.vaft - ourview.vfore; |
851 |
|
for (y = 0; y < vresolu; y++) { |
852 |
< |
if (ourview.type == VT_PER) { /* adjust distance */ |
852 |
> |
if (adjtest) { /* adjust test */ |
853 |
|
yzn2 = (y+.5)/vresolu + ourview.voff - .5; |
854 |
|
yzn2 = 1. + yzn2*yzn2*ourview.vn2; |
855 |
|
tstdist = (ourview.vaft - ourview.vfore)*sqrt(yzn2); |
856 |
|
} |
857 |
|
for (x = 0; x < hresolu; x++) |
858 |
|
if (zscan(y)[x] > tstdist) { |
859 |
< |
if (ourview.type == VT_PER) { |
859 |
> |
if (adjtest) { |
860 |
|
vx = (x+.5)/hresolu + ourview.hoff - .5; |
861 |
|
if (zscan(y)[x] <= (ourview.vaft - |
862 |
|
ourview.vfore) * |
897 |
|
} |
898 |
|
|
899 |
|
|
900 |
< |
writedistance(fname) /* write out z file */ |
900 |
> |
writedistance(fname) /* write out z file (alters buffer) */ |
901 |
|
char *fname; |
902 |
|
{ |
903 |
< |
int donorm = normdist && ourview.type == VT_PER && |
904 |
< |
!averaging && hasmatrix; |
903 |
> |
int donorm = normdist & !zisnorm ? 1 : |
904 |
> |
ourview.type == VT_PER & !normdist & zisnorm ? -1 : 0; |
905 |
|
int fd; |
906 |
|
int y; |
904 |
– |
float *zout; |
907 |
|
|
908 |
|
if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) |
909 |
|
syserror(fname); |
908 |
– |
if (donorm |
909 |
– |
&& (zout = (float *)malloc(hresolu*sizeof(float))) == NULL) |
910 |
– |
syserror(progname); |
910 |
|
for (y = vresolu-1; y >= 0; y--) { |
911 |
|
if (donorm) { |
912 |
< |
double vx, yzn2; |
912 |
> |
double vx, yzn2, d; |
913 |
|
register int x; |
914 |
|
yzn2 = (y+.5)/vresolu + ourview.voff - .5; |
915 |
|
yzn2 = 1. + yzn2*yzn2*ourview.vn2; |
916 |
|
for (x = 0; x < hresolu; x++) { |
917 |
|
vx = (x+.5)/hresolu + ourview.hoff - .5; |
918 |
< |
zout[x] = zscan(y)[x] |
919 |
< |
* sqrt(vx*vx*ourview.hn2 + yzn2); |
918 |
> |
d = sqrt(vx*vx*ourview.hn2 + yzn2); |
919 |
> |
if (donorm > 0) |
920 |
> |
zscan(y)[x] *= d; |
921 |
> |
else |
922 |
> |
zscan(y)[x] /= d; |
923 |
|
} |
924 |
< |
} else |
925 |
< |
zout = zscan(y); |
924 |
< |
if (write(fd, (char *)zout, hresolu*sizeof(float)) |
924 |
> |
} |
925 |
> |
if (write(fd, (char *)zscan(y), hresolu*sizeof(float)) |
926 |
|
< hresolu*sizeof(float)) |
927 |
|
syserror(fname); |
928 |
|
} |
928 |
– |
if (donorm) |
929 |
– |
free((char *)zout); |
929 |
|
close(fd); |
930 |
|
} |
931 |
|
|
1010 |
|
float fbuf[6*(PACKSIZ+1)]; |
1011 |
|
register float *fbp; |
1012 |
|
register int i; |
1013 |
+ |
double vx, vy; |
1014 |
|
|
1015 |
|
if (queuesiz == 0) |
1016 |
|
return; |
1045 |
|
} else |
1046 |
|
setcolr(pscan(queue[i][1])[queue[i][0]], |
1047 |
|
fbp[0], fbp[1], fbp[2]); |
1048 |
< |
zscan(queue[i][1])[queue[i][0]] = fbp[3]; |
1048 |
> |
if (zisnorm) |
1049 |
> |
zscan(queue[i][1])[queue[i][0]] = fbp[3]; |
1050 |
> |
else { |
1051 |
> |
vx = (queue[i][0]+.5)/hresolu + ourview.hoff - .5; |
1052 |
> |
vy = (queue[i][1]+.5)/vresolu + ourview.voff - .5; |
1053 |
> |
zscan(queue[i][1])[queue[i][0]] = fbp[3] / sqrt(1. + |
1054 |
> |
vx*vx*ourview.hn2 + vy*vy*ourview.vn2); |
1055 |
> |
} |
1056 |
|
fbp += 4; |
1057 |
|
} |
1058 |
|
queuesiz = 0; |