32 const QVector<double> &datasetValues,
const QVector<bool> &activeFaceFlagValues,
33 bool dataIsOnVertices,
36 : mTriangularMesh( m ),
37 mDatasetValues( datasetValues ),
38 mActiveFaceFlagValues( activeFaceFlagValues ),
40 mDataOnVertices( dataIsOnVertices ),
45 QgsMeshLayerInterpolator::~QgsMeshLayerInterpolator() =
default;
58 int QgsMeshLayerInterpolator::bandCount()
const 66 outputBlock->setIsNoData();
67 double *data =
reinterpret_cast<double *
>( outputBlock->bits() );
69 const QVector<QgsMeshFace> &triangles = mTriangularMesh.triangles();
70 const QVector<QgsMeshVertex> &vertices = mTriangularMesh.vertices();
73 if ( mDataOnVertices )
74 Q_ASSERT( mDatasetValues.count() == mTriangularMesh.vertices().count() );
76 for (
int i = 0; i < triangles.size(); ++i )
81 if ( mContext.renderingStopped() )
86 const int v1 = face[0], v2 = face[1], v3 = face[2];
87 const QgsPoint p1 = vertices[v1], p2 = vertices[v2], p3 = vertices[v3];
89 const int nativeFaceIndex = mTriangularMesh.trianglesToNativeFaces()[i];
90 const bool isActive = mActiveFaceFlagValues[nativeFaceIndex];
94 QgsRectangle bbox = QgsMeshLayerUtils::triangleBoundingBox( p1, p2, p3 );
99 int topLim, bottomLim, leftLim, rightLim;
100 QgsMeshLayerUtils::boundingBoxToScreenRectangle( mContext.mapToPixel(), mOutputSize, bbox, leftLim, rightLim, topLim, bottomLim );
103 for (
int j = topLim; j <= bottomLim; j++ )
105 double *line = data + ( j * width );
106 for (
int k = leftLim; k <= rightLim; k++ )
109 const QgsPointXY p = mContext.mapToPixel().toMapCoordinates( k, j );
110 if ( mDataOnVertices )
111 val = QgsMeshLayerUtils::interpolateFromVerticesData(
121 int face = mTriangularMesh.trianglesToNativeFaces()[i];
122 val = QgsMeshLayerUtils::interpolateFromFacesData(
126 mDatasetValues[face],
131 if ( !std::isnan( val ) )
134 outputBlock->setIsData( j, k );
141 return outputBlock.release();;
bool isCanceled() const
Tells whether the operation has been canceled already.
bool intersects(const QgsRectangle &rect) const
Returns true when rectangle intersects with other rectangle.
A rectangle specified with double values.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
A class to represent a 2D point.
DataType
Raster data types.
Sixty four bit floating point (double)
QgsRectangle extent() const override
Returns the extent of the layer.
Base class for processing filters like renderers, reprojector, resampler etc.
Point geometry type, with support for z-dimension and m-values.
Contains information about the context of a rendering operation.
QVector< int > QgsMeshFace
List of vertex indexes.
Feedback object tailored for raster block reading.