Skip to content

Commit

Permalink
only render when in extent
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Sep 24, 2018
1 parent 11645ac commit 58116a2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/core/mesh/qgsmeshlayerinterpolator.cpp
Expand Up @@ -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];
Expand Down
7 changes: 6 additions & 1 deletion src/core/mesh/qgsmeshlayerrenderer.cpp
Expand Up @@ -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 )
{
Expand All @@ -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 );
}
Expand Down
17 changes: 13 additions & 4 deletions src/core/mesh/qgsmeshvectorrenderer.cpp
Expand Up @@ -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];
Expand All @@ -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 ) )
Expand All @@ -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];
Expand Down

0 comments on commit 58116a2

Please sign in to comment.