7 |
|
* Greg Ward 09Dec89 |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include "standard.h" |
10 |
> |
#include "copyright.h" |
11 |
|
|
12 |
|
#include <ctype.h> |
13 |
+ |
#include <string.h> |
14 |
|
|
15 |
+ |
#include "standard.h" |
16 |
+ |
#include "rtprocess.h" /* Windows: must come before color.h */ |
17 |
|
#include "view.h" |
15 |
– |
|
18 |
|
#include "color.h" |
19 |
|
|
20 |
|
#define LOG2 0.69314718055994530942 |
86 |
|
MAT4 theirs2ours; /* transformation matrix */ |
87 |
|
int hasmatrix = 0; /* has transformation matrix */ |
88 |
|
|
89 |
< |
int PDesc[3] = {-1,-1,-1}; /* rtrace process descriptor */ |
88 |
< |
#define childpid (PDesc[2]) |
89 |
> |
static SUBPROC PDesc = SP_INACTIVE; /* rtrace process descriptor */ |
90 |
|
unsigned short queue[PACKSIZ][2]; /* pending pixels */ |
91 |
|
int packsiz; /* actual packet size */ |
92 |
|
int queuesiz = 0; /* number of pixels pending */ |
232 |
|
fillo &= ~F_BACK; |
233 |
|
if (doavg < 0) |
234 |
|
doavg = (argc-an) > 2; |
235 |
< |
if (expcomp != NULL) |
235 |
> |
if (expcomp != NULL) { |
236 |
|
if (expcomp[0] == '+' | expcomp[0] == '-') { |
237 |
|
expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5); |
238 |
|
if (doavg | doblur) |
247 |
|
if (!(doavg | doblur)) |
248 |
|
rexpadj = pow(2.0, (double)expadj); |
249 |
|
} |
250 |
+ |
} |
251 |
|
/* set view */ |
252 |
|
if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) { |
253 |
|
fprintf(stderr, "%s: no view on standard input!\n", |
279 |
|
fputnow(stdout); |
280 |
|
/* run pictures */ |
281 |
|
do { |
282 |
< |
bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float)); |
282 |
> |
memset((char *)ourzbuf, '\0', hresolu*vresolu*sizeof(float)); |
283 |
|
for (i = an; i < argc; i += 2) |
284 |
|
addpicture(argv[i], argv[i+1]); |
285 |
|
if (fillo&F_BACK) /* fill in spaces */ |
375 |
|
exit(1); |
376 |
|
} |
377 |
|
if (!nvavg) { /* first view */ |
378 |
< |
copystruct(&avgview, &ourview); |
378 |
> |
avgview = ourview; |
379 |
|
return(nvavg++); |
380 |
|
} |
381 |
|
/* add to average view */ |
414 |
|
avgview.vfore *= f; |
415 |
|
avgview.vaft *= f; |
416 |
|
if (setview(&avgview) != NULL) /* in case of emergency... */ |
417 |
< |
copystruct(&avgview, &ourview); |
417 |
> |
avgview = ourview; |
418 |
|
pixaspect = viewaspect(&avgview) * hresolu / vresolu; |
419 |
|
} |
420 |
|
|
435 |
|
syserror(pfile); |
436 |
|
/* get header with exposure and view */ |
437 |
|
theirexp = 1.0; |
438 |
< |
copystruct(&theirview, &stdview); |
438 |
> |
theirview = stdview; |
439 |
|
gotview = 0; |
440 |
|
if (nvavg < 2) |
441 |
|
printf("%s:\n", pfile); |
804 |
|
xl[y-1].max = xl[y-step].max; |
805 |
|
} |
806 |
|
for (x = 2; x < step; x++) |
807 |
< |
copystruct(xl+y-x, xl+y-1); |
807 |
> |
*(xl+y-x) = *(xl+y-1); |
808 |
|
} |
809 |
|
if (yl->max >= numscans(&tresolu)) |
810 |
|
yl->max = numscans(&tresolu) - 1; |
811 |
|
y -= step; |
812 |
|
for (x = numscans(&tresolu) - 1; x > y; x--) /* fill bottom rows */ |
813 |
< |
copystruct(xl+x, xl+y); |
813 |
> |
*(xl+x) = *(xl+y); |
814 |
|
return(yl->max >= yl->min); |
815 |
|
} |
816 |
|
|
963 |
|
continue; |
964 |
|
} |
965 |
|
if (averaging) |
966 |
< |
bzero(sscan(y)[x], sizeof(COLOR)); |
966 |
> |
memset(sscan(y)[x], '\0', sizeof(COLOR)); |
967 |
|
else |
968 |
< |
bzero(pscan(y)[x], sizeof(COLR)); |
968 |
> |
memset(pscan(y)[x], '\0', sizeof(COLR)); |
969 |
|
zscan(y)[x] = 0.0; |
970 |
|
} |
971 |
|
} |
1097 |
|
int rval; |
1098 |
|
register char **wp, *cp; |
1099 |
|
|
1100 |
< |
if (childpid != -1) { |
1100 |
> |
if (PDesc.running) { |
1101 |
|
fprintf(stderr, "%s: too many calculations\n", progname); |
1102 |
|
exit(1); |
1103 |
|
} |
1116 |
|
} |
1117 |
|
*wp = NULL; |
1118 |
|
/* start process */ |
1119 |
< |
if ((rval = open_process(PDesc, argv)) < 0) |
1119 |
> |
if ((rval = open_process(&PDesc, argv)) < 0) |
1120 |
|
syserror(progname); |
1121 |
|
if (rval == 0) { |
1122 |
|
fprintf(stderr, "%s: command not found\n", argv[0]); |
1131 |
|
|
1132 |
|
caldone() /* done with calculation */ |
1133 |
|
{ |
1134 |
< |
if (childpid == -1) |
1134 |
> |
if (!PDesc.running) |
1135 |
|
return; |
1136 |
|
clearqueue(); |
1137 |
< |
close_process(PDesc); |
1136 |
< |
childpid = -1; |
1137 |
> |
close_process(&PDesc); |
1138 |
|
} |
1139 |
|
|
1140 |
|
|
1169 |
|
*fbp++ = dir[0]; *fbp++ = dir[1]; *fbp++ = dir[2]; |
1170 |
|
} |
1171 |
|
/* mark end and get results */ |
1172 |
< |
bzero((char *)fbp, 6*sizeof(float)); |
1173 |
< |
if (process(PDesc, (char *)fbuf, (char *)fbuf, |
1172 |
> |
memset((char *)fbp, '\0', 6*sizeof(float)); |
1173 |
> |
if (process(&PDesc, (char *)fbuf, (char *)fbuf, |
1174 |
|
4*sizeof(float)*(queuesiz+1), |
1175 |
|
6*sizeof(float)*(queuesiz+1)) != |
1176 |
|
4*sizeof(float)*(queuesiz+1)) { |