51 |
|
check(2,1); |
52 |
|
zeps = atof(argv[++i]); |
53 |
|
break; |
54 |
+ |
case 'x': /* x resolution */ |
55 |
+ |
check(2,1); |
56 |
+ |
ourview.hresolu = atoi(argv[++i]); |
57 |
+ |
break; |
58 |
+ |
case 'y': /* y resolution */ |
59 |
+ |
check(2,1); |
60 |
+ |
ourview.vresolu = atoi(argv[++i]); |
61 |
+ |
break; |
62 |
|
case 'v': /* view */ |
63 |
|
switch (argv[i][2]) { |
64 |
|
case 't': /* type */ |
296 |
|
} |
297 |
|
pos[0] += .5*ourview.hresolu; |
298 |
|
pos[1] += .5*ourview.vresolu; |
299 |
< |
if (pos[0] < 0 || pos[0] > ourview.hresolu |
300 |
< |
|| pos[1] < 0 || pos[1] > ourview.vresolu) |
299 |
> |
if (pos[0] < 0 || pos[0] >= ourview.hresolu |
300 |
> |
|| pos[1] < 0 || pos[1] >= ourview.vresolu) |
301 |
|
continue; |
302 |
|
/* check current value at pos */ |
303 |
|
xpos = pos[0]; |
326 |
|
} |
327 |
|
for (x = 0; x < ourview.hresolu; x++) |
328 |
|
yback[x] = -2; |
329 |
+ |
/* |
330 |
+ |
* Xback and yback are the pixel locations of suitable |
331 |
+ |
* background values in each direction. |
332 |
+ |
* A value of -2 means unassigned, and -1 means |
333 |
+ |
* that there is no suitable background in this direction. |
334 |
+ |
*/ |
335 |
|
/* fill image */ |
336 |
|
for (y = 0; y < ourview.vresolu; y++) { |
337 |
|
xback = -2; |
338 |
|
for (x = 0; x < ourview.hresolu; x++) |
339 |
|
if (zscan(y)[x] <= 0.0) { /* empty pixel */ |
340 |
+ |
/* |
341 |
+ |
* First, find background from above or below. |
342 |
+ |
* (farthest assigned pixel) |
343 |
+ |
*/ |
344 |
|
if (yback[x] == -2) { |
345 |
|
for (i = y+1; i < ourview.vresolu; i++) |
346 |
|
if (zscan(i)[x] > 0.0) |
351 |
|
else |
352 |
|
yback[x] = y-1; |
353 |
|
} |
354 |
+ |
/* |
355 |
+ |
* Next, find background from left or right. |
356 |
+ |
*/ |
357 |
|
if (xback == -2) { |
358 |
|
for (i = x+1; x < ourview.hresolu; i++) |
359 |
|
if (zscan(y)[i] > 0.0) |
365 |
|
xback = x-1; |
366 |
|
} |
367 |
|
if (xback < 0 && yback[x] < 0) |
368 |
< |
continue; |
368 |
> |
continue; /* no background */ |
369 |
> |
/* |
370 |
> |
* Compare, and use the background that is |
371 |
> |
* farther, unless one of them is next to us. |
372 |
> |
*/ |
373 |
|
if (yback[x] < 0 || ABS(x-xback) <= 1 |
374 |
|
|| ( ABS(y-yback[x]) > 1 |
375 |
|
&& zscan(yback[x])[x] < zscan(y)[xback] )) |