65 |
|
} |
66 |
|
|
67 |
|
|
68 |
< |
normaspect(vp, ap, xp, yp) /* fix pixel aspect or resolution */ |
69 |
< |
VIEW *vp; |
70 |
< |
double *ap; |
71 |
< |
int *xp, *yp; |
68 |
> |
normaspect(va, ap, xp, yp) /* fix pixel aspect or resolution */ |
69 |
> |
double va; /* view aspect ratio */ |
70 |
> |
double *ap; /* pixel aspect in (or out if 0) */ |
71 |
> |
int *xp, *yp; /* x and y resolution in (or out if *ap!=0) */ |
72 |
|
{ |
73 |
– |
double va = viewaspect(vp); |
74 |
– |
|
73 |
|
if (*ap <= FTINY) |
74 |
< |
*ap = (double)*yp / *xp / va; /* compute pixel aspect */ |
74 |
> |
*ap = va * *xp / *yp; /* compute pixel aspect */ |
75 |
|
else if (va * *xp > *ap * *yp) |
76 |
< |
*xp = *yp / va * *ap; /* reduce x resolution */ |
76 |
> |
*xp = *yp / va * *ap + .5; /* reduce x resolution */ |
77 |
|
else |
78 |
< |
*yp = *xp * va / *ap; /* reduce y resolution */ |
78 |
> |
*yp = *xp * va / *ap + .5; /* reduce y resolution */ |
79 |
|
} |
80 |
|
|
81 |
|
|
119 |
|
if (zp != NULL) |
120 |
|
*zp = DOT(disp,v->vdir); |
121 |
|
} else { /* perspective view */ |
122 |
< |
d = 1.0/DOT(disp,v->vdir); |
122 |
> |
d = DOT(disp,v->vdir); |
123 |
|
if (zp != NULL) { |
124 |
|
*zp = sqrt(DOT(disp,disp)); |
125 |
|
if (d < 0.0) |
126 |
|
*zp = -*zp; |
127 |
|
} |
128 |
< |
disp[0] *= d; |
129 |
< |
disp[1] *= d; |
130 |
< |
disp[2] *= d; |
128 |
> |
if (d < 0.0) /* fold pyramid */ |
129 |
> |
d = -d; |
130 |
> |
if (d > FTINY) { |
131 |
> |
d = 1.0/d; |
132 |
> |
disp[0] *= d; |
133 |
> |
disp[1] *= d; |
134 |
> |
disp[2] *= d; |
135 |
> |
} |
136 |
|
} |
137 |
|
*xp = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff; |
138 |
|
*yp = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff; |
148 |
|
#define check(c,n) if ((av[0][c]&&av[0][c]!=' ') || n>=ac) return(-1) |
149 |
|
extern double atof(); |
150 |
|
|
151 |
< |
if (av[0][0] != '-' || av[0][1] != 'v') |
151 |
> |
if (ac <= 0 || av[0][0] != '-' || av[0][1] != 'v') |
152 |
|
return(-1); |
153 |
|
switch (av[0][2]) { |
154 |
|
case 't': /* type */ |
210 |
|
|
211 |
|
while (*s == ' ') |
212 |
|
s++; |
213 |
< |
do { |
213 |
> |
while (*s) { |
214 |
|
ac = 0; |
215 |
|
do { |
216 |
|
av[ac++] = s; |
223 |
|
if (na+1 < ac) |
224 |
|
s = av[na+1]; |
225 |
|
nvopts++; |
226 |
< |
} |
227 |
< |
} while (*s); |
226 |
> |
} else if (ac > 1) |
227 |
> |
s = av[1]; |
228 |
> |
} |
229 |
|
return(nvopts); |
230 |
|
} |
231 |
|
|
239 |
|
fprintf(fp, " -vd %.6g %.6g %.6g", vp->vdir[0], vp->vdir[1], vp->vdir[2]); |
240 |
|
fprintf(fp, " -vu %.6g %.6g %.6g", vp->vup[0], vp->vup[1], vp->vup[2]); |
241 |
|
fprintf(fp, " -vh %.6g -vv %.6g", vp->horiz, vp->vert); |
242 |
< |
fprintf(fp, " -vs %d -vl %d", vp->hoff, vp->voff); |
242 |
> |
fprintf(fp, " -vs %.6g -vl %.6g", vp->hoff, vp->voff); |
243 |
|
} |
244 |
|
|
245 |
|
|
264 |
|
|
265 |
|
|
266 |
|
int |
267 |
< |
viewfile(fname, vp) /* get view from file */ |
267 |
> |
viewfile(fname, vp, xp, yp) /* get view from file */ |
268 |
|
char *fname; |
269 |
|
VIEW *vp; |
270 |
+ |
int *xp, *yp; |
271 |
|
{ |
272 |
|
extern char *progname; |
273 |
|
FILE *fp; |
280 |
|
gothview = 0; |
281 |
|
|
282 |
|
getheader(fp, gethview); |
283 |
+ |
|
284 |
+ |
if (xp != NULL && yp != NULL |
285 |
+ |
&& fgetresolu(xp, yp, fp) == -1) |
286 |
+ |
gothview = 0; |
287 |
|
|
288 |
|
fclose(fp); |
289 |
|
|