28 |
|
#define averaging (ourweigh != NULL) |
29 |
|
#define blurring (ourbpict != NULL) |
30 |
|
#define usematrix (hasmatrix & !averaging) |
31 |
< |
#define zisnorm ((!usematrix) | (ourview.type != VT_PER)) |
31 |
> |
#define zisnorm (!usematrix | (ourview.type != VT_PER)) |
32 |
|
|
33 |
|
#define MAXWT 1000. /* maximum pixel weight (averaging) */ |
34 |
|
|
64 |
|
VIEW avgview; /* average view for -B option */ |
65 |
|
int nvavg; /* number of views averaged */ |
66 |
|
|
67 |
– |
char *progname; |
68 |
– |
|
67 |
|
int fillo = F_FORE|F_BACK; /* selected fill options */ |
68 |
|
int fillsamp = 0; /* sample separation (0 == inf) */ |
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; /* i/o normalized distance? */ |
73 |
< |
char ourfmt[LPICFMT+1] = PICFMT; /* original picture format */ |
73 |
> |
char ourfmt[MAXFMTLEN] = PICFMT; /* original picture format */ |
74 |
|
double ourexp = -1; /* original picture exposure */ |
75 |
|
int expadj = 0; /* exposure adjustment (f-stops) */ |
76 |
|
double rexpadj = 1; /* real exposure adjustment */ |
132 |
|
char *expcomp = NULL; |
133 |
|
int i, an, rval; |
134 |
|
|
135 |
< |
progname = argv[0]; |
135 |
> |
SET_DEFAULT_BINARY(); |
136 |
> |
SET_FILE_BINARY(stdout); |
137 |
|
|
138 |
+ |
fixargv0(argv[0]); /* sets global progname */ |
139 |
+ |
|
140 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) { |
141 |
|
rval = getviewopt(&ourview, argc-an, argv+an); |
142 |
|
if (rval >= 0) { |
359 |
|
void *p |
360 |
|
) |
361 |
|
{ |
362 |
< |
char fmt[32]; |
362 |
> |
char fmt[MAXFMTLEN]; |
363 |
|
|
364 |
|
if (isheadid(s)) |
365 |
|
return(0); |
392 |
|
{ |
393 |
|
char linebuf[256]; |
394 |
|
char *err; |
395 |
< |
register int i; |
395 |
> |
int i; |
396 |
|
|
397 |
|
if (fp != NULL) { |
398 |
|
do /* get new view */ |
429 |
|
static void |
430 |
|
compavgview(void) /* compute average view */ |
431 |
|
{ |
432 |
< |
register int i; |
432 |
> |
int i; |
433 |
|
double f; |
434 |
|
|
435 |
|
if (nvavg < 2) |
495 |
|
zin = (float *)malloc(scanlen(&tresolu)*sizeof(float)); |
496 |
|
if (zin == NULL) |
497 |
|
syserror(progname); |
498 |
< |
if ((zfd = open(zspec, O_RDONLY)) == -1) { |
499 |
< |
double zvalue; |
500 |
< |
register int x; |
501 |
< |
if (!isflt(zspec) || (zvalue = atof(zspec)) <= 0.0) |
502 |
< |
syserror(zspec); |
498 |
> |
if (isflt(zspec)) { /* depth is a constant? */ |
499 |
> |
double zvalue = atof(zspec); |
500 |
> |
int x; |
501 |
> |
if (zvalue <= 0.0) { |
502 |
> |
fprintf(stderr, "%s: illegal Z-value %s\n", |
503 |
> |
progname, zspec); |
504 |
> |
exit(1); |
505 |
> |
} |
506 |
|
for (x = scanlen(&tresolu); x-- > 0; ) |
507 |
|
zin[x] = zvalue; |
508 |
< |
} |
508 |
> |
zfd = -1; |
509 |
> |
} else if ((zfd = open_float_depth(zspec, (long)tresolu.xr*tresolu.yr)) < 0) |
510 |
> |
exit(1); |
511 |
|
/* compute transferrable perimeter */ |
512 |
|
xlim = (struct bound *)malloc(numscans(&tresolu)*sizeof(struct bound)); |
513 |
|
if (xlim == NULL) |
561 |
|
|
562 |
|
static int |
563 |
|
pixform( /* compute view1 to view2 matrix */ |
564 |
< |
register MAT4 xfmat, |
565 |
< |
register VIEW *vw1, |
566 |
< |
register VIEW *vw2 |
564 |
> |
MAT4 xfmat, |
565 |
> |
VIEW *vw1, |
566 |
> |
VIEW *vw2 |
567 |
|
) |
568 |
|
{ |
569 |
< |
double m4t[4][4]; |
569 |
> |
MAT4 m4t; |
570 |
|
|
571 |
|
if ((vw1->type != VT_PER) & (vw1->type != VT_PAR)) |
572 |
|
return(0); |
615 |
|
FVECT pos; |
616 |
|
struct position lastx, newpos; |
617 |
|
double wt; |
618 |
< |
register int x; |
618 |
> |
int x; |
619 |
|
|
620 |
|
lastx.z = 0; |
621 |
|
for (x = xl->max; x >= xl->min; x--) { |
653 |
|
int l1, l2, c1, c2; /* side lengths and counters */ |
654 |
|
int p1isy; /* p0p1 along y? */ |
655 |
|
int x1, y1; /* p1 position */ |
656 |
< |
register int x, y; /* final position */ |
656 |
> |
int x, y; /* final position */ |
657 |
|
|
658 |
|
/* compute vector p0p1 */ |
659 |
|
if (fillo&F_FORE && ABS(p1->z-p0->z) <= zt) { |
720 |
|
|
721 |
|
static double |
722 |
|
movepixel( /* reposition image point */ |
723 |
< |
register FVECT pos |
723 |
> |
FVECT pos |
724 |
|
) |
725 |
|
{ |
726 |
|
FVECT pt, tdir, odir; |
751 |
|
} |
752 |
|
pos[0] += .5 - ourview.hoff; |
753 |
|
pos[1] += .5 - ourview.voff; |
754 |
+ |
if ((pos[0] < 0) | (pos[0] >= 1-FTINY) | |
755 |
+ |
(pos[1] < 0) | (pos[1] >= 1-FTINY)) |
756 |
+ |
return(0); |
757 |
|
pos[2] -= ourview.vfore; |
758 |
|
} else { |
759 |
|
if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY) |
760 |
|
return(0); |
761 |
< |
if ((!normdist) & (theirview.type == VT_PER)) /* adjust */ |
762 |
< |
pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
754 |
< |
+ pos[1]*pos[1]*theirview.vn2); |
761 |
> |
if (!normdist & (theirview.type == VT_PER)) /* adjust */ |
762 |
> |
pos[2] /= DOT(theirview.vdir, tdir); |
763 |
|
pt[0] += tdir[0]*pos[2]; |
764 |
|
pt[1] += tdir[1]*pos[2]; |
765 |
|
pt[2] += tdir[2]*pos[2]; |
766 |
< |
viewloc(pos, &ourview, pt); |
759 |
< |
if (pos[2] <= 0) |
766 |
> |
if (viewloc(pos, &ourview, pt) != VL_GOOD) |
767 |
|
return(0); |
768 |
|
} |
762 |
– |
if ((pos[0] < 0) | (pos[0] >= 1-FTINY) | (pos[1] < 0) | (pos[1] >= 1-FTINY)) |
763 |
– |
return(0); |
769 |
|
if (!averaging) |
770 |
|
return(1); |
771 |
|
/* compute pixel weight */ |
785 |
|
|
786 |
|
static int |
787 |
|
getperim( /* compute overlapping image area */ |
788 |
< |
register struct bound *xl, |
788 |
> |
struct bound *xl, |
789 |
|
struct bound *yl, |
790 |
|
float *zline, |
791 |
|
int zfd |
793 |
|
{ |
794 |
|
int step; |
795 |
|
FVECT pos; |
796 |
< |
register int x, y; |
796 |
> |
int x, y; |
797 |
|
/* set up step size */ |
798 |
|
if (scanlen(&tresolu) < numscans(&tresolu)) |
799 |
|
step = scanlen(&tresolu)/NSTEPS; |
877 |
|
{ |
878 |
|
int *yback, xback; |
879 |
|
int y; |
880 |
< |
register int x, i; |
880 |
> |
int x, i; |
881 |
|
/* get back buffer */ |
882 |
|
yback = (int *)malloc(hresolu*sizeof(int)); |
883 |
|
if (yback == NULL) |
984 |
|
fillfunc_t *fill |
985 |
|
) |
986 |
|
{ |
987 |
< |
register int x, y; |
987 |
> |
int x, y; |
988 |
|
|
989 |
|
for (y = 0; y < vresolu; y++) |
990 |
|
for (x = 0; x < hresolu; x++) |
998 |
|
static int |
999 |
|
clipaft(void) /* perform aft clipping as indicated */ |
1000 |
|
{ |
1001 |
< |
register int x, y; |
1001 |
> |
int x, y; |
1002 |
|
int adjtest = (ourview.type == VT_PER) & zisnorm; |
1003 |
|
double tstdist; |
1004 |
|
double yzn2, vx; |
1037 |
|
{ |
1038 |
|
COLOR cval; |
1039 |
|
double d; |
1040 |
< |
register int i; |
1040 |
> |
int i; |
1041 |
|
|
1042 |
|
if (!blurring) |
1043 |
|
return(0); |
1077 |
|
writepicture(void) /* write out picture (alters buffer) */ |
1078 |
|
{ |
1079 |
|
int y; |
1080 |
< |
register int x; |
1080 |
> |
int x; |
1081 |
|
double d; |
1082 |
|
|
1083 |
|
fprtresolu(hresolu, vresolu, stdout); |
1120 |
|
for (y = vresolu-1; y >= 0; y--) { |
1121 |
|
if (donorm) { |
1122 |
|
double vx, yzn2, d; |
1123 |
< |
register int x; |
1123 |
> |
int x; |
1124 |
|
yzn2 = (y+.5)/vresolu + ourview.voff - .5; |
1125 |
|
yzn2 = 1. + yzn2*yzn2*ourview.vn2; |
1126 |
|
for (x = 0; x < hresolu; x++) { |
1164 |
|
char combuf[512]; |
1165 |
|
char *argv[64]; |
1166 |
|
int rval; |
1167 |
< |
register char **wp, *cp; |
1167 |
> |
char **wp, *cp; |
1168 |
|
|
1169 |
< |
if (PDesc.running) { |
1169 |
> |
if (PDesc.flags & PF_RUNNING) { |
1170 |
|
fprintf(stderr, "%s: too many calculations\n", progname); |
1171 |
|
exit(1); |
1172 |
|
} |
1201 |
|
static void |
1202 |
|
caldone(void) /* done with calculation */ |
1203 |
|
{ |
1204 |
< |
if (!PDesc.running) |
1204 |
> |
if (!(PDesc.flags & PF_RUNNING)) |
1205 |
|
return; |
1206 |
|
clearqueue(); |
1207 |
|
close_process(&PDesc); |
1228 |
|
{ |
1229 |
|
FVECT orig, dir; |
1230 |
|
float fbuf[6*(PACKSIZ+1)]; |
1231 |
< |
register float *fbp; |
1232 |
< |
register int i; |
1231 |
> |
float *fbp; |
1232 |
> |
int i; |
1233 |
|
double vx, vy; |
1234 |
|
|
1235 |
|
if (queuesiz == 0) |
1244 |
|
} |
1245 |
|
/* mark end and get results */ |
1246 |
|
memset((char *)fbp, '\0', 6*sizeof(float)); |
1247 |
< |
if (process(&PDesc, (char *)fbuf, (char *)fbuf, |
1247 |
> |
if (process(&PDesc, fbuf, fbuf, |
1248 |
|
4*sizeof(float)*(queuesiz+1), |
1249 |
|
6*sizeof(float)*(queuesiz+1)) != |
1250 |
|
4*sizeof(float)*(queuesiz+1)) { |