~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to alg/llrasterize.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 $
3
3
 *
4
4
 * Project:  GDAL
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) */
198
 
            {
 
198
            {
199
199
                
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])
204
 
                {
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])
 
204
                {
 
205
                    horizontal_x1 = (int) floor(padfX[ind2]+0.5);
 
206
                    horizontal_x2 = (int) floor(padfX[ind1]+0.5);
207
207
                
208
208
                    if  ( (horizontal_x1 >  maxx) ||  (horizontal_x2 <= minx) )
209
209
                        continue;
210
210
 
211
 
                    /*fill the horizontal segment (separately from the rest)*/
212
 
                    pfnScanlineFunc( pCBData, y, horizontal_x1, horizontal_x2 - 1, (dfVariant == NULL)?0:dfVariant[0] );
213
 
                    continue;
214
 
                }
215
 
                else /*skip top horizontal segments (they are already filled in the regular loop)*/
216
 
                    continue;
 
211
                    /*fill the horizontal segment (separately from the rest)*/
 
212
                    pfnScanlineFunc( pCBData, y, horizontal_x1, horizontal_x2 - 1, (dfVariant == NULL)?0:dfVariant[0] );
 
213
                    continue;
 
214
                }
 
215
                else /*skip top horizontal segments (they are already filled in the regular loop)*/
 
216
                    continue;
217
217
 
218
 
            }
 
218
            }
219
219
 
220
220
            if(( dy < dy2 ) && (dy >= dy1))
221
221
            {
222
222
                
223
223
                intersect = (dy-dy1) * (dx2-dx1) / (dy2-dy1) + dx1;
224
224
 
225
 
                polyInts[ints++] = (int) floor(intersect+0.5);
226
 
            }
227
 
        }
 
225
                polyInts[ints++] = (int) floor(intersect+0.5);
 
226
            }
 
227
        }
228
228
 
229
229
        /* 
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.
235
235
         */
236
236
        qsort(polyInts, ints, sizeof(int), llCompareInt);
237
237
 
261
261
 
262
262
    for ( i = 0; i < nPartCount; i++ )
263
263
    {
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];
292
292
 
293
293
        for ( j = 1; j < panPartSize[i]; j++ )
294
294
        {
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] );
297
297
 
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] );
300
300
 
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) /
324
326
                                                           (double)nDeltaX;
325
327
 
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) /
349
353
                                                           (double)nDeltaY;
350
354
 
351
355
                while ( nDeltaY-- >= 0 )