Skip to content
Permalink
Browse files

only render when in extent

  • Loading branch information
PeterPetrik committed Sep 24, 2018
1 parent 11645ac commit 58116a222b89e916b114a8c71f968cbf12bdc6c2
@@ -78,6 +78,9 @@ QgsRasterBlock *QgsMeshLayerInterpolator::block( int, const QgsRectangle &extent
if ( feedback && feedback->isCanceled() )
break;

if ( mContext.renderingStopped() )
break;

const QgsMeshFace &face = triangles[i];

const int v1 = face[0], v2 = face[1], v3 = face[2];
@@ -240,6 +240,7 @@ void QgsMeshLayerRenderer::renderMesh( const std::unique_ptr<QgsSymbol> &symbol,
QgsFields fields;
QgsSingleSymbolRenderer renderer( symbol->clone() );
renderer.startRender( mContext, fields );
const QVector<QgsMeshVertex> &vertices = mTriangularMesh.vertices(); //Triangular mesh vertices contains also native mesh vertices

for ( int i = 0; i < faces.size(); ++i )
{
@@ -249,7 +250,11 @@ void QgsMeshLayerRenderer::renderMesh( const std::unique_ptr<QgsSymbol> &symbol,
const QgsMeshFace &face = faces[i];
QgsFeature feat;
feat.setFields( fields );
QgsGeometry geom = QgsMeshUtils::toGeometry( face, mTriangularMesh.vertices() ); //Triangular mesh vertices contains also native mesh vertices
QgsGeometry geom = QgsMeshUtils::toGeometry( face, vertices );
const QgsRectangle bbox = geom.boundingBox();
if ( !mContext.extent().intersects( bbox ) )
continue;

feat.setGeometry( geom );
renderer.renderFeature( feat, mContext );
}
@@ -199,9 +199,12 @@ void QgsMeshVectorRenderer::drawVectorDataOnVertices()

for ( int i = 0; i < vertices.size(); ++i )
{
if ( mContext.renderingStopped() )
break;

const QgsMeshVertex &vertex = vertices.at( i );
//if (!nodeInsideView(nodeIndex))
// continue;
if ( !mContext.extent().contains( vertex ) )
continue;

double xVal = mDatasetValuesX[i];
double yVal = mDatasetValuesY[i];
@@ -221,10 +224,13 @@ void QgsMeshVectorRenderer::drawVectorDataOnFaces()

for ( int i = 0; i < centroids.count(); i++ )
{
//if (elemOutsideView(elemIndex))
// continue;
if ( mContext.renderingStopped() )
break;

QgsPointXY center = centroids.at( i );
if ( !mContext.extent().contains( center ) )
continue;

double xVal = mDatasetValuesX[i];
double yVal = mDatasetValuesY[i];
if ( nodataValue( xVal, yVal ) )
@@ -247,6 +253,9 @@ void QgsMeshVectorRenderer::drawVectorDataOnGrid()

for ( int i = 0; i < triangles.size(); i++ )
{
if ( mContext.renderingStopped() )
break;

const QgsMeshFace &face = triangles[i];

const int v1 = face[0], v2 = face[1], v3 = face[2];

0 comments on commit 58116a2

Please sign in to comment.
You can’t perform that action at this time.