QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
35 class QgsTriangularMesh;
36 class QgsMeshDataBlock;
39 class QgsMeshLayer;
40 
48 class 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,
81  QgsMeshDatasetIndex index,
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 
137  static QgsRectangle boundingBoxToScreenRectangle(
138  const QgsMapToPixel &mtp,
139  const QgsRectangle &bbox
140  );
141 
148  static double interpolateFromVerticesData(
149  double fraction,
150  double val1, double val2
151  );
152 
159  static QgsMeshDatasetValue interpolateFromVerticesData( double fraction,
160  const QgsMeshDatasetValue &val1, const QgsMeshDatasetValue &val2
161  );
162 
174  static double interpolateFromVerticesData(
175  const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
176  double val1, double val2, double val3, const QgsPointXY &pt
177  );
178 
186  static double interpolateZForPoint( const QgsTriangularMesh &mesh, double x, double y );
187 
201  static QgsVector interpolateVectorFromVerticesData(
202  const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
203  QgsVector vect1, QgsVector vect2, QgsVector vect3, const QgsPointXY &pt
204  );
205 
215  static double interpolateFromFacesData(
216  const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
217  double val, const QgsPointXY &pt );
218 
230  static QgsVector interpolateVectorFromFacesData(
231  const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3,
232  QgsVector vect, const QgsPointXY &pt );
233 
239  static QVector<double> interpolateFromFacesData(
240  QVector<double> valuesOnFaces,
241  const QgsMesh *nativeMesh,
242  const QgsTriangularMesh *triangularMesh,
243  QgsMeshDataBlock *active,
245  );
246 
252  static QVector<double> interpolateFromFacesData(
253  const QVector<double> &valuesOnFaces,
254  const QgsMesh &nativeMesh,
255  QgsMeshDataBlock *active,
257  );
258 
264  static QVector<double> interpolateFromFacesData(
265  const QVector<double> &valuesOnFaces,
266  const QgsMesh &nativeMesh,
267  const QgsMeshDataBlock &active,
269  );
270 
276  static QVector<double> resampleFromVerticesToFaces(
277  const QVector<double> valuesOnVertices,
278  const QgsMesh *nativeMesh,
279  const QgsTriangularMesh *triangularMesh,
280  const QgsMeshDataBlock *active,
282  );
283 
294  static QVector<double> calculateMagnitudeOnVertices(
295  const QgsMeshLayer *meshLayer,
296  const QgsMeshDatasetIndex index,
297  QgsMeshDataBlock *activeFaceFlagValues,
299 
312  static QVector<double> calculateMagnitudeOnVertices(
313  const QgsMesh &nativeMesh,
314  const QgsMeshDatasetGroupMetadata &groupMetadata,
315  const QgsMeshDataBlock &datasetValues,
316  const QgsMeshDataBlock &activeFaceFlagValues,
318 
319 
320 
328  static QgsRectangle triangleBoundingBox( const QgsPointXY &p1, const QgsPointXY &p2, const QgsPointXY &p3 );
329 
338  static QString formatTime( double hours, const QDateTime &referenceTime, const QgsMeshTimeSettings &settings );
339 
348  static QVector<QVector3D> calculateNormals(
349  const QgsTriangularMesh &triangularMesh,
350  const QVector<double> &verticalMagnitude,
351  bool isRelative );
352 };
353 
355 
356 #endif // QGSMESHLAYERUTILS_H
QgsMeshTimeSettings
Represents a mesh time settings for mesh datasets.
Definition: qgsmeshtimesettings.h:35
qgsrectangle.h
qgsmaptopixel.h
QgsMeshDatasetValue
QgsMeshDatasetValue represents single dataset value.
Definition: qgsmeshdataset.h:79
QgsMesh
Mesh - vertices, edges and faces.
Definition: qgsmeshdataprovider.h:58
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsMeshRendererScalarSettings::NeighbourAverage
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
Definition: qgsmeshrenderersettings.h:116
QgsMeshDatasetIndex
QgsMeshDatasetIndex is index that identifies the dataset group (e.g. wind speed) and a dataset in thi...
Definition: qgsmeshdataset.h:48
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:98
QgsMeshRendererScalarSettings::DataResamplingMethod
DataResamplingMethod
Resampling of value from dataset.
Definition: qgsmeshrenderersettings.h:105
QgsMesh3dAveragingMethod
Abstract class to interpolate 3d stacked mesh data to 2d data.
Definition: qgsmesh3daveraging.h:39
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
qgsmeshrenderersettings.h
QgsMeshDatasetGroupMetadata
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
Definition: qgsmeshdataset.h:351
QgsMapToPixel
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:38
QgsMeshDatasetGroupMetadata::DataType
DataType
Location of where data is specified for datasets in the dataset group.
Definition: qgsmeshdataset.h:356
QgsVector
A class to represent a vector. Currently no Z axis / 2.5D support is implemented.
Definition: qgsvector.h:29
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:137
QgsTriangularMesh
Triangular/Derived Mesh is mesh with vertices in map coordinates.
Definition: qgstriangularmesh.h:51
qgsmeshdataprovider.h