12 |
|
#include <ctype.h> |
13 |
|
#include <string.h> |
14 |
|
|
15 |
– |
#include "standard.h" |
15 |
|
#include "platform.h" |
16 |
+ |
#include "standard.h" |
17 |
|
#include "rtprocess.h" /* Windows: must come before color.h */ |
18 |
|
#include "view.h" |
19 |
|
#include "color.h" |
68 |
|
|
69 |
|
int fillo = F_FORE|F_BACK; /* selected fill options */ |
70 |
|
int fillsamp = 0; /* sample separation (0 == inf) */ |
71 |
– |
extern int backfill(), rcalfill(); /* fill functions */ |
72 |
– |
int (*fillfunc)() = backfill; /* selected fill function */ |
71 |
|
COLR backcolr = BLKCOLR; /* background color */ |
72 |
|
COLOR backcolor = BLKCOLOR; /* background color (float) */ |
73 |
|
double backz = 0.0; /* background z value */ |
90 |
|
int packsiz; /* actual packet size */ |
91 |
|
int queuesiz = 0; /* number of pixels pending */ |
92 |
|
|
93 |
< |
extern double movepixel(); |
93 |
> |
typedef void fillfunc_t(int x, int y); |
94 |
|
|
95 |
+ |
static gethfunc headline; |
96 |
+ |
static int nextview(FILE *fp); |
97 |
+ |
static void compavgview(void); |
98 |
+ |
static void addpicture(char *pfile, char *zspec); |
99 |
+ |
static int pixform(MAT4 xfmat, VIEW *vw1, VIEW *vw2); |
100 |
+ |
static void addscanline(struct bound *xl, int y, |
101 |
+ |
COLR *pline, float *zline, struct position *lasty); |
102 |
+ |
static void addpixel(struct position *p0, struct position *p1, |
103 |
+ |
struct position *p2, COLR pix, double w, double z); |
104 |
+ |
static double movepixel(FVECT pos); |
105 |
+ |
static int getperim(struct bound *xl, struct bound *yl, float *zline, int zfd); |
106 |
+ |
static void backpicture(fillfunc_t *fill, int samp); |
107 |
+ |
static void fillpicture(fillfunc_t *fill); |
108 |
+ |
static int clipaft(void); |
109 |
+ |
static int addblur(void); |
110 |
+ |
static void writepicture(void); |
111 |
+ |
static void writedistance(char *fname); |
112 |
+ |
static fillfunc_t backfill; |
113 |
+ |
static fillfunc_t rcalfill; |
114 |
+ |
static void calstart(char *prog, char *args); |
115 |
+ |
static void caldone(void); |
116 |
+ |
static void clearqueue(void); |
117 |
+ |
static void syserror(char *s); |
118 |
|
|
119 |
< |
main(argc, argv) /* interpolate pictures */ |
120 |
< |
int argc; |
121 |
< |
char *argv[]; |
119 |
> |
fillfunc_t *fillfunc = backfill; /* selected fill function */ |
120 |
> |
|
121 |
> |
int |
122 |
> |
main( /* interpolate pictures */ |
123 |
> |
int argc, |
124 |
> |
char *argv[] |
125 |
> |
) |
126 |
|
{ |
127 |
|
#define check(ol,al) if (argv[an][ol] || \ |
128 |
|
badarg(argc-an-1,argv+an+1,al)) \ |
352 |
|
} |
353 |
|
|
354 |
|
|
355 |
< |
int |
356 |
< |
headline(s) /* process header string */ |
357 |
< |
char *s; |
355 |
> |
static int |
356 |
> |
headline( /* process header string */ |
357 |
> |
char *s, |
358 |
> |
void *p |
359 |
> |
) |
360 |
|
{ |
361 |
|
char fmt[32]; |
362 |
|
|
384 |
|
} |
385 |
|
|
386 |
|
|
387 |
< |
nextview(fp) /* get and set next view */ |
388 |
< |
FILE *fp; |
387 |
> |
static int |
388 |
> |
nextview( /* get and set next view */ |
389 |
> |
FILE *fp |
390 |
> |
) |
391 |
|
{ |
392 |
|
char linebuf[256]; |
393 |
|
char *err; |
424 |
|
} |
425 |
|
|
426 |
|
|
427 |
< |
compavgview() /* compute average view */ |
427 |
> |
static void |
428 |
> |
compavgview(void) /* compute average view */ |
429 |
|
{ |
430 |
|
register int i; |
431 |
|
double f; |
450 |
|
} |
451 |
|
|
452 |
|
|
453 |
< |
addpicture(pfile, zspec) /* add picture to output */ |
454 |
< |
char *pfile, *zspec; |
453 |
> |
static void |
454 |
> |
addpicture( /* add picture to output */ |
455 |
> |
char *pfile, |
456 |
> |
char *zspec |
457 |
> |
) |
458 |
|
{ |
459 |
|
FILE *pfp; |
460 |
|
int zfd; |
551 |
|
} |
552 |
|
|
553 |
|
|
554 |
< |
pixform(xfmat, vw1, vw2) /* compute view1 to view2 matrix */ |
555 |
< |
register MAT4 xfmat; |
556 |
< |
register VIEW *vw1, *vw2; |
554 |
> |
static int |
555 |
> |
pixform( /* compute view1 to view2 matrix */ |
556 |
> |
register MAT4 xfmat, |
557 |
> |
register VIEW *vw1, |
558 |
> |
register VIEW *vw2 |
559 |
> |
) |
560 |
|
{ |
561 |
|
double m4t[4][4]; |
562 |
|
|
595 |
|
} |
596 |
|
|
597 |
|
|
598 |
< |
addscanline(xl, y, pline, zline, lasty) /* add scanline to output */ |
599 |
< |
struct bound *xl; |
600 |
< |
int y; |
601 |
< |
COLR *pline; |
602 |
< |
float *zline; |
603 |
< |
struct position *lasty; /* input/output */ |
598 |
> |
static void |
599 |
> |
addscanline( /* add scanline to output */ |
600 |
> |
struct bound *xl, |
601 |
> |
int y, |
602 |
> |
COLR *pline, |
603 |
> |
float *zline, |
604 |
> |
struct position *lasty /* input/output */ |
605 |
> |
) |
606 |
|
{ |
607 |
|
FVECT pos; |
608 |
|
struct position lastx, newpos; |
629 |
|
} |
630 |
|
|
631 |
|
|
632 |
< |
addpixel(p0, p1, p2, pix, w, z) /* fill in pixel parallelogram */ |
633 |
< |
struct position *p0, *p1, *p2; |
634 |
< |
COLR pix; |
635 |
< |
double w; |
636 |
< |
double z; |
632 |
> |
static void |
633 |
> |
addpixel( /* fill in pixel parallelogram */ |
634 |
> |
struct position *p0, |
635 |
> |
struct position *p1, |
636 |
> |
struct position *p2, |
637 |
> |
COLR pix, |
638 |
> |
double w, |
639 |
> |
double z |
640 |
> |
) |
641 |
|
{ |
642 |
|
double zt = 2.*zeps*p0->z; /* threshold */ |
643 |
|
COLOR pval; /* converted+weighted pixel */ |
710 |
|
} |
711 |
|
|
712 |
|
|
713 |
< |
double |
714 |
< |
movepixel(pos) /* reposition image point */ |
715 |
< |
register FVECT pos; |
713 |
> |
static double |
714 |
> |
movepixel( /* reposition image point */ |
715 |
> |
register FVECT pos |
716 |
> |
) |
717 |
|
{ |
718 |
|
FVECT pt, tdir, odir; |
719 |
|
double d; |
776 |
|
} |
777 |
|
|
778 |
|
|
779 |
< |
getperim(xl, yl, zline, zfd) /* compute overlapping image area */ |
780 |
< |
register struct bound *xl; |
781 |
< |
struct bound *yl; |
782 |
< |
float *zline; |
783 |
< |
int zfd; |
779 |
> |
static int |
780 |
> |
getperim( /* compute overlapping image area */ |
781 |
> |
register struct bound *xl, |
782 |
> |
struct bound *yl, |
783 |
> |
float *zline, |
784 |
> |
int zfd |
785 |
> |
) |
786 |
|
{ |
787 |
|
int step; |
788 |
|
FVECT pos; |
862 |
|
} |
863 |
|
|
864 |
|
|
865 |
< |
backpicture(fill, samp) /* background fill algorithm */ |
866 |
< |
int (*fill)(); |
867 |
< |
int samp; |
865 |
> |
static void |
866 |
> |
backpicture( /* background fill algorithm */ |
867 |
> |
fillfunc_t *fill, |
868 |
> |
int samp |
869 |
> |
) |
870 |
|
{ |
871 |
|
int *yback, xback; |
872 |
|
int y; |
972 |
|
} |
973 |
|
|
974 |
|
|
975 |
< |
fillpicture(fill) /* paint in empty pixels using fill */ |
976 |
< |
int (*fill)(); |
975 |
> |
static void |
976 |
> |
fillpicture( /* paint in empty pixels using fill */ |
977 |
> |
fillfunc_t *fill |
978 |
> |
) |
979 |
|
{ |
980 |
|
register int x, y; |
981 |
|
|
988 |
|
} |
989 |
|
|
990 |
|
|
991 |
< |
clipaft() /* perform aft clipping as indicated */ |
991 |
> |
static int |
992 |
> |
clipaft(void) /* perform aft clipping as indicated */ |
993 |
|
{ |
994 |
|
register int x, y; |
995 |
|
int adjtest = (ourview.type == VT_PER) & zisnorm; |
1025 |
|
} |
1026 |
|
|
1027 |
|
|
1028 |
< |
addblur() /* add to blurred picture */ |
1028 |
> |
static int |
1029 |
> |
addblur(void) /* add to blurred picture */ |
1030 |
|
{ |
1031 |
|
COLOR cval; |
1032 |
|
double d; |
1066 |
|
} |
1067 |
|
|
1068 |
|
|
1069 |
< |
writepicture() /* write out picture (alters buffer) */ |
1069 |
> |
static void |
1070 |
> |
writepicture(void) /* write out picture (alters buffer) */ |
1071 |
|
{ |
1072 |
|
int y; |
1073 |
|
register int x; |
1098 |
|
} |
1099 |
|
|
1100 |
|
|
1101 |
< |
writedistance(fname) /* write out z file (alters buffer) */ |
1102 |
< |
char *fname; |
1101 |
> |
static void |
1102 |
> |
writedistance( /* write out z file (alters buffer) */ |
1103 |
> |
char *fname |
1104 |
> |
) |
1105 |
|
{ |
1106 |
|
int donorm = normdist & !zisnorm ? 1 : |
1107 |
|
(ourview.type == VT_PER) & !normdist & zisnorm ? -1 : 0; |
1133 |
|
} |
1134 |
|
|
1135 |
|
|
1136 |
< |
backfill(x, y) /* fill pixel with background */ |
1137 |
< |
int x, y; |
1136 |
> |
static void |
1137 |
> |
backfill( /* fill pixel with background */ |
1138 |
> |
int x, |
1139 |
> |
int y |
1140 |
> |
) |
1141 |
|
{ |
1142 |
|
if (averaging) { |
1143 |
|
copycolor(sscan(y)[x], backcolor); |
1148 |
|
} |
1149 |
|
|
1150 |
|
|
1151 |
< |
calstart(prog, args) /* start fill calculation */ |
1152 |
< |
char *prog, *args; |
1151 |
> |
static void |
1152 |
> |
calstart( /* start fill calculation */ |
1153 |
> |
char *prog, |
1154 |
> |
char *args |
1155 |
> |
) |
1156 |
|
{ |
1157 |
|
char combuf[512]; |
1158 |
|
char *argv[64]; |
1191 |
|
} |
1192 |
|
|
1193 |
|
|
1194 |
< |
caldone() /* done with calculation */ |
1194 |
> |
static void |
1195 |
> |
caldone(void) /* done with calculation */ |
1196 |
|
{ |
1197 |
|
if (!PDesc.running) |
1198 |
|
return; |
1201 |
|
} |
1202 |
|
|
1203 |
|
|
1204 |
< |
rcalfill(x, y) /* fill with ray-calculated pixel */ |
1205 |
< |
int x, y; |
1204 |
> |
static void |
1205 |
> |
rcalfill( /* fill with ray-calculated pixel */ |
1206 |
> |
int x, |
1207 |
> |
int y |
1208 |
> |
) |
1209 |
|
{ |
1210 |
|
if (queuesiz >= packsiz) /* flush queue if needed */ |
1211 |
|
clearqueue(); |
1216 |
|
} |
1217 |
|
|
1218 |
|
|
1219 |
< |
clearqueue() /* process queue */ |
1219 |
> |
static void |
1220 |
> |
clearqueue(void) /* process queue */ |
1221 |
|
{ |
1222 |
|
FVECT orig, dir; |
1223 |
|
float fbuf[6*(PACKSIZ+1)]; |
1273 |
|
} |
1274 |
|
|
1275 |
|
|
1276 |
< |
syserror(s) /* report error and exit */ |
1277 |
< |
char *s; |
1276 |
> |
static void |
1277 |
> |
syserror( /* report error and exit */ |
1278 |
> |
char *s |
1279 |
> |
) |
1280 |
|
{ |
1281 |
|
perror(s); |
1282 |
|
exit(1); |