QGIS API Documentation 3.27.0-Master (f261cc1f8b)
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 const QVector<double> &verticalLevels ) const = 0;
144
145 Method mMethod;
146};
147
159{
160 public:
163
171 QgsMeshMultiLevelsAveragingMethod( int startLevel, int endLevel, bool countedFromTop );
172
179 QgsMeshMultiLevelsAveragingMethod( int verticalLevel, bool countedFromTop );
180
182 QDomElement writeXml( QDomDocument &doc ) const override;
183 void readXml( const QDomElement &elem ) override;
184 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
185 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
186
195 int startVerticalLevel() const;
196
205 int endVerticalLevel() const;
206
210 bool countedFromTop() const;
211
215 bool isSingleLevel() const;
216
217 private:
218 bool hasValidInputs() const override;
219 void volumeRangeForFace( double &startVerticalLevel,
220 double &endVerticalLevel,
221 const QVector<double> &verticalLevels ) const override;
222 void setLevels( int startVerticalLevel, int endVerticalLevel );
223 int mStartVerticalLevel = 1;
224 int mEndVerticalLevel = 1;
225 bool mCountedFromTop = true;
226};
227
239{
240 public:
243
249 QgsMeshSigmaAveragingMethod( double startFraction, double endFraction );
250
252 QDomElement writeXml( QDomDocument &doc ) const override;
253 void readXml( const QDomElement &elem ) override;
254 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
255 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
256
263 double startFraction() const;
264
271 double endFraction() const;
272
273 private:
274 bool hasValidInputs() const override;
275 void volumeRangeForFace( double &startVerticalLevel,
276 double &endVerticalLevel,
277 const QVector<double> &verticalLevels ) const override;
278
279 double mStartFraction = 0;
280 double mEndFraction = 1;
281};
282
300{
301 public:
302
305
313 QgsMeshRelativeHeightAveragingMethod( double startHeight, double endHeight, bool countedFromTop );
314
316 QDomElement writeXml( QDomDocument &doc ) const override;
317 void readXml( const QDomElement &elem ) override;
318 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
319 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
320
326 double startHeight() const;
327
333 double endHeight() const;
334
338 bool countedFromTop() const;
339
340 private:
341 bool hasValidInputs() const override;
342 void volumeRangeForFace( double &startVerticalLevel,
343 double &endVerticalLevel,
344 const QVector<double> &verticalLevels ) const override;
345 double mStartHeight = 0;
346 double mEndHeight = 0;
347 bool mCountedFromTop = true;
348};
349
362{
363 public:
364
367
373 QgsMeshElevationAveragingMethod( double startElevation, double endElevation );
375
376 QDomElement writeXml( QDomDocument &doc ) const override;
377 void readXml( const QDomElement &elem ) override;
378 bool equals( const QgsMesh3dAveragingMethod *other ) const override;
379 QgsMesh3dAveragingMethod *clone() const override SIP_FACTORY;
380
384 double startElevation() const;
385
389 double endElevation() const;
390
391 private:
392 bool hasValidInputs() const override;
393 void volumeRangeForFace( double &startVerticalLevel,
394 double &endVerticalLevel,
395 const QVector<double> &verticalLevels ) const override;
396 double mStartElevation = 0;
397 double mEndElevation = 0;
398};
399
400#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:99
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