--- ray/src/rt/RpictSimulManager.cpp 2024/08/23 02:08:28 2.8 +++ ray/src/rt/RpictSimulManager.cpp 2024/08/27 18:50:01 2.11 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: RpictSimulManager.cpp,v 2.8 2024/08/23 02:08:28 greg Exp $"; +static const char RCSid[] = "$Id: RpictSimulManager.cpp,v 2.11 2024/08/27 18:50:01 greg Exp $"; #endif /* * RpictSimulManager.cpp @@ -9,6 +9,8 @@ static const char RCSid[] = "$Id: RpictSimulManager.cp * Created by Greg Ward on 07/11/2024. */ +#define DEBUG 1 // XXX temporary! + #include #include "platform.h" #include "RpictSimulManager.h" @@ -196,6 +198,8 @@ RpictSimulManager::SetTile(const int ti[2]) bool RpictSimulManager::ComputePixel(int x, int y) { + DCHECK(doneMap.OffBitMap(x,y), + CONSISTENCY, "illegal pixel index in ComputPixel()"); int i; FVECT rodir[2]; double hpos = (x+pixjitter())/TWidth(); @@ -232,31 +236,37 @@ RpictSimulManager::ComputePixel(int x, int y) // Check if neighbor differences are below pixel sampling threshold bool -RpictSimulManager::BelowSampThresh(int x, int y, const int noff[4][2]) const +RpictSimulManager::BelowSampThresh(const int x, const int y, const int noff[4][2]) const { SCOLOR pval[4]; float dist[4]; int i, j; for (i = 4; i--; ) { // get pixels from tile store - int px = x + noff[i][0]; - int py = y + noff[i][1]; + const int px = x + noff[i][0]; + const int py = y + noff[i][1]; if (!doneMap.Check(px, py) || !pacc.GetPixel(px, py, pval[i], &dist[i])) return false; } - const bool spectr = (pacc.NC() > 3); - for (i = 4; --i; ) // do pairwise comparisons - for (j = i; j--; ) { - if (pacc.DepthType() && - (dist[i] - dist[j] > maxdiff*dist[j]) | + // do pairwise comparisons + for (i = (pacc.DepthType() != RDTnone)*4; --i > 0; ) + for (j = i; j--; ) + if ((dist[i] - dist[j] > maxdiff*dist[j]) | (dist[j] - dist[i] > maxdiff*dist[i])) return false; - if (spectr ? sbigsdiff(pval[i], pval[j], maxdiff) : - bigdiff(pval[i], pval[j], maxdiff)) + if (pacc.NC() > 3) { + for (i = 4; --i; ) + for (j = i; j--; ) + if (sbigsdiff(pval[i], pval[j], maxdiff)) return false; - } - return true; // linear interpolation OK + } else { + for (i = 4; --i; ) + for (j = i; j--; ) + if (bigdiff(pval[i], pval[j], maxdiff)) + return false; + } + return true; } // Fill an interior square patch with interpolated values @@ -267,9 +277,11 @@ RpictSimulManager::FillSquare(const int x, const int y float dist[4]; int i, j; // assumes 4 corners are valid! - for (i = 4; i--; ) + for (i = 4; i--; ) { + DCHECK(!doneMap.Check(x+noff[i][0], y+noff[i][1]), + CONSISTENCY, "inclusion of bad pixel in FillSquare()"); pacc.GetPixel(x+noff[i][0], y+noff[i][1], pval[i], &dist[i]); - + } i = abs(noff[1][0]-noff[0][0]); j = abs(noff[1][1]-noff[0][1]); // i==j for diamond fill const int slen = (i > j) ? i : j; @@ -378,7 +390,7 @@ RpictSimulManager::RenderRect(const int x0, const int SetQuincunx(&sampMap, noff, 1< 1) ? int(4*psample+.99) : 8; + const int bheight = (psample > 1) ? int(8*psample+.99) : 16; const int vstep = bheight >> (psample > 1); NewBar(bheight); // render frame if we can @@ -1177,7 +1171,7 @@ RpictSimulManager::ResumeFrame(const char *pfname, con fclose(pdfp[0]); fclose(pdfp[1]); return RDTnone; } - int bheight = (psample > 1) ? int(4*psample+.99) : 8; + int bheight = (psample > 1) ? int(8*psample+.99) : 16; if (bheight > GetHeight()-doneScans) bheight = GetHeight()-doneScans; int vstep = bheight >> (psample > 1);