QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsmesh3daveraging.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmesh3daveraging.h
3 ---------------------
4 begin : November 2019
5 copyright : (C) 2019 by Peter Petrik
6 email : zilolv 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 QGSMESH3DAVERAGING_H
19#define QGSMESH3DAVERAGING_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23
24#include <QDomElement>
25
26class QgsMeshLayer;
30class QgsFeedback;
31class QgsMeshRenderer3dAveragingSettings;
32
40{
41
42#ifdef SIP_RUN
44 QgsMesh3dAveragingMethod *averagingMethod = dynamic_cast<QgsMesh3dAveragingMethod *>( sipCpp );
45
46 sipType = 0;
47
48 if ( averagingMethod )
49 {
50 switch ( averagingMethod->method() )
51 {
53 sipType = sipType_QgsMeshMultiLevelsAveragingMethod;
54 break;
56 sipType = sipType_QgsMeshSigmaAveragingMethod;
57 break;
59 sipType = sipType_QgsMeshRelativeHeightAveragingMethod;
60 break;
62 sipType = sipType_QgsMeshElevationAveragingMethod;
63 break;
64 default:
65 sipType = nullptr;
66 break;
67 }
68 }
70#endif
71
72 public:
74 enum Method
75 {
77 MultiLevelsAveragingMethod = 0,
83 ElevationAveragingMethod
84 };
85
87 QgsMesh3dAveragingMethod( Method method );
88
90 virtual ~QgsMesh3dAveragingMethod() = default;
91
93 QgsMeshDataBlock calculate( const QgsMesh3dDataBlock &block3d, QgsFeedback *feedback = nullptr ) const;
94
98 virtual QDomElement writeXml( QDomDocument &doc ) const = 0;
99
101 static QgsMesh3dAveragingMethod *createFromXml( const QDomElement &elem ) SIP_FACTORY;
102
104 virtual void readXml( const QDomElement &elem ) = 0;
105
107 static bool equals( const QgsMesh3dAveragingMethod *a, const QgsMesh3dAveragingMethod *b );
108
110 virtual bool equals( const QgsMesh3dAveragingMethod *other ) const = 0;
111
114
116 Method method() const;
117
118 private:
120 virtual bool hasValidInputs() const = 0;
121
125 void averageVolumeValuesForFace(
126 int faceIndex,
127 int volumesBelowFaceCount,
128 int startVolumeIndex,
129 double methodLevelTop,
130 double methodLevelBottom,
131 bool isVector,
132 const QVector<double> &verticalLevelsForFace,
133 const QVector<double> &volumeValues,
134 QVector<double> &valuesFaces
135 ) const;
136
140 virtual void volumeRangeForFace(
141 double &startVerticalLevel,
142 double &endVerticalLevel,
143 int &singleVerticalLevel,
144 const QVector<double> &verticalLevels ) const = 0;
145
146 Method mMethod;
147};
148
160{
161 public:
164
172 QgsMeshMultiLevelsAveragingMethod( int startLevel, int endLevel, bool countedFromTop );
173
180 QgsMeshMultiLevelsAveragingMethod( int verticalLevel, bool countedFromTop );
181
183 QDomElement writeXml( QDomDocument &doc ) const override;
184 void readXml( const QDomElement &elem ) override;
185 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
186 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
187
196 int startVerticalLevel() const;
197
206 int endVerticalLevel() const;
207
211 bool countedFromTop() const;
212
216 bool isSingleLevel() const;
217
218 private:
219 bool hasValidInputs() const override;
220 void volumeRangeForFace( double &startVerticalLevel,
221 double &endVerticalLevel,
222 int &singleVerticalIndex,
223 const QVector<double> &verticalLevels ) const override;
224 void setLevels( int startVerticalLevel, int endVerticalLevel );
225 int mStartVerticalLevel = 1;
226 int mEndVerticalLevel = 1;
227 bool mCountedFromTop = true;
228};
229
241{
242 public:
245
251 QgsMeshSigmaAveragingMethod( double startFraction, double endFraction );
252
254 QDomElement writeXml( QDomDocument &doc ) const override;
255 void readXml( const QDomElement &elem ) override;
256 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
257 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
258
265 double startFraction() const;
266
273 double endFraction() const;
274
275 private:
276 bool hasValidInputs() const override;
277 void volumeRangeForFace( double &startVerticalLevel,
278 double &endVerticalLevel,
279 int &singleVerticalIndex,
280 const QVector<double> &verticalLevels ) const override;
281
282 double mStartFraction = 0;
283 double mEndFraction = 1;
284};
285
303{
304 public:
305
308
316 QgsMeshRelativeHeightAveragingMethod( double startHeight, double endHeight, bool countedFromTop );
317
319 QDomElement writeXml( QDomDocument &doc ) const override;
320 void readXml( const QDomElement &elem ) override;
321 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
322 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
323
329 double startHeight() const;
330
336 double endHeight() const;
337
341 bool countedFromTop() const;
342
343 private:
344 bool hasValidInputs() const override;
345 void volumeRangeForFace( double &startVerticalLevel,
346 double &endVerticalLevel,
347 int &singleVerticalIndex,
348 const QVector<double> &verticalLevels ) const override;
349 double mStartHeight = 0;
350 double mEndHeight = 0;
351 bool mCountedFromTop = true;
352};
353
366{
367 public:
368
371
377 QgsMeshElevationAveragingMethod( double startElevation, double endElevation );
379
380 QDomElement writeXml( QDomDocument &doc ) const override;
381 void readXml( const QDomElement &elem ) override;
382 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
383 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
384
388 double startElevation() const;
389
393 double endElevation() const;
394
395 private:
396 bool hasValidInputs() const override;
397 void volumeRangeForFace( double &startVerticalLevel,
398 double &endVerticalLevel,
399 int &singleVerticalIndex,
400 const QVector<double> &verticalLevels ) const override;
401 double mStartElevation = 0;
402 double mEndElevation = 0;
403};
404
405#endif // QGSMESH3DAVERAGING_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
Abstract class to interpolate 3d stacked mesh data to 2d data.
virtual void readXml(const QDomElement &elem)=0
Reads configuration from the given DOM element.
virtual ~QgsMesh3dAveragingMethod()=default
Dtor.
virtual bool equals(const QgsMesh3dAveragingMethod *other) const =0
Returns whether method equals to other.
Method
Type of averaging method.
@ RelativeHeightAveragingMethod
Method to average values defined by range of relative length units to the surface or bed level.
@ MultiLevelsAveragingMethod
Method to average values from selected vertical layers.
@ ElevationAveragingMethod
Method to average values defined by range of absolute length units to the model's datum.
@ SigmaAveragingMethod
Method to average values between 0 (bed level) and 1 (surface)
virtual QgsMesh3dAveragingMethod * clone() const =0
Clone the instance.
virtual QDomElement writeXml(QDomDocument &doc) const =0
Writes configuration to a new DOM element.
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Elevation averaging method averages the values based on range defined absolute value to the model's d...
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:100
Multi level averaging method specifies limits of vertical layers from the top layer down or reversed.
Relative height averaging method averages the values based on range defined relative to bed elevation...
Sigma averages over the values between 0 (bed level) and 1 (surface).
~QgsMeshSigmaAveragingMethod() override
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
#define SIP_ABSTRACT
Definition: qgis_sip.h:208
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:203