QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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;
31
42{
43
44#ifdef SIP_RUN
46 QgsMesh3DAveragingMethod *averagingMethod = dynamic_cast<QgsMesh3DAveragingMethod *>( sipCpp );
47
48 sipType = 0;
49
50 if ( averagingMethod )
51 {
52 switch ( averagingMethod->method() )
53 {
55 sipType = sipType_QgsMeshMultiLevelsAveragingMethod;
56 break;
58 sipType = sipType_QgsMeshSigmaAveragingMethod;
59 break;
61 sipType = sipType_QgsMeshRelativeHeightAveragingMethod;
62 break;
64 sipType = sipType_QgsMeshElevationAveragingMethod;
65 break;
66 default:
67 sipType = nullptr;
68 break;
69 }
70 }
72#endif
73
74 public:
76 enum Method
77 {
79 MultiLevelsAveragingMethod = 0,
85 ElevationAveragingMethod
86 };
87
89 QgsMesh3DAveragingMethod( Method method );
90
92 virtual ~QgsMesh3DAveragingMethod() = default;
93
95 QgsMeshDataBlock calculate( const QgsMesh3DDataBlock &block3d, QgsFeedback *feedback = nullptr ) const;
96
100 virtual QDomElement writeXml( QDomDocument &doc ) const = 0;
101
103 static QgsMesh3DAveragingMethod *createFromXml( const QDomElement &elem ) SIP_FACTORY;
104
106 virtual void readXml( const QDomElement &elem ) = 0;
107
109 static bool equals( const QgsMesh3DAveragingMethod *a, const QgsMesh3DAveragingMethod *b );
110
112 virtual bool equals( const QgsMesh3DAveragingMethod *other ) const = 0;
113
116
118 Method method() const;
119
120 private:
122 virtual bool hasValidInputs() const = 0;
123
127 void averageVolumeValuesForFace(
128 int faceIndex,
129 int volumesBelowFaceCount,
130 int startVolumeIndex,
131 double methodLevelTop,
132 double methodLevelBottom,
133 bool isVector,
134 const QVector<double> &verticalLevelsForFace,
135 const QVector<double> &volumeValues,
136 QVector<double> &valuesFaces
137 ) const;
138
142 virtual void volumeRangeForFace(
143 double &startVerticalLevel,
144 double &endVerticalLevel,
145 int &singleVerticalLevel,
146 const QVector<double> &verticalLevels ) const = 0;
147
148 Method mMethod;
149};
150
162{
163 public:
166
174 QgsMeshMultiLevelsAveragingMethod( int startLevel, int endLevel, bool countedFromTop );
175
182 QgsMeshMultiLevelsAveragingMethod( int verticalLevel, bool countedFromTop );
183
185 QDomElement writeXml( QDomDocument &doc ) const override;
186 void readXml( const QDomElement &elem ) override;
187 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
188 QgsMesh3DAveragingMethod *clone() const override SIP_FACTORY;
189
198 int startVerticalLevel() const;
199
208 int endVerticalLevel() const;
209
213 bool countedFromTop() const;
214
218 bool isSingleLevel() const;
219
220 private:
221 bool hasValidInputs() const override;
222 void volumeRangeForFace( double &startVerticalLevel,
223 double &endVerticalLevel,
224 int &singleVerticalIndex,
225 const QVector<double> &verticalLevels ) const override;
226 void setLevels( int startVerticalLevel, int endVerticalLevel );
227 int mStartVerticalLevel = 1;
228 int mEndVerticalLevel = 1;
229 bool mCountedFromTop = true;
230};
231
243{
244 public:
247
253 QgsMeshSigmaAveragingMethod( double startFraction, double endFraction );
254
256 QDomElement writeXml( QDomDocument &doc ) const override;
257 void readXml( const QDomElement &elem ) override;
258 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
259 QgsMesh3DAveragingMethod *clone() const override SIP_FACTORY;
260
267 double startFraction() const;
268
275 double endFraction() const;
276
277 private:
278 bool hasValidInputs() const override;
279 void volumeRangeForFace( double &startVerticalLevel,
280 double &endVerticalLevel,
281 int &singleVerticalIndex,
282 const QVector<double> &verticalLevels ) const override;
283
284 double mStartFraction = 0;
285 double mEndFraction = 1;
286};
287
305{
306 public:
307
310
318 QgsMeshRelativeHeightAveragingMethod( double startHeight, double endHeight, bool countedFromTop );
319
321 QDomElement writeXml( QDomDocument &doc ) const override;
322 void readXml( const QDomElement &elem ) override;
323 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
324 QgsMesh3DAveragingMethod *clone() const override SIP_FACTORY;
325
331 double startHeight() const;
332
338 double endHeight() const;
339
343 bool countedFromTop() const;
344
345 private:
346 bool hasValidInputs() const override;
347 void volumeRangeForFace( double &startVerticalLevel,
348 double &endVerticalLevel,
349 int &singleVerticalIndex,
350 const QVector<double> &verticalLevels ) const override;
351 double mStartHeight = 0;
352 double mEndHeight = 0;
353 bool mCountedFromTop = true;
354};
355
368{
369 public:
370
373
379 QgsMeshElevationAveragingMethod( double startElevation, double endElevation );
381
382 QDomElement writeXml( QDomDocument &doc ) const override;
383 void readXml( const QDomElement &elem ) override;
384 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
385 QgsMesh3DAveragingMethod *clone() const override SIP_FACTORY;
386
390 double startElevation() const;
391
395 double endElevation() const;
396
397 private:
398 bool hasValidInputs() const override;
399 void volumeRangeForFace( double &startVerticalLevel,
400 double &endVerticalLevel,
401 int &singleVerticalIndex,
402 const QVector<double> &verticalLevels ) const override;
403 double mStartElevation = 0;
404 double mEndElevation = 0;
405};
406
407#endif // QGSMESH3DAVERAGING_H
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
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 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()=default
Dtor.
virtual QDomElement writeXml(QDomDocument &doc) const =0
Writes configuration to a new DOM element.
virtual QgsMesh3DAveragingMethod * clone() const =0
Clone the instance.
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.
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:191
#define SIP_ABSTRACT
Definition qgis_sip.h:213
#define SIP_FACTORY
Definition qgis_sip.h:76
#define SIP_END
Definition qgis_sip.h:208