QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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#ifdef SIP_RUN
45 QgsMesh3DAveragingMethod *averagingMethod = dynamic_cast<QgsMesh3DAveragingMethod *>( sipCpp );
46
47 sipType = 0;
48
49 if ( averagingMethod )
50 {
51 switch ( averagingMethod->method() )
52 {
54 sipType = sipType_QgsMeshMultiLevelsAveragingMethod;
55 break;
57 sipType = sipType_QgsMeshSigmaAveragingMethod;
58 break;
60 sipType = sipType_QgsMeshRelativeHeightAveragingMethod;
61 break;
63 sipType = sipType_QgsMeshElevationAveragingMethod;
64 break;
65 default:
66 sipType = nullptr;
67 break;
68 }
69 }
71#endif
72
73 public:
86
88 QgsMesh3DAveragingMethod( Method method );
89
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( double &startVerticalLevel, double &endVerticalLevel, int &singleVerticalLevel, const QVector<double> &verticalLevels ) const = 0;
141
142 Method mMethod;
143};
144
156{
157 public:
160
168 QgsMeshMultiLevelsAveragingMethod( int startLevel, int endLevel, bool countedFromTop );
169
176 QgsMeshMultiLevelsAveragingMethod( int verticalLevel, bool countedFromTop );
177
179 QDomElement writeXml( QDomDocument &doc ) const override;
180 void readXml( const QDomElement &elem ) override;
181 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
183
192 int startVerticalLevel() const;
193
202 int endVerticalLevel() const;
203
207 bool countedFromTop() const;
208
212 bool isSingleLevel() const;
213
214 private:
215 bool hasValidInputs() const override;
216 void volumeRangeForFace( double &startVerticalLevel, double &endVerticalLevel, int &singleVerticalIndex, const QVector<double> &verticalLevels ) const override;
217 void setLevels( int startVerticalLevel, int endVerticalLevel );
218 int mStartVerticalLevel = 1;
219 int mEndVerticalLevel = 1;
220 bool mCountedFromTop = true;
221};
222
234{
235 public:
238
245
247 QDomElement writeXml( QDomDocument &doc ) const override;
248 void readXml( const QDomElement &elem ) override;
249 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
251
258 double startFraction() const;
259
266 double endFraction() const;
267
268 private:
269 bool hasValidInputs() const override;
270 void volumeRangeForFace( double &startVerticalLevel, double &endVerticalLevel, int &singleVerticalIndex, const QVector<double> &verticalLevels ) const override;
271
272 double mStartFraction = 0;
273 double mEndFraction = 1;
274};
275
294{
295 public:
298
307
309 QDomElement writeXml( QDomDocument &doc ) const override;
310 void readXml( const QDomElement &elem ) override;
311 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
313
319 double startHeight() const;
320
326 double endHeight() const;
327
331 bool countedFromTop() const;
332
333 private:
334 bool hasValidInputs() const override;
335 void volumeRangeForFace( double &startVerticalLevel, double &endVerticalLevel, int &singleVerticalIndex, const QVector<double> &verticalLevels ) const override;
336 double mStartHeight = 0;
337 double mEndHeight = 0;
338 bool mCountedFromTop = true;
339};
340
354{
355 public:
357
365
366 QDomElement writeXml( QDomDocument &doc ) const override;
367 void readXml( const QDomElement &elem ) override;
368 bool equals( const QgsMesh3DAveragingMethod *other ) const override;
370
374 double startElevation() const;
375
379 double endElevation() const;
380
381 private:
382 bool hasValidInputs() const override;
383 void volumeRangeForFace( double &startVerticalLevel, double &endVerticalLevel, int &singleVerticalIndex, const QVector<double> &verticalLevels ) const override;
384 double mStartElevation = 0;
385 double mEndElevation = 0;
386};
387
388#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 for interpolating 3d stacked mesh data to 2d data.
static QgsMesh3DAveragingMethod * createFromXml(const QDomElement &elem)
Creates the instance from XML by calling readXml of derived classes.
static bool equals(const QgsMesh3DAveragingMethod *a, const QgsMesh3DAveragingMethod *b)
Returns whether two methods equal.
QgsMeshDataBlock calculate(const QgsMesh3DDataBlock &block3d, QgsFeedback *feedback=nullptr) const
Calculated 2d block values from 3d stacked mesh values.
virtual void readXml(const QDomElement &elem)=0
Reads configuration from the given DOM element.
Method method() const
Returns type of averaging method.
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).
QgsMesh3DAveragingMethod(Method method)
Ctor.
virtual ~QgsMesh3DAveragingMethod()=default
virtual QDomElement writeXml(QDomDocument &doc) const =0
Writes configuration to a new DOM element.
virtual QgsMesh3DAveragingMethod * clone() const =0
Clone the instance.
A block of 3d stacked mesh data related N faces defined on base mesh frame.
A block of integers/doubles from a mesh dataset.
An index that identifies the dataset group (e.g.
double startElevation() const
Returns start elevation.
void readXml(const QDomElement &elem) override
Reads configuration from the given DOM element.
double endElevation() const
Returns end elevation.
QgsMesh3DAveragingMethod * clone() const override
Clone the instance.
QDomElement writeXml(QDomDocument &doc) const override
Writes configuration to a new DOM element.
bool equals(const QgsMesh3DAveragingMethod *other) const override
Returns whether method equals to other.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QDomElement writeXml(QDomDocument &doc) const override
Writes configuration to a new DOM element.
QgsMeshMultiLevelsAveragingMethod()
Constructs single level averaging method for 1st (top) vertical level.
int endVerticalLevel() const
Returns ending vertical level.
bool equals(const QgsMesh3DAveragingMethod *other) const override
Returns whether method equals to other.
QgsMesh3DAveragingMethod * clone() const override
Clone the instance.
bool countedFromTop() const
Returns whether the start and end vertical levels are indexed from top (surface) or bottom (bed) leve...
bool isSingleLevel() const
Returns whether the averaging method selects only a single vertical level.
void readXml(const QDomElement &elem) override
Reads configuration from the given DOM element.
int startVerticalLevel() const
Returns starting vertical level.
void readXml(const QDomElement &elem) override
Reads configuration from the given DOM element.
double startHeight() const
Returns starting depth/height.
QgsMeshRelativeHeightAveragingMethod()
Constructs default depth averaging method.
bool countedFromTop() const
Returns whether the start and end vertical levels are relative to top (surface) or bottom (bed) level...
bool equals(const QgsMesh3DAveragingMethod *other) const override
Returns whether method equals to other.
QDomElement writeXml(QDomDocument &doc) const override
Writes configuration to a new DOM element.
double endHeight() const
Returns ending depth/height.
QgsMesh3DAveragingMethod * clone() const override
Clone the instance.
double endFraction() const
Returns ending fraction.
QgsMeshSigmaAveragingMethod()
Constructs the sigma method for whole value range 0-1.
void readXml(const QDomElement &elem) override
Reads configuration from the given DOM element.
bool equals(const QgsMesh3DAveragingMethod *other) const override
Returns whether method equals to other.
QDomElement writeXml(QDomDocument &doc) const override
Writes configuration to a new DOM element.
QgsMesh3DAveragingMethod * clone() const override
Clone the instance.
~QgsMeshSigmaAveragingMethod() override
double startFraction() const
Returns starting fraction.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:198
#define SIP_ABSTRACT
Definition qgis_sip.h:220
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_END
Definition qgis_sip.h:215