QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsalgorithmexportmesh.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsalgorithmexportmesh.h
3  ---------------------------
4  begin : October 2020
5  copyright : (C) 2020 by Vincent Cloarec
6  email : vcloarec 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 QGSALGORITHMEXPORTMESH_H
19 #define QGSALGORITHMEXPORTMESH_H
20 
21 #define SIP_NO_FILE
22 
23 #include "qgsprocessingalgorithm.h"
24 #include "qgsmeshdataset.h"
25 #include "qgsmeshdataprovider.h"
26 #include "qgstriangularmesh.h"
28 
30 
31 struct DataGroup
32 {
34  QgsMeshDataBlock datasetValues;
35  QgsMeshDataBlock activeFaces;
36  QgsMesh3dDataBlock dataset3dStakedValue; //will be filled only if data are 3d stacked
37 };
38 
39 class QgsExportMeshOnElement : public QgsProcessingAlgorithm
40 {
41 
42  public:
43  QString group() const override;
44  QString groupId() const override;
45 
46  protected:
47  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
48  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
49  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
50  QgsMesh mNativeMesh;
51 
52  private:
53 
54  virtual QSet<int> supportedDataType() const = 0;
55  virtual QgsProcessing::SourceType sinkType() const = 0;
56  virtual QgsWkbTypes::Type sinkGeometryType() const = 0;
57  virtual QgsGeometry meshElement( int index ) const = 0;
58  virtual QgsMesh::ElementType meshElementType() const = 0;
59 
60  QList<DataGroup> mDataPerGroup;
61  QgsCoordinateTransform mTransform;
62  int mExportVectorOption = 2;
63  int mElementCount = 0;
64 };
65 
66 class QgsExportMeshVerticesAlgorithm : public QgsExportMeshOnElement
67 {
68  public:
69  QString shortHelpString() const override;
70  QString name() const override;
71  QString displayName() const override;
72 
73  protected:
74  QgsProcessingAlgorithm *createInstance() const override;
75 
76  private:
77  QgsWkbTypes::Type sinkGeometryType() const override {return QgsWkbTypes::PointZ;}
78  QSet<int> supportedDataType() const override
79  {
80  return QSet<int>( {QgsMeshDatasetGroupMetadata::DataOnVertices} );
81  }
82  QgsProcessing::SourceType sinkType() const override {return QgsProcessing::TypeVectorPoint;}
83  QgsGeometry meshElement( int index ) const override;
84  QgsMesh::ElementType meshElementType()const override {return QgsMesh::Vertex;}
85 };
86 
87 class QgsExportMeshFacesAlgorithm : public QgsExportMeshOnElement
88 {
89  public:
90  QString shortHelpString() const override;
91  QString name() const override;
92  QString displayName() const override;
93 
94  protected:
95  QgsProcessingAlgorithm *createInstance() const override;
96 
97  private:
98  QgsWkbTypes::Type sinkGeometryType() const override {return QgsWkbTypes::PolygonZ;}
99  QSet<int> supportedDataType() const override
100  {
101  return QSet<int>( {QgsMeshDatasetGroupMetadata::DataOnFaces} );
102  }
103  QgsProcessing::SourceType sinkType() const override {return QgsProcessing::TypeVectorPolygon;}
104  QgsGeometry meshElement( int index ) const override;
105  QgsMesh::ElementType meshElementType()const override {return QgsMesh::Face;}
106 };
107 
108 class QgsExportMeshEdgesAlgorithm : public QgsExportMeshOnElement
109 {
110  public:
111  QString shortHelpString() const override;
112  QString name() const override;
113  QString displayName() const override;
114 
115  protected:
116  QgsProcessingAlgorithm *createInstance() const override;
117 
118  private:
119  QgsWkbTypes::Type sinkGeometryType() const override {return QgsWkbTypes::LineStringZ;}
120  QSet<int> supportedDataType() const override
121  {
122  return QSet<int>( {QgsMeshDatasetGroupMetadata::DataOnEdges} );
123  }
124  QgsProcessing::SourceType sinkType() const override {return QgsProcessing::TypeVectorLine;}
125  QgsGeometry meshElement( int index ) const override;
126  QgsMesh::ElementType meshElementType()const override {return QgsMesh::Edge;}
127 };
128 
129 
130 class QgsExportMeshOnGridAlgorithm : public QgsProcessingAlgorithm
131 {
132 
133  public:
134  QString name() const override;
135  QString displayName() const override;
136  QString group() const override;
137  QString groupId() const override;
138  QString shortHelpString() const override;
139 
140  protected:
141  QgsProcessingAlgorithm *createInstance() const override;
142  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
143  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
144  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
145 
146  private:
147 
148  QSet<int> supportedDataType();
149 
150  QgsTriangularMesh mTriangularMesh;
151 
152  QList<DataGroup> mDataPerGroup;
153  QgsCoordinateTransform mTransform;
154  int mExportVectorOption = 2;
155  QgsMeshRendererSettings mLayerRendererSettings;
156 };
157 
158 class QgsMeshRasterizeAlgorithm : public QgsProcessingAlgorithm
159 {
160 
161  public:
162  QString name() const override;
163  QString displayName() const override;
164  QString group() const override;
165  QString groupId() const override;
166  QString shortHelpString() const override;
167 
168  protected:
169  QgsProcessingAlgorithm *createInstance() const override;
170  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
171  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
172  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
173 
174  private:
175 
176  QSet<int> supportedDataType();
177 
178  QgsTriangularMesh mTriangularMesh;
179 
180  QList<DataGroup> mDataPerGroup;
181  QgsCoordinateTransform mTransform;
182  QgsMeshRendererSettings mLayerRendererSettings;
183 };
184 
185 class QgsMeshContoursAlgorithm : public QgsProcessingAlgorithm
186 {
187 
188  public:
189  QString name() const override;
190  QString displayName() const override;
191  QString group() const override;
192  QString groupId() const override;
193  QString shortHelpString() const override;
194 
195  protected:
196  QgsProcessingAlgorithm *createInstance() const override;
197  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
198  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
199  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
200 
201  private:
202 
203  QSet<int> supportedDataType()
204  {
205  return QSet<int>(
206  {
210  }
211 
212  QgsTriangularMesh mTriangularMesh;
213  QgsMesh mNativeMesh;
214  QVector<double> mLevels;
215 
216  QList<DataGroup> mDataPerGroup;
217  QgsCoordinateTransform mTransform;
218  QgsMeshRendererSettings mLayerRendererSettings;
219  QString mDateTimeString;
220 
221 };
222 
223 class QgsMeshExportCrossSection : public QgsProcessingAlgorithm
224 {
225 
226  public:
227  QString name() const override;
228  QString displayName() const override;
229  QString group() const override;
230  QString groupId() const override;
231  QString shortHelpString() const override;
232 
233  protected:
234  QgsProcessingAlgorithm *createInstance() const override;
235  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
236  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
237  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
238 
239  private:
240 
241  QSet<int> supportedDataType()
242  {
243  return QSet<int>(
244  {
248  }
249 
250  QgsTriangularMesh mTriangularMesh;
251 
252  QList<DataGroup> mDataPerGroup;
253  QgsCoordinateReferenceSystem mMeshLayerCrs;
254  QgsMeshRendererSettings mLayerRendererSettings;
255 
256 };
257 
258 class QgsMeshExportTimeSeries : public QgsProcessingAlgorithm
259 {
260 
261  public:
262  QString name() const override;
263  QString displayName() const override;
264  QString group() const override;
265  QString groupId() const override;
266  QString shortHelpString() const override;
267 
268  protected:
269  QgsProcessingAlgorithm *createInstance() const override;
270  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
271  bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
272  QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
273 
274  private:
275 
276  QSet<int> supportedDataType()
277  {
278  return QSet<int>(
279  {
283  }
284 
285  QgsTriangularMesh mTriangularMesh;
286 
287  QgsCoordinateReferenceSystem mMeshLayerCrs;
288  QgsMeshRendererSettings mLayerRendererSettings;
289 
290  QList<int> mGroupIndexes;
291  QList<DataGroup> mDatasets;
292  QList<qint64> mRelativeTimeSteps;
293  QStringList mTimeStepString;
294  QMap<qint64, QMap<int, int>> mRelativeTimeToData;
295  QMap<int, QgsMeshDatasetGroupMetadata> mGroupsMetadata;
296 
297 };
298 
299 
301 
302 #endif // QGSALGORITHMEXPORTMESH_H
This class represents a coordinate reference system (CRS).
Class for doing transforms between two map coordinate systems.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
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....
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
@ DataOnEdges
Data is defined on edges.
@ DataOnFaces
Data is defined on faces.
@ DataOnVertices
Data is defined on vertices.
@ DataOnVolumes
Data is defined on volumes.
Represents all mesh renderer settings.
Abstract base class for processing algorithms.
virtual QString group() const
Returns the name of the group this algorithm belongs to.
virtual QString groupId() const
Returns the unique ID of the group this algorithm belongs to.
virtual QString shortHelpString() const
Returns a localised short helper string for the algorithm.
virtual QVariantMap processAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)=0
Runs the algorithm using the specified parameters.
virtual QString displayName() const =0
Returns the translated algorithm name, which should be used for any user-visible display of the algor...
virtual bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback) SIP_THROW(QgsProcessingException)
Prepares the algorithm to run using the specified parameters.
virtual QgsProcessingAlgorithm * createInstance() const =0
Creates a new instance of the algorithm class.
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
SourceType
Data source types enum.
Definition: qgsprocessing.h:46
@ TypeVectorLine
Vector line layers.
Definition: qgsprocessing.h:50
@ TypeVectorPolygon
Vector polygon layers.
Definition: qgsprocessing.h:51
@ TypeVectorPoint
Vector point layers.
Definition: qgsprocessing.h:49
Triangular/Derived Mesh is mesh with vertices in map coordinates.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:70
Mesh - vertices, edges and faces.
ElementType
Defines type of mesh elements.