103 |
|
COLOR *scanbar[MAXDIV+1]; /* scanline arrays of pixel values */ |
104 |
|
float *zbar[MAXDIV+1]; /* z values */ |
105 |
|
int ypos; /* current scanline */ |
106 |
+ |
int ystep; /* current y step size */ |
107 |
|
FILE *zfp; |
108 |
|
COLOR *colptr; |
109 |
|
float *zptr; |
143 |
|
error(SYSTEM, "z file seek error in render"); |
144 |
|
ypos = vresolu-1 - i; |
145 |
|
fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); |
146 |
+ |
ystep = psample; |
147 |
|
/* compute scanlines */ |
148 |
< |
for (ypos -= psample; ypos >= 0; ypos -= psample) { |
149 |
< |
|
150 |
< |
pctdone = 100.0*(vresolu-ypos-psample)/vresolu; |
151 |
< |
|
152 |
< |
colptr = scanbar[psample]; /* move base to top */ |
153 |
< |
scanbar[psample] = scanbar[0]; |
148 |
> |
for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { |
149 |
> |
/* record progress */ |
150 |
> |
pctdone = 100.0*(vresolu-ypos-ystep)/vresolu; |
151 |
> |
/* bottom adjust? */ |
152 |
> |
if (ypos < 0) { |
153 |
> |
ystep += ypos; |
154 |
> |
ypos = 0; |
155 |
> |
} |
156 |
> |
colptr = scanbar[ystep]; /* move base to top */ |
157 |
> |
scanbar[ystep] = scanbar[0]; |
158 |
|
scanbar[0] = colptr; |
159 |
< |
zptr = zbar[psample]; |
160 |
< |
zbar[psample] = zbar[0]; |
159 |
> |
zptr = zbar[ystep]; |
160 |
> |
zbar[ystep] = zbar[0]; |
161 |
|
zbar[0] = zptr; |
162 |
|
/* fill base line */ |
163 |
|
fillscanline(scanbar[0], zbar[0], hresolu, ypos, psample); |
164 |
|
/* fill bar */ |
165 |
< |
fillscanbar(scanbar, zbar, hresolu, ypos, psample); |
165 |
> |
fillscanbar(scanbar, zbar, hresolu, ypos, ystep); |
166 |
|
/* write it out */ |
167 |
< |
for (i = psample; i > 0; i--) { |
167 |
> |
for (i = ystep; i > 0; i--) { |
168 |
|
if (zfp != NULL && fwrite(zbar[i],sizeof(float),hresolu,zfp) != hresolu) |
169 |
|
goto writerr; |
170 |
|
if (fwritescan(scanbar[i],hresolu,stdout) < 0) |
175 |
|
if (fflush(stdout) == EOF) |
176 |
|
goto writerr; |
177 |
|
} |
172 |
– |
/* compute residual */ |
173 |
– |
colptr = scanbar[psample]; |
174 |
– |
scanbar[psample] = scanbar[0]; |
175 |
– |
scanbar[0] = colptr; |
176 |
– |
zptr = zbar[psample]; |
177 |
– |
zbar[psample] = zbar[0]; |
178 |
– |
zbar[0] = zptr; |
179 |
– |
if (ypos > -psample) { |
180 |
– |
fillscanline(scanbar[-ypos], zbar[-ypos], hresolu, 0, psample); |
181 |
– |
fillscanbar(scanbar-ypos, zbar-ypos, hresolu, 0, psample+ypos); |
182 |
– |
} |
183 |
– |
for (i = psample; i+ypos >= 0; i--) { |
184 |
– |
if (zfp != NULL && fwrite(zbar[i],sizeof(float),hresolu,zfp) != hresolu) |
185 |
– |
goto writerr; |
186 |
– |
if (fwritescan(scanbar[i], hresolu, stdout) < 0) |
187 |
– |
goto writerr; |
188 |
– |
} |
178 |
|
/* clean up */ |
179 |
|
if (zfp != NULL) { |
180 |
+ |
fwrite(zbar[0], sizeof(float), hresolu, zfp); |
181 |
|
if (fclose(zfp) == EOF) |
182 |
|
goto writerr; |
183 |
|
for (i = 0; i <= psample; i++) |
184 |
|
free((char *)zbar[i]); |
185 |
|
} |
186 |
+ |
fwritescan(scanbar[0], hresolu, stdout); |
187 |
|
if (fflush(stdout) == EOF) |
188 |
|
goto writerr; |
189 |
|
for (i = 0; i <= psample; i++) |
209 |
|
z = pixvalue(scanline[0], 0, y); |
210 |
|
if (zline) zline[0] = z; |
211 |
|
|
212 |
< |
for (i = xstep; i < xres; i += xstep) { |
213 |
< |
|
212 |
> |
for (i = xstep; i < xres-1+xstep; i += xstep) { |
213 |
> |
if (i >= xres) { |
214 |
> |
xstep += xres-1-i; |
215 |
> |
i = xres-1; |
216 |
> |
} |
217 |
|
z = pixvalue(scanline[i], i, y); |
218 |
|
if (zline) zline[i] = z; |
219 |
|
|
220 |
|
b = fillsample(scanline+i-xstep, zline ? zline+i-xstep : NULL, |
221 |
|
i-xstep, y, xstep, 0, b/2); |
228 |
– |
} |
229 |
– |
if (i-xstep < xres-1) { |
230 |
– |
z = pixvalue(scanline[xres-1], xres-1, y); |
231 |
– |
if (zline) zline[xres-1] = z; |
232 |
– |
fillsample(scanline+i-xstep, zline ? zline+i-xstep : NULL, |
233 |
– |
i-xstep, y, xres-1-(i-xstep), 0, b/2); |
222 |
|
} |
223 |
|
} |
224 |
|
|