QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
26 class QgsMeshLayer;
27 class QgsMesh3dDataBlock;
28 class QgsMeshDataBlock;
30 class QgsFeedback;
31 class 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  }
69  SIP_END
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
QgsMesh3dAveragingMethod::RelativeHeightAveragingMethod
@ RelativeHeightAveragingMethod
Method to average values defined by range of relative length units to the surface or bed level.
Definition: qgsmesh3daveraging.h:81
QgsMeshMultiLevelsAveragingMethod::~QgsMeshMultiLevelsAveragingMethod
~QgsMeshMultiLevelsAveragingMethod() override
QgsMesh3dAveragingMethod::Method
Method
Type of averaging method.
Definition: qgsmesh3daveraging.h:75
QgsMesh3dAveragingMethod::SigmaAveragingMethod
@ SigmaAveragingMethod
Method to average values between 0 (bed level) and 1 (surface)
Definition: qgsmesh3daveraging.h:79
QgsMeshMultiLevelsAveragingMethod
Multi level averaging method specifies limits of vertical layers from the top layer down or reversed.
Definition: qgsmesh3daveraging.h:159
QgsMesh3dAveragingMethod::equals
virtual bool equals(const QgsMesh3dAveragingMethod *other) const =0
Returns whether method equals to other.
QgsMeshSigmaAveragingMethod
Sigma averages over the values between 0 (bed level) and 1 (surface).
Definition: qgsmesh3daveraging.h:239
QgsMesh3dDataBlock
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
Definition: qgsmeshdataset.h:245
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsMeshElevationAveragingMethod::~QgsMeshElevationAveragingMethod
~QgsMeshElevationAveragingMethod() override
QgsMeshElevationAveragingMethod
Elevation averaging method averages the values based on range defined absolute value to the model's d...
Definition: qgsmesh3daveraging.h:362
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:177
QgsMeshRelativeHeightAveragingMethod
Relative height averaging method averages the values based on range defined relative to bed elevation...
Definition: qgsmesh3daveraging.h:300
QgsMesh3dAveragingMethod::equals
static bool equals(const QgsMesh3dAveragingMethod *a, const QgsMesh3dAveragingMethod *b)
Returns whether two methods equal.
Definition: qgsmesh3daveraging.cpp:214
QgsMeshDatasetIndex
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Definition: qgsmeshdataset.h:47
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:95
QgsMeshRelativeHeightAveragingMethod::~QgsMeshRelativeHeightAveragingMethod
~QgsMeshRelativeHeightAveragingMethod() override
QgsMesh3dAveragingMethod::MultiLevelsAveragingMethod
@ MultiLevelsAveragingMethod
Method to average values from selected vertical layers.
Definition: qgsmesh3daveraging.h:77
qgis_sip.h
QgsMesh3dAveragingMethod
Abstract class to interpolate 3d stacked mesh data to 2d data.
Definition: qgsmesh3daveraging.h:40
QgsMesh3dAveragingMethod::writeXml
virtual QDomElement writeXml(QDomDocument &doc) const =0
Writes configuration to a new DOM element.
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:136
QgsMesh3dAveragingMethod::readXml
virtual void readXml(const QDomElement &elem)=0
Reads configuration from the given DOM element.
SIP_END
#define SIP_END
Definition: qgis_sip.h:194
QgsMesh3dAveragingMethod::clone
virtual QgsMesh3dAveragingMethod * clone() const =0
Clone the instance.
QgsMeshSigmaAveragingMethod::~QgsMeshSigmaAveragingMethod
~QgsMeshSigmaAveragingMethod() override
QgsMesh3dAveragingMethod::~QgsMesh3dAveragingMethod
virtual ~QgsMesh3dAveragingMethod()=default
Dtor.
QgsMesh3dAveragingMethod::ElevationAveragingMethod
@ ElevationAveragingMethod
Method to average values defined by range of absolute length units to the model's datum.
Definition: qgsmesh3daveraging.h:83
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:199