| 9 |
|
* Created by Greg Ward on 07/11/2024. |
| 10 |
|
*/ |
| 11 |
|
|
| 12 |
+ |
#define DEBUG 1 // XXX temporary! |
| 13 |
+ |
|
| 14 |
|
#include <ctype.h> |
| 15 |
|
#include "platform.h" |
| 16 |
|
#include "RpictSimulManager.h" |
| 198 |
|
bool |
| 199 |
|
RpictSimulManager::ComputePixel(int x, int y) |
| 200 |
|
{ |
| 201 |
+ |
DCHECK(doneMap.OffBitMap(x,y), |
| 202 |
+ |
CONSISTENCY, "illegal pixel index in ComputPixel()"); |
| 203 |
|
int i; |
| 204 |
|
FVECT rodir[2]; |
| 205 |
|
double hpos = (x+pixjitter())/TWidth(); |
| 271 |
|
float dist[4]; |
| 272 |
|
int i, j; |
| 273 |
|
// assumes 4 corners are valid! |
| 274 |
< |
for (i = 4; i--; ) |
| 274 |
> |
for (i = 4; i--; ) { |
| 275 |
> |
DCHECK(!doneMap.Check(x+noff[i][0], y+noff[i][1]), |
| 276 |
> |
CONSISTENCY, "inclusion of bad pixel in FillSquare()"); |
| 277 |
|
pacc.GetPixel(x+noff[i][0], y+noff[i][1], pval[i], &dist[i]); |
| 278 |
< |
|
| 278 |
> |
} |
| 279 |
|
i = abs(noff[1][0]-noff[0][0]); |
| 280 |
|
j = abs(noff[1][1]-noff[0][1]); // i==j for diamond fill |
| 281 |
|
const int slen = (i > j) ? i : j; |
| 384 |
|
SetQuincunx(&sampMap, noff, 1<<sp2, layer&1, x0, y0); |
| 385 |
|
sampMap -= doneSamples; // avoid resampling pixels |
| 386 |
|
// Are we into adaptive sampling realm? |
| 387 |
< |
if (noff[0][0]*noff[0][0] + noff[0][1]*noff[0][1] < 4*psample*psample) { |
| 387 |
> |
if (noff[0][0]*noff[0][0] + noff[0][1]*noff[0][1] < psample*psample) { |
| 388 |
|
if (FlushQueue() < 0) // need results to check thresholds |
| 389 |
|
return false; |
| 390 |
|
ABitMap2 fillMap = sampMap; |
| 391 |
|
for (x = y = 0; sampMap.Find(&x, &y); x++) |
| 392 |
|
if (BelowSampThresh(x, y, noff)) |
| 393 |
|
sampMap.Reset(x, y); |
| 394 |
+ |
#if 0 |
| 395 |
+ |
XXX Need to fix directions for spreading!! |
| 396 |
|
// spread sampling to neighbors... |
| 397 |
|
const ABitMap2 origSampMap = sampMap; |
| 398 |
|
for (x = 4; x--; ) { |
| 401 |
|
sampMap |= stamp; |
| 402 |
|
} // ...but don't resample what's done |
| 403 |
|
sampMap -= doneSamples; |
| 404 |
+ |
#endif |
| 405 |
|
// interpolate smooth regions |
| 406 |
|
fillMap -= sampMap; |
| 407 |
|
for (x = y = 0; fillMap.Find(&x, &y); x++) |
| 570 |
|
sizeof(COLORV)*NC*TWidth()*(THeight()-v)); |
| 571 |
|
memmove(barDepth, barDepth + TWidth()*v, |
| 572 |
|
sizeof(float)*TWidth()*(THeight()-v)); |
| 573 |
< |
if (ytop < THeight()) { // mark what we won't do as finished |
| 573 |
> |
if (ytop < THeight()) // mark what we won't do as finished |
| 574 |
|
doneMap.ClearRect(0, 0, TWidth(), THeight()-ytop, true); |
| 566 |
– |
memset(barPix, 0, sizeof(COLORV)*NC*TWidth()*(THeight()-ytop)); |
| 567 |
– |
memset(barDepth, 0, sizeof(float)*TWidth()*(THeight()-ytop)); |
| 568 |
– |
} |
| 575 |
|
return true; |
| 576 |
|
} |
| 577 |
|
|
| 594 |
|
cropview(&ptvw, 0., double(ytop-THeight())/GetHeight(), |
| 595 |
|
1., double(ytop)/GetHeight())) |
| 596 |
|
ptvw.type = 0; |
| 597 |
< |
// set up spectral sampling |
| 597 |
> |
// update spectral sampling |
| 598 |
|
if (setspectrsamp(CNDX, WLPART) <= 0) { |
| 599 |
|
error(USER, "unsupported spectral sampling"); |
| 600 |
|
return false; |
| 681 |
|
{ |
| 682 |
|
pdfp[0] = pdfp[1] = NULL; |
| 683 |
|
if (!RDTcolorT(dt)) |
| 684 |
< |
error(INTERNAL, "botched color output type in NewOutput()"); |
| 684 |
> |
error(INTERNAL, "missing color output type in NewOutput()"); |
| 685 |
|
if (NCSAMP == 3) { |
| 686 |
|
if (RDTcolorT(dt) == RDTscolr) |
| 687 |
|
dt = RDTnewCT(dt, prims==xyzprims ? RDTxyze : RDTrgbe); |
| 703 |
|
sprintf(errmsg, "cannot open picture file '%s'", pfname); |
| 704 |
|
error(SYSTEM, errmsg); |
| 705 |
|
} |
| 706 |
< |
return RDTnone; // expected in parallel sequence |
| 706 |
> |
return RDTnone; // may be expected in sequence run |
| 707 |
|
} |
| 708 |
|
if (fd == 1) |
| 709 |
|
pdfp[0] = stdout; |
| 758 |
|
fputendian(pdfp[0]); |
| 759 |
|
fputformat("float", pdfp[0]); |
| 760 |
|
break; |
| 761 |
< |
default:; |
| 761 |
> |
default:; // pro forma - caught this above |
| 762 |
|
} |
| 763 |
< |
fputc('\n', pdfp[0]); // flush picture header + resolution |
| 763 |
> |
fputc('\n', pdfp[0]); // flush picture header |
| 764 |
|
if (fflush(pdfp[0]) == EOF) { |
| 765 |
|
sprintf(errmsg, "cannot write header to picture '%s'", pfname); |
| 766 |
|
error(SYSTEM, errmsg); |