10 |
|
* 10/17/85 |
11 |
|
*/ |
12 |
|
|
13 |
– |
#include <ctype.h> |
14 |
– |
|
13 |
|
#include "standard.h" |
14 |
|
|
15 |
|
#include "view.h" |
16 |
|
|
17 |
< |
VIEW stdview = STDVIEW(512); /* default view parameters */ |
17 |
> |
VIEW stdview = STDVIEW; /* default view parameters */ |
18 |
|
|
19 |
|
|
20 |
|
char * |
21 |
< |
sskip(s) /* skip a word */ |
24 |
< |
register char *s; |
25 |
< |
{ |
26 |
< |
while (isspace(*s)) s++; |
27 |
< |
while (*s && !isspace(*s)) s++; |
28 |
< |
return(s); |
29 |
< |
} |
30 |
< |
|
31 |
< |
|
32 |
< |
char * |
33 |
< |
setview(v) /* set vhinc and vvinc, return message on error */ |
21 |
> |
setview(v) /* set hvec and vvec, return message on error */ |
22 |
|
register VIEW *v; |
23 |
|
{ |
24 |
< |
double tan(), dt; |
24 |
> |
static char ill_horiz[] = "illegal horizontal view size"; |
25 |
> |
static char ill_vert[] = "illegal vertical view size"; |
26 |
|
|
27 |
|
if (normalize(v->vdir) == 0.0) /* normalize direction */ |
28 |
|
return("zero view direction"); |
40 |
– |
|
41 |
– |
fcross(v->vhinc, v->vdir, v->vup); /* compute horiz dir */ |
29 |
|
|
30 |
< |
if (normalize(v->vhinc) == 0.0) |
31 |
< |
return("illegal view up vector"); |
45 |
< |
|
46 |
< |
fcross(v->vvinc, v->vhinc, v->vdir); /* compute vert dir */ |
30 |
> |
if (normalize(v->vup) == 0.0) /* normalize view up */ |
31 |
> |
return("zero view up vector"); |
32 |
|
|
33 |
< |
if (v->type == VT_PAR) |
49 |
< |
dt = v->horiz; |
50 |
< |
else if (v->type == VT_PER) |
51 |
< |
dt = 2.0 * tan(v->horiz*(PI/180.0/2.0)); |
52 |
< |
else |
53 |
< |
return("unknown view type"); |
33 |
> |
fcross(v->hvec, v->vdir, v->vup); /* compute horiz dir */ |
34 |
|
|
35 |
< |
if (dt <= FTINY || dt >= FHUGE) |
36 |
< |
return("illegal horizontal view size"); |
35 |
> |
if (normalize(v->hvec) == 0.0) |
36 |
> |
return("view up parallel to view direction"); |
37 |
|
|
38 |
< |
if (v->hresolu <= 0) |
59 |
< |
return("illegal horizontal resolution"); |
38 |
> |
fcross(v->vvec, v->hvec, v->vdir); /* compute vert dir */ |
39 |
|
|
40 |
< |
dt /= (double)v->hresolu; |
41 |
< |
v->vhinc[0] *= dt; |
42 |
< |
v->vhinc[1] *= dt; |
43 |
< |
v->vhinc[2] *= dt; |
40 |
> |
if (v->horiz <= FTINY) |
41 |
> |
return(ill_horiz); |
42 |
> |
if (v->vert <= FTINY) |
43 |
> |
return(ill_vert); |
44 |
|
|
45 |
< |
if (v->type == VT_PAR) |
46 |
< |
dt = v->vert; |
47 |
< |
else |
48 |
< |
dt = 2.0 * tan(v->vert*(PI/180.0/2.0)); |
45 |
> |
switch (v->type) { |
46 |
> |
case VT_PAR: /* parallel view */ |
47 |
> |
v->hn2 = v->horiz; |
48 |
> |
v->vn2 = v->vert; |
49 |
> |
break; |
50 |
> |
case VT_PER: /* perspective view */ |
51 |
> |
if (v->horiz >= 180.0-FTINY) |
52 |
> |
return(ill_horiz); |
53 |
> |
if (v->vert >= 180.0-FTINY) |
54 |
> |
return(ill_vert); |
55 |
> |
v->hn2 = 2.0 * tan(v->horiz*(PI/180.0/2.0)); |
56 |
> |
v->vn2 = 2.0 * tan(v->vert*(PI/180.0/2.0)); |
57 |
> |
break; |
58 |
> |
case VT_ANG: /* angular fisheye */ |
59 |
> |
if (v->horiz > 360.0+FTINY) |
60 |
> |
return(ill_horiz); |
61 |
> |
if (v->vert > 360.0+FTINY) |
62 |
> |
return(ill_vert); |
63 |
> |
v->hn2 = v->horiz / 90.0; |
64 |
> |
v->vn2 = v->vert / 90.0; |
65 |
> |
break; |
66 |
> |
case VT_HEM: /* hemispherical fisheye */ |
67 |
> |
if (v->horiz > 180.0+FTINY) |
68 |
> |
return(ill_horiz); |
69 |
> |
if (v->vert > 180.0+FTINY) |
70 |
> |
return(ill_vert); |
71 |
> |
v->hn2 = 2.0 * sin(v->horiz*(PI/180.0/2.0)); |
72 |
> |
v->vn2 = 2.0 * sin(v->vert*(PI/180.0/2.0)); |
73 |
> |
break; |
74 |
> |
default: |
75 |
> |
return("unknown view type"); |
76 |
> |
} |
77 |
> |
if (v->type != VT_ANG) { |
78 |
> |
v->hvec[0] *= v->hn2; |
79 |
> |
v->hvec[1] *= v->hn2; |
80 |
> |
v->hvec[2] *= v->hn2; |
81 |
> |
v->vvec[0] *= v->vn2; |
82 |
> |
v->vvec[1] *= v->vn2; |
83 |
> |
v->vvec[2] *= v->vn2; |
84 |
> |
} |
85 |
> |
v->hn2 *= v->hn2; |
86 |
> |
v->vn2 *= v->vn2; |
87 |
|
|
88 |
< |
if (dt <= FTINY || dt >= FHUGE) |
89 |
< |
return("illegal vertical view size"); |
88 |
> |
return(NULL); |
89 |
> |
} |
90 |
|
|
74 |
– |
if (v->vresolu <= 0) |
75 |
– |
return("illegal vertical resolution"); |
76 |
– |
|
77 |
– |
dt /= (double)v->vresolu; |
78 |
– |
v->vvinc[0] *= dt; |
79 |
– |
v->vvinc[1] *= dt; |
80 |
– |
v->vvinc[2] *= dt; |
91 |
|
|
92 |
< |
v->vhs2 = 1.0/DOT(v->vhinc,v->vhinc); |
93 |
< |
v->vvs2 = 1.0/DOT(v->vvinc,v->vvinc); |
94 |
< |
|
95 |
< |
return(NULL); |
92 |
> |
normaspect(va, ap, xp, yp) /* fix pixel aspect or resolution */ |
93 |
> |
double va; /* view aspect ratio */ |
94 |
> |
double *ap; /* pixel aspect in (or out if 0) */ |
95 |
> |
int *xp, *yp; /* x and y resolution in (or out if *ap!=0) */ |
96 |
> |
{ |
97 |
> |
if (*ap <= FTINY) |
98 |
> |
*ap = va * *xp / *yp; /* compute pixel aspect */ |
99 |
> |
else if (va * *xp > *ap * *yp) |
100 |
> |
*xp = *yp / va * *ap + .5; /* reduce x resolution */ |
101 |
> |
else |
102 |
> |
*yp = *xp * va / *ap + .5; /* reduce y resolution */ |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
< |
rayview(orig, direc, v, x, y) /* compute ray origin and direction */ |
106 |
> |
viewray(orig, direc, v, x, y) /* compute ray origin and direction */ |
107 |
|
FVECT orig, direc; |
108 |
|
register VIEW *v; |
109 |
|
double x, y; |
110 |
|
{ |
111 |
< |
x -= 0.5 * v->hresolu; |
112 |
< |
y -= 0.5 * v->vresolu; |
111 |
> |
double d, z; |
112 |
> |
|
113 |
> |
x += v->hoff - 0.5; |
114 |
> |
y += v->voff - 0.5; |
115 |
|
|
116 |
< |
if (v->type == VT_PAR) { /* parallel view */ |
117 |
< |
orig[0] = v->vp[0] + x*v->vhinc[0] + y*v->vvinc[0]; |
118 |
< |
orig[1] = v->vp[1] + x*v->vhinc[1] + y*v->vvinc[1]; |
119 |
< |
orig[2] = v->vp[2] + x*v->vhinc[2] + y*v->vvinc[2]; |
116 |
> |
switch(v->type) { |
117 |
> |
case VT_PAR: /* parallel view */ |
118 |
> |
orig[0] = v->vp[0] + x*v->hvec[0] + y*v->vvec[0]; |
119 |
> |
orig[1] = v->vp[1] + x*v->hvec[1] + y*v->vvec[1]; |
120 |
> |
orig[2] = v->vp[2] + x*v->hvec[2] + y*v->vvec[2]; |
121 |
|
VCOPY(direc, v->vdir); |
122 |
< |
} else { /* perspective view */ |
122 |
> |
return(0); |
123 |
> |
case VT_PER: /* perspective view */ |
124 |
|
VCOPY(orig, v->vp); |
125 |
< |
direc[0] = v->vdir[0] + x*v->vhinc[0] + y*v->vvinc[0]; |
126 |
< |
direc[1] = v->vdir[1] + x*v->vhinc[1] + y*v->vvinc[1]; |
127 |
< |
direc[2] = v->vdir[2] + x*v->vhinc[2] + y*v->vvinc[2]; |
125 |
> |
direc[0] = v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; |
126 |
> |
direc[1] = v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; |
127 |
> |
direc[2] = v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; |
128 |
|
normalize(direc); |
129 |
+ |
return(0); |
130 |
+ |
case VT_HEM: /* hemispherical fisheye */ |
131 |
+ |
z = 1.0 - x*x*v->hn2 - y*y*v->vn2; |
132 |
+ |
if (z < 0.0) |
133 |
+ |
return(-1); |
134 |
+ |
z = sqrt(z); |
135 |
+ |
VCOPY(orig, v->vp); |
136 |
+ |
direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; |
137 |
+ |
direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; |
138 |
+ |
direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; |
139 |
+ |
return(0); |
140 |
+ |
case VT_ANG: /* angular fisheye */ |
141 |
+ |
x *= v->horiz/180.0; |
142 |
+ |
y *= v->vert/180.0; |
143 |
+ |
d = x*x + y*y; |
144 |
+ |
if (d > 1.0) |
145 |
+ |
return(-1); |
146 |
+ |
VCOPY(orig, v->vp); |
147 |
+ |
if (d <= FTINY) { |
148 |
+ |
VCOPY(direc, v->vdir); |
149 |
+ |
return(0); |
150 |
+ |
} |
151 |
+ |
d = sqrt(d); |
152 |
+ |
z = cos(PI*d); |
153 |
+ |
d = sqrt(1 - z*z)/d; |
154 |
+ |
x *= d; |
155 |
+ |
y *= d; |
156 |
+ |
direc[0] = z*v->vdir[0] + x*v->hvec[0] + y*v->vvec[0]; |
157 |
+ |
direc[1] = z*v->vdir[1] + x*v->hvec[1] + y*v->vvec[1]; |
158 |
+ |
direc[2] = z*v->vdir[2] + x*v->hvec[2] + y*v->vvec[2]; |
159 |
+ |
return(0); |
160 |
|
} |
161 |
+ |
return(-1); |
162 |
|
} |
163 |
|
|
164 |
|
|
165 |
< |
pixelview(xp, yp, zp, v, p) /* find image location for point */ |
165 |
> |
viewpixel(xp, yp, zp, v, p) /* find image location for point */ |
166 |
|
double *xp, *yp, *zp; |
167 |
|
register VIEW *v; |
168 |
|
FVECT p; |
169 |
|
{ |
117 |
– |
extern double sqrt(); |
170 |
|
double d; |
171 |
|
FVECT disp; |
172 |
< |
|
172 |
> |
|
173 |
|
disp[0] = p[0] - v->vp[0]; |
174 |
|
disp[1] = p[1] - v->vp[1]; |
175 |
|
disp[2] = p[2] - v->vp[2]; |
176 |
|
|
177 |
< |
if (v->type == VT_PAR) { /* parallel view */ |
177 |
> |
switch (v->type) { |
178 |
> |
case VT_PAR: /* parallel view */ |
179 |
|
if (zp != NULL) |
180 |
|
*zp = DOT(disp,v->vdir); |
181 |
< |
} else { /* perspective view */ |
182 |
< |
d = 1.0/DOT(disp,v->vdir); |
181 |
> |
break; |
182 |
> |
case VT_PER: /* perspective view */ |
183 |
> |
d = DOT(disp,v->vdir); |
184 |
|
if (zp != NULL) { |
185 |
|
*zp = sqrt(DOT(disp,disp)); |
186 |
|
if (d < 0.0) |
187 |
|
*zp = -*zp; |
188 |
|
} |
189 |
< |
disp[0] *= d; |
190 |
< |
disp[1] *= d; |
191 |
< |
disp[2] *= d; |
189 |
> |
if (d < 0.0) /* fold pyramid */ |
190 |
> |
d = -d; |
191 |
> |
if (d > FTINY) { |
192 |
> |
d = 1.0/d; |
193 |
> |
disp[0] *= d; |
194 |
> |
disp[1] *= d; |
195 |
> |
disp[2] *= d; |
196 |
> |
} |
197 |
> |
break; |
198 |
> |
case VT_HEM: /* hemispherical fisheye */ |
199 |
> |
d = normalize(disp); |
200 |
> |
if (zp != NULL) { |
201 |
> |
if (DOT(disp,v->vdir) < 0.0) |
202 |
> |
*zp = -d; |
203 |
> |
else |
204 |
> |
*zp = d; |
205 |
> |
} |
206 |
> |
break; |
207 |
> |
case VT_ANG: /* angular fisheye */ |
208 |
> |
d = normalize(disp); |
209 |
> |
if (zp != NULL) |
210 |
> |
*zp = d; |
211 |
> |
*xp = 0.5 - v->hoff; |
212 |
> |
*yp = 0.5 - v->voff; |
213 |
> |
d = DOT(disp,v->vdir); |
214 |
> |
if (d >= 1.0-FTINY) |
215 |
> |
return; |
216 |
> |
if (d <= -(1.0-FTINY)) { |
217 |
> |
*xp += 180.0/v->horiz; |
218 |
> |
*yp += 180.0/v->vert; |
219 |
> |
return; |
220 |
> |
} |
221 |
> |
d = acos(d)/PI / sqrt(1.0 - d*d); |
222 |
> |
*xp += DOT(disp,v->hvec)*d*180.0/v->horiz; |
223 |
> |
*yp += DOT(disp,v->vvec)*d*180.0/v->vert; |
224 |
> |
return; |
225 |
|
} |
226 |
< |
*xp = DOT(disp,v->vhinc)*v->vhs2 + 0.5*v->hresolu; |
227 |
< |
*yp = DOT(disp,v->vvinc)*v->vvs2 + 0.5*v->vresolu; |
226 |
> |
*xp = DOT(disp,v->hvec)/v->hn2 + 0.5 - v->hoff; |
227 |
> |
*yp = DOT(disp,v->vvec)/v->vn2 + 0.5 - v->voff; |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
< |
sscanview(vp, s) /* get view parameters */ |
232 |
< |
register VIEW *vp; |
231 |
> |
int |
232 |
> |
getviewopt(v, ac, av) /* process view argument */ |
233 |
> |
register VIEW *v; |
234 |
> |
int ac; |
235 |
> |
register char *av[]; |
236 |
> |
{ |
237 |
> |
#define check(c,n) if ((av[0][c]&&av[0][c]!=' ') || n>=ac) return(-1) |
238 |
> |
extern double atof(); |
239 |
> |
|
240 |
> |
if (ac <= 0 || av[0][0] != '-' || av[0][1] != 'v') |
241 |
> |
return(-1); |
242 |
> |
switch (av[0][2]) { |
243 |
> |
case 't': /* type */ |
244 |
> |
if (!av[0][3] || av[0][3]==' ') |
245 |
> |
return(-1); |
246 |
> |
check(4,0); |
247 |
> |
v->type = av[0][3]; |
248 |
> |
return(0); |
249 |
> |
case 'p': /* point */ |
250 |
> |
check(3,3); |
251 |
> |
v->vp[0] = atof(av[1]); |
252 |
> |
v->vp[1] = atof(av[2]); |
253 |
> |
v->vp[2] = atof(av[3]); |
254 |
> |
return(3); |
255 |
> |
case 'd': /* direction */ |
256 |
> |
check(3,3); |
257 |
> |
v->vdir[0] = atof(av[1]); |
258 |
> |
v->vdir[1] = atof(av[2]); |
259 |
> |
v->vdir[2] = atof(av[3]); |
260 |
> |
return(3); |
261 |
> |
case 'u': /* up */ |
262 |
> |
check(3,3); |
263 |
> |
v->vup[0] = atof(av[1]); |
264 |
> |
v->vup[1] = atof(av[2]); |
265 |
> |
v->vup[2] = atof(av[3]); |
266 |
> |
return(3); |
267 |
> |
case 'h': /* horizontal size */ |
268 |
> |
check(3,1); |
269 |
> |
v->horiz = atof(av[1]); |
270 |
> |
return(1); |
271 |
> |
case 'v': /* vertical size */ |
272 |
> |
check(3,1); |
273 |
> |
v->vert = atof(av[1]); |
274 |
> |
return(1); |
275 |
> |
case 's': /* shift */ |
276 |
> |
check(3,1); |
277 |
> |
v->hoff = atof(av[1]); |
278 |
> |
return(1); |
279 |
> |
case 'l': /* lift */ |
280 |
> |
check(3,1); |
281 |
> |
v->voff = atof(av[1]); |
282 |
> |
return(1); |
283 |
> |
default: |
284 |
> |
return(-1); |
285 |
> |
} |
286 |
> |
#undef check |
287 |
> |
} |
288 |
> |
|
289 |
> |
|
290 |
> |
int |
291 |
> |
sscanview(vp, s) /* get view parameters from string */ |
292 |
> |
VIEW *vp; |
293 |
|
register char *s; |
294 |
|
{ |
295 |
< |
for ( ; ; ) |
296 |
< |
switch (*s++) { |
297 |
< |
case '\0': |
298 |
< |
case '\n': |
299 |
< |
return(0); |
300 |
< |
case '-': |
301 |
< |
switch (*s++) { |
302 |
< |
case '\0': |
303 |
< |
return(-1); |
304 |
< |
case 'x': |
305 |
< |
if (sscanf(s, "%d", &vp->hresolu) != 1) |
306 |
< |
return(-1); |
307 |
< |
s = sskip(s); |
308 |
< |
continue; |
309 |
< |
case 'y': |
310 |
< |
if (sscanf(s, "%d", &vp->vresolu) != 1) |
311 |
< |
return(-1); |
312 |
< |
s = sskip(s); |
313 |
< |
continue; |
314 |
< |
case 'v': |
315 |
< |
switch (*s++) { |
316 |
< |
case '\0': |
317 |
< |
return(-1); |
318 |
< |
case 't': |
172 |
< |
vp->type = *s++; |
173 |
< |
continue; |
174 |
< |
case 'p': |
175 |
< |
if (sscanf(s, "%lf %lf %lf", |
176 |
< |
&vp->vp[0], |
177 |
< |
&vp->vp[1], |
178 |
< |
&vp->vp[2]) != 3) |
179 |
< |
return(-1); |
180 |
< |
s = sskip(sskip(sskip(s))); |
181 |
< |
continue; |
182 |
< |
case 'd': |
183 |
< |
if (sscanf(s, "%lf %lf %lf", |
184 |
< |
&vp->vdir[0], |
185 |
< |
&vp->vdir[1], |
186 |
< |
&vp->vdir[2]) != 3) |
187 |
< |
return(-1); |
188 |
< |
s = sskip(sskip(sskip(s))); |
189 |
< |
continue; |
190 |
< |
case 'u': |
191 |
< |
if (sscanf(s, "%lf %lf %lf", |
192 |
< |
&vp->vup[0], |
193 |
< |
&vp->vup[1], |
194 |
< |
&vp->vup[2]) != 3) |
195 |
< |
return(-1); |
196 |
< |
s = sskip(sskip(sskip(s))); |
197 |
< |
continue; |
198 |
< |
case 'h': |
199 |
< |
if (sscanf(s, "%lf", |
200 |
< |
&vp->horiz) != 1) |
201 |
< |
return(-1); |
202 |
< |
s = sskip(s); |
203 |
< |
continue; |
204 |
< |
case 'v': |
205 |
< |
if (sscanf(s, "%lf", |
206 |
< |
&vp->vert) != 1) |
207 |
< |
return(-1); |
208 |
< |
s = sskip(s); |
209 |
< |
continue; |
210 |
< |
} |
211 |
< |
continue; |
212 |
< |
} |
213 |
< |
continue; |
214 |
< |
} |
295 |
> |
int ac; |
296 |
> |
char *av[4]; |
297 |
> |
int na; |
298 |
> |
int nvopts = 0; |
299 |
> |
|
300 |
> |
while (*s == ' ') |
301 |
> |
s++; |
302 |
> |
while (*s) { |
303 |
> |
ac = 0; |
304 |
> |
do { |
305 |
> |
av[ac++] = s; |
306 |
> |
while (*s && *s != ' ') |
307 |
> |
s++; |
308 |
> |
while (*s == ' ') |
309 |
> |
s++; |
310 |
> |
} while (*s && ac < 4); |
311 |
> |
if ((na = getviewopt(vp, ac, av)) >= 0) { |
312 |
> |
if (na+1 < ac) |
313 |
> |
s = av[na+1]; |
314 |
> |
nvopts++; |
315 |
> |
} else if (ac > 1) |
316 |
> |
s = av[1]; |
317 |
> |
} |
318 |
> |
return(nvopts); |
319 |
|
} |
320 |
|
|
321 |
|
|
328 |
|
fprintf(fp, " -vd %.6g %.6g %.6g", vp->vdir[0], vp->vdir[1], vp->vdir[2]); |
329 |
|
fprintf(fp, " -vu %.6g %.6g %.6g", vp->vup[0], vp->vup[1], vp->vup[2]); |
330 |
|
fprintf(fp, " -vh %.6g -vv %.6g", vp->horiz, vp->vert); |
331 |
< |
fprintf(fp, " -x %d -y %d", vp->hresolu, vp->vresolu); |
331 |
> |
fprintf(fp, " -vs %.6g -vl %.6g", vp->hoff, vp->voff); |
332 |
|
} |
333 |
|
|
334 |
|
|
231 |
– |
static VIEW *hview; /* view from header */ |
232 |
– |
static int gothview; /* success indicator */ |
335 |
|
static char *altname[] = {NULL,"rpict","rview","pinterp",VIEWSTR,NULL}; |
336 |
|
|
337 |
+ |
struct myview { |
338 |
+ |
VIEW *hv; |
339 |
+ |
int ok; |
340 |
+ |
}; |
341 |
|
|
342 |
+ |
|
343 |
|
static |
344 |
< |
gethview(s) /* get view from header */ |
344 |
> |
gethview(s, v) /* get view from header */ |
345 |
|
char *s; |
346 |
+ |
register struct myview *v; |
347 |
|
{ |
348 |
|
register char **an; |
349 |
|
|
350 |
|
for (an = altname; *an != NULL; an++) |
351 |
|
if (!strncmp(*an, s, strlen(*an))) { |
352 |
< |
if (sscanview(hview, s+strlen(*an)) == 0) |
353 |
< |
gothview++; |
352 |
> |
if (sscanview(v->hv, s+strlen(*an)) > 0) |
353 |
> |
v->ok++; |
354 |
|
return; |
355 |
|
} |
356 |
|
} |
357 |
|
|
358 |
|
|
359 |
|
int |
360 |
< |
viewfile(fname, vp) /* get view from file */ |
360 |
> |
viewfile(fname, vp, xp, yp) /* get view from file */ |
361 |
|
char *fname; |
362 |
|
VIEW *vp; |
363 |
+ |
int *xp, *yp; |
364 |
|
{ |
365 |
|
extern char *progname; |
366 |
+ |
struct myview mvs; |
367 |
|
FILE *fp; |
368 |
|
|
369 |
|
if ((fp = fopen(fname, "r")) == NULL) |
370 |
|
return(-1); |
371 |
|
|
372 |
|
altname[0] = progname; |
373 |
< |
hview = vp; |
374 |
< |
gothview = 0; |
373 |
> |
mvs.hv = vp; |
374 |
> |
mvs.ok = 0; |
375 |
|
|
376 |
< |
getheader(fp, gethview); |
376 |
> |
getheader(fp, gethview, &mvs); |
377 |
|
|
378 |
+ |
if (xp != NULL && yp != NULL |
379 |
+ |
&& fgetresolu(xp, yp, fp) == -1) |
380 |
+ |
mvs.ok = 0; |
381 |
+ |
|
382 |
|
fclose(fp); |
383 |
|
|
384 |
< |
return(gothview); |
384 |
> |
return(mvs.ok); |
385 |
|
} |