Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Slightly faster preparation of vectors of points
  • Loading branch information
wonder-sk committed Dec 28, 2012
1 parent 46f1109 commit 578dc2a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/core/symbology-ng/qgsrendererv2.cpp
Expand Up @@ -88,7 +88,8 @@ unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderCo
{
pts.resize( nPoints );

for ( unsigned int i = 0; i < nPoints; ++i )
QPointF* ptr = pts.data();
for ( unsigned int i = 0; i < nPoints; ++i, ++ptr )
{
x = *(( double * ) wkb );
wkb += sizeof( double );
Expand All @@ -98,19 +99,20 @@ unsigned char* QgsFeatureRendererV2::_getLineString( QPolygonF& pts, QgsRenderCo
if ( hasZValue ) // ignore Z value
wkb += sizeof( double );

pts[i] = QPointF( x, y );
*ptr = QPointF( x, y );
}
}

//transform the QPolygonF to screen coordinates
for ( int i = 0; i < pts.size(); ++i )
QPointF* ptr = pts.data();
for ( int i = 0; i < pts.size(); ++i, ++ptr )
{
if ( ct )
{
z = 0;
ct->transformInPlace( pts[i].rx(), pts[i].ry(), z );
ct->transformInPlace( ptr->rx(), ptr->ry(), z );
}
mtp.transformInPlace( pts[i].rx(), pts[i].ry() );
mtp.transformInPlace( ptr->rx(), ptr->ry() );
}


Expand Down Expand Up @@ -151,12 +153,13 @@ unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygon
QPolygonF poly( nPoints );

// Extract the points from the WKB and store in a pair of vectors.
for ( unsigned int jdx = 0; jdx < nPoints; jdx++ )
QPointF* ptr = poly.data();
for ( unsigned int jdx = 0; jdx < nPoints; ++jdx, ++ptr )
{
x = *(( double * ) wkb ); wkb += sizeof( double );
y = *(( double * ) wkb ); wkb += sizeof( double );

poly[jdx] = QPointF( x, y );
*ptr = QPointF( x, y );

if ( hasZValue )
wkb += sizeof( double );
Expand All @@ -169,14 +172,15 @@ unsigned char* QgsFeatureRendererV2::_getPolygon( QPolygonF& pts, QList<QPolygon
QgsClipper::trimPolygon( poly, clipRect );

//transform the QPolygonF to screen coordinates
for ( int i = 0; i < poly.size(); ++i )
ptr = poly.data();
for ( int i = 0; i < poly.size(); ++i, ++ptr )
{
if ( ct )
{
z = 0;
ct->transformInPlace( poly[i].rx(), poly[i].ry(), z );
ct->transformInPlace( ptr->rx(), ptr->ry(), z );
}
mtp.transformInPlace( poly[i].rx(), poly[i].ry() );
mtp.transformInPlace( ptr->rx(), ptr->ry() );
}

if ( idx == 0 )
Expand Down

0 comments on commit 578dc2a

Please sign in to comment.