QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
qgsmeshlayerutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmeshlayerutils.h
3 --------------------------
4 begin : August 2018
5 copyright : (C) 2018 by Martin Dobias
6 email : wonder dot sk at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSMESHLAYERUTILS_H
19#define QGSMESHLAYERUTILS_H
20
21#define SIP_NO_FILE
22
23#include "qgis_core.h"
24#include "qgsrectangle.h"
25#include "qgsmaptopixel.h"
26#include "qgsmeshdataprovider.h"
28
29#include <QVector>
30#include <QSize>
31
33
39class QgsMeshLayer;
40
48class CORE_EXPORT QgsMeshLayerUtils
49{
50 public:
51
60 static int datasetValuesCount( const QgsMesh *mesh, QgsMeshDatasetGroupMetadata::DataType dataType );
61
69
79 static QgsMeshDataBlock datasetValues(
80 const QgsMeshLayer *meshLayer,
82 int valueIndex,
83 int count );
84
98 static QVector<QgsVector> griddedVectorValues(
99 const QgsMeshLayer *meshLayer,
100 const QgsMeshDatasetIndex index,
101 double xSpacing,
102 double ySpacing,
103 const QSize &size,
104 const QgsPointXY &minCorner );
105
111 static QVector<double> calculateMagnitudes( const QgsMeshDataBlock &block );
112
123 static void boundingBoxToScreenRectangle(
124 const QgsMapToPixel &mtp,
125 const QSize &outputSize,
126 const QgsRectangle &bbox,
127 int &leftLim,
128 int &rightLim,
129 int &bottomLim,
130 int &topLim,
131 double devicePixelRatio = 1.0 );
132
138 static QgsRectangle boundingBoxToScreenRectangle(
139 const QgsMapToPixel &mtp,
140 const QgsRectangle &bbox,
141 double devicePixelRatio = 1.0
142 );
143
152 static bool calculateBarycentricCoordinates(
153 const QgsPointXY &pA,
154 const QgsPointXY &pB,
155 const QgsPointXY &pC,
156 const QgsPointXY &pP,
157 double &lam1,
158 double &lam2,
159 double &lam3
160 );
161
168 static double interpolateFromVerticesData(
169 double fraction,
170 double val1, double val2
171 );
172
179 static QgsMeshDatasetValue interpolateFromVerticesData( double fraction,
180 const QgsMeshDatasetValue &val1, const QgsMeshDatasetValue &val2
181 );
182
194 static double interpolateFromVerticesData(
195 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
196 double val1, double val2, double val3, const QgsPointXY &pt
197 );
198
206 static double interpolateZForPoint( const QgsTriangularMesh &mesh, double x, double y );
207
221 static QgsVector interpolateVectorFromVerticesData(
222 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
223 QgsVector vect1, QgsVector vect2, QgsVector vect3, const QgsPointXY &pt
224 );
225
235 static double interpolateFromFacesData(
236 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
237 double val, const QgsPointXY &pt );
238
250 static QgsVector interpolateVectorFromFacesData(
251 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
252 QgsVector vect, const QgsPointXY &pt );
253
259 static QVector<double> interpolateFromFacesData(
260 QVector<double> valuesOnFaces,
261 const QgsMesh *nativeMesh,
262 const QgsTriangularMesh *triangularMesh,
263 QgsMeshDataBlock *active,
265 );
266
272 static QVector<double> interpolateFromFacesData(
273 const QVector<double> &valuesOnFaces,
274 const QgsMesh &nativeMesh,
275 QgsMeshDataBlock *active,
277 );
278
284 static QVector<double> interpolateFromFacesData(
285 const QVector<double> &valuesOnFaces,
286 const QgsMesh &nativeMesh,
287 const QgsMeshDataBlock &active,
289 );
290
296 static QVector<double> resampleFromVerticesToFaces(
297 const QVector<double> valuesOnVertices,
298 const QgsMesh *nativeMesh,
299 const QgsTriangularMesh *triangularMesh,
300 const QgsMeshDataBlock *active,
302 );
303
314 static QVector<double> calculateMagnitudeOnVertices(
315 const QgsMeshLayer *meshLayer,
316 const QgsMeshDatasetIndex index,
317 QgsMeshDataBlock *activeFaceFlagValues,
319
332 static QVector<double> calculateMagnitudeOnVertices(
333 const QgsMesh &nativeMesh,
334 const QgsMeshDatasetGroupMetadata &groupMetadata,
335 const QgsMeshDataBlock &datasetValues,
336 const QgsMeshDataBlock &activeFaceFlagValues,
338
339
340
348 static QgsRectangle triangleBoundingBox( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 );
349
358 static QString formatTime( double hours, const QDateTime &referenceTime, const QgsMeshTimeSettings &settings );
359
368 static QVector<QVector3D> calculateNormals(
369 const QgsTriangularMesh &triangularMesh,
370 const QVector<double> &verticalMagnitude,
371 bool isRelative );
372
378 static bool haveSameParentQuantity( const QgsMeshLayer *layer, const QgsMeshDatasetIndex &index1, const QgsMeshDatasetIndex &index2 );
379
380};
381
383
384#endif // QGSMESHLAYERUTILS_H
Perform transforms between map coordinates and device coordinates.
Abstract class to interpolate 3d stacked mesh data to 2d data.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
DataType
Location of where data is specified for datasets in the dataset group.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
QgsMeshDatasetValue represents single dataset value.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
DataResamplingMethod
Resampling of value from dataset.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
Represents a mesh time settings for mesh datasets.
A class to represent a 2D point.
Definition qgspointxy.h:60
A rectangle specified with double values.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
A class to represent a vector.
Definition qgsvector.h:30
Mesh - vertices, edges and faces.