QGIS API Documentation 3.99.0-Master (a8f284845db)
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
22#include "qgis_core.h"
23#include "qgsmaptopixel.h"
24#include "qgsmeshdataprovider.h"
26#include "qgsrectangle.h"
27
28#include <QSize>
29#include <QVector>
30
31#define SIP_NO_FILE
32
34
40class QgsMeshLayer;
41
49class CORE_EXPORT QgsMeshLayerUtils
50{
51 public:
52
61 static int datasetValuesCount( const QgsMesh *mesh, QgsMeshDatasetGroupMetadata::DataType dataType );
62
70
80 static QgsMeshDataBlock datasetValues(
81 const QgsMeshLayer *meshLayer,
83 int valueIndex,
84 int count );
85
99 static QVector<QgsVector> griddedVectorValues(
100 const QgsMeshLayer *meshLayer,
101 const QgsMeshDatasetIndex index,
102 double xSpacing,
103 double ySpacing,
104 const QSize &size,
105 const QgsPointXY &minCorner );
106
112 static QVector<double> calculateMagnitudes( const QgsMeshDataBlock &block );
113
124 static void boundingBoxToScreenRectangle(
125 const QgsMapToPixel &mtp,
126 const QSize &outputSize,
127 const QgsRectangle &bbox,
128 int &leftLim,
129 int &rightLim,
130 int &bottomLim,
131 int &topLim,
132 double devicePixelRatio = 1.0 );
133
139 static QgsRectangle boundingBoxToScreenRectangle(
140 const QgsMapToPixel &mtp,
141 const QgsRectangle &bbox,
142 double devicePixelRatio = 1.0
143 );
144
153 static bool calculateBarycentricCoordinates(
154 const QgsPointXY &pA,
155 const QgsPointXY &pB,
156 const QgsPointXY &pC,
157 const QgsPointXY &pP,
158 double &lam1,
159 double &lam2,
160 double &lam3
161 );
162
169 static double interpolateFromVerticesData(
170 double fraction,
171 double val1, double val2
172 );
173
180 static QgsMeshDatasetValue interpolateFromVerticesData( double fraction,
181 const QgsMeshDatasetValue &val1, const QgsMeshDatasetValue &val2
182 );
183
195 static double interpolateFromVerticesData(
196 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
197 double val1, double val2, double val3, const QgsPointXY &pt
198 );
199
207 static double interpolateZForPoint( const QgsTriangularMesh &mesh, double x, double y );
208
222 static QgsVector interpolateVectorFromVerticesData(
223 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
224 QgsVector vect1, QgsVector vect2, QgsVector vect3, const QgsPointXY &pt
225 );
226
236 static double interpolateFromFacesData(
237 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
238 double val, const QgsPointXY &pt );
239
251 static QgsVector interpolateVectorFromFacesData(
252 const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
253 QgsVector vect, const QgsPointXY &pt );
254
260 static QVector<double> interpolateFromFacesData(
261 QVector<double> valuesOnFaces,
262 const QgsMesh *nativeMesh,
263 const QgsTriangularMesh *triangularMesh,
264 QgsMeshDataBlock *active,
266 );
267
273 static QVector<double> interpolateFromFacesData(
274 const QVector<double> &valuesOnFaces,
275 const QgsMesh &nativeMesh,
276 QgsMeshDataBlock *active,
278 );
279
285 static QVector<double> interpolateFromFacesData(
286 const QVector<double> &valuesOnFaces,
287 const QgsMesh &nativeMesh,
288 const QgsMeshDataBlock &active,
290 );
291
297 static QVector<double> resampleFromVerticesToFaces(
298 const QVector<double> valuesOnVertices,
299 const QgsMesh *nativeMesh,
300 const QgsTriangularMesh *triangularMesh,
301 const QgsMeshDataBlock *active,
303 );
304
315 static QVector<double> calculateMagnitudeOnVertices(
316 const QgsMeshLayer *meshLayer,
317 const QgsMeshDatasetIndex index,
318 QgsMeshDataBlock *activeFaceFlagValues,
320
333 static QVector<double> calculateMagnitudeOnVertices(
334 const QgsMesh &nativeMesh,
335 const QgsMeshDatasetGroupMetadata &groupMetadata,
336 const QgsMeshDataBlock &datasetValues,
337 const QgsMeshDataBlock &activeFaceFlagValues,
339
340
341
349 static QgsRectangle triangleBoundingBox( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 );
350
359 static QString formatTime( double hours, const QDateTime &referenceTime, const QgsMeshTimeSettings &settings );
360
369 static QVector<QVector3D> calculateNormals(
370 const QgsTriangularMesh &triangularMesh,
371 const QVector<double> &verticalMagnitude,
372 bool isRelative );
373
379 static bool haveSameParentQuantity( const QgsMeshLayer *layer, const QgsMeshDatasetIndex &index1, const QgsMeshDatasetIndex &index2 );
380
381};
382
384
385#endif // QGSMESHLAYERUTILS_H
Perform transforms between map coordinates and device coordinates.
Abstract class for interpolating 3d stacked mesh data to 2d data.
A block of integers/doubles from a mesh dataset.
A collection of dataset group metadata such as whether the data is vector or scalar,...
DataType
Location of where data is specified for datasets in the dataset group.
An index that identifies the dataset group (e.g.
Represents a single mesh 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.
Represents a 2D point.
Definition qgspointxy.h:62
A rectangle specified with double values.
A triangular/derived mesh with vertices in map coordinates.
Represent a 2-dimensional vector.
Definition qgsvector.h:34
Mesh - vertices, edges and faces.