1
1
/******************************************************************************
2
* $Id: llrasterize.cpp 18340 2009-12-19 04:41:45Z chaitanya $
2
* $Id: llrasterize.cpp 22998 2011-08-28 12:23:29Z rouault $
5
5
* Purpose: Vector polygon rasterization code.
195
195
dx2 = padfX[ind1];
196
196
dx1 = padfX[ind2];
197
197
} else /* if (fabs(dy1-dy2)< 1.e-6) */
200
200
/*AE: DO NOT skip bottom horizontal segments
201
-Fill them separately-
202
They are not taken into account twice.*/
203
if (padfX[ind1] > padfX[ind2])
205
horizontal_x1 = (int) floor(padfX[ind2]+0.5);
206
horizontal_x2 = (int) floor(padfX[ind1]+0.5);
201
-Fill them separately-
202
They are not taken into account twice.*/
203
if (padfX[ind1] > padfX[ind2])
205
horizontal_x1 = (int) floor(padfX[ind2]+0.5);
206
horizontal_x2 = (int) floor(padfX[ind1]+0.5);
208
208
if ( (horizontal_x1 > maxx) || (horizontal_x2 <= minx) )
211
/*fill the horizontal segment (separately from the rest)*/
212
pfnScanlineFunc( pCBData, y, horizontal_x1, horizontal_x2 - 1, (dfVariant == NULL)?0:dfVariant[0] );
215
else /*skip top horizontal segments (they are already filled in the regular loop)*/
211
/*fill the horizontal segment (separately from the rest)*/
212
pfnScanlineFunc( pCBData, y, horizontal_x1, horizontal_x2 - 1, (dfVariant == NULL)?0:dfVariant[0] );
215
else /*skip top horizontal segments (they are already filled in the regular loop)*/
220
220
if(( dy < dy2 ) && (dy >= dy1))
223
223
intersect = (dy-dy1) * (dx2-dx1) / (dy2-dy1) + dx1;
225
polyInts[ints++] = (int) floor(intersect+0.5);
225
polyInts[ints++] = (int) floor(intersect+0.5);
230
230
* It would be more efficient to do this inline, to avoid
231
231
* a function call for each comparison.
232
* NOTE - mloskot: make llCompareInt a functor and use std
233
* algorithm and it will be optimized and expanded
234
* automatically in compile-time, with modularity preserved.
232
* NOTE - mloskot: make llCompareInt a functor and use std
233
* algorithm and it will be optimized and expanded
234
* automatically in compile-time, with modularity preserved.
236
236
qsort(polyInts, ints, sizeof(int), llCompareInt);
262
262
for ( i = 0; i < nPartCount; i++ )
264
int nX = (int)floor( padfX[i] + 0.5 );
265
int nY = (int)floor( padfY[i] + 0.5 );
264
int nX = (int)floor( padfX[i] );
265
int nY = (int)floor( padfY[i] );
266
266
double dfVariant = 0;
267
267
if( padfVariant != NULL )
268
268
dfVariant = padfVariant[i];
293
293
for ( j = 1; j < panPartSize[i]; j++ )
295
int iX = (int)floor( padfX[n + j - 1] + 0.5 );
296
int iY = (int)floor( padfY[n + j - 1] + 0.5 );
295
int iX = (int)floor( padfX[n + j - 1] );
296
int iY = (int)floor( padfY[n + j - 1] );
298
const int iX1 = (int)floor( padfX[n + j] + 0.5 );
299
const int iY1 = (int)floor( padfY[n + j] + 0.5 );
298
const int iX1 = (int)floor( padfX[n + j] );
299
const int iY1 = (int)floor( padfY[n + j] );
301
301
double dfVariant = 0, dfVariant1 = 0;
302
302
if( padfVariant != NULL &&
320
320
const int nXError = nDeltaY << 1;
321
321
const int nYError = nXError - (nDeltaX << 1);
322
322
int nError = nXError - nDeltaX;
323
double dfDeltaVariant = (dfVariant1 - dfVariant) /
323
/* == 0 makes clang -fcatch-undefined-behavior -ftrapv happy, but if */
324
/* it is == 0, dfDeltaVariant is not really used, so any value is OK */
325
double dfDeltaVariant = (nDeltaX == 0) ? 0 : (dfVariant1 - dfVariant) /
326
328
while ( nDeltaX-- >= 0 )
345
347
const int nXError = nDeltaX << 1;
346
348
const int nYError = nXError - (nDeltaY << 1);
347
349
int nError = nXError - nDeltaY;
348
double dfDeltaVariant = (dfVariant1 - dfVariant) /
350
/* == 0 makes clang -fcatch-undefined-behavior -ftrapv happy, but if */
351
/* it is == 0, dfDeltaVariant is not really used, so any value is OK */
352
double dfDeltaVariant = (nDeltaY == 0) ? 0 : (dfVariant1 - dfVariant) /
351
355
while ( nDeltaY-- >= 0 )