QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
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
24#include "qgsmeshdataset.h"
25#include "qgsmeshdataprovider.h"
26#include "qgstriangularmesh.h"
28
30
31struct DataGroup
32{
34 QgsMeshDataBlock datasetValues;
35 QgsMeshDataBlock activeFaces;
36 QgsMesh3DDataBlock dataset3dStakedValue; //will be filled only if data are 3d stacked
37};
38
39class QgsExportMeshOnElement : public QgsProcessingAlgorithm
40{
41 public:
42 QString group() const override;
43 QString groupId() const override;
44
45 protected:
46 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
47 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
48 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
49 QgsMesh mNativeMesh;
50
51 private:
52 virtual QSet<int> supportedDataType() const = 0;
53 virtual Qgis::ProcessingSourceType sinkType() const = 0;
54 virtual Qgis::WkbType sinkGeometryType() const = 0;
55 virtual QgsGeometry meshElement( int index ) const = 0;
56 virtual QgsMesh::ElementType meshElementType() const = 0;
57
58 QList<DataGroup> mDataPerGroup;
59 QgsCoordinateTransform mTransform;
60 int mExportVectorOption = 2;
61 int mElementCount = 0;
62};
63
64class QgsExportMeshVerticesAlgorithm : public QgsExportMeshOnElement
65{
66 public:
67 QString shortHelpString() const override;
68 QString shortDescription() const override;
69 QString name() const override;
70 QString displayName() const override;
71
72 protected:
73 QgsProcessingAlgorithm *createInstance() const override;
74
75 private:
76 Qgis::WkbType sinkGeometryType() const override { return Qgis::WkbType::PointZ; }
77 QSet<int> supportedDataType() const override
78 {
79 return QSet<int>( { QgsMeshDatasetGroupMetadata::DataOnVertices } );
80 }
82 QgsGeometry meshElement( int index ) const override;
83 QgsMesh::ElementType meshElementType() const override { return QgsMesh::Vertex; }
84};
85
86class QgsExportMeshFacesAlgorithm : public QgsExportMeshOnElement
87{
88 public:
89 QString shortHelpString() const override;
90 QString shortDescription() const override;
91 QString name() const override;
92 QString displayName() const override;
93
94 protected:
95 QgsProcessingAlgorithm *createInstance() const override;
96
97 private:
98 Qgis::WkbType sinkGeometryType() const override { return Qgis::WkbType::PolygonZ; }
99 QSet<int> supportedDataType() const override
100 {
101 return QSet<int>( { QgsMeshDatasetGroupMetadata::DataOnFaces } );
102 }
104 QgsGeometry meshElement( int index ) const override;
105 QgsMesh::ElementType meshElementType() const override { return QgsMesh::Face; }
106};
107
108class QgsExportMeshEdgesAlgorithm : public QgsExportMeshOnElement
109{
110 public:
111 QString shortHelpString() const override;
112 QString shortDescription() const override;
113 QString name() const override;
114 QString displayName() const override;
115
116 protected:
117 QgsProcessingAlgorithm *createInstance() const override;
118
119 private:
120 Qgis::WkbType sinkGeometryType() const override { return Qgis::WkbType::LineStringZ; }
121 QSet<int> supportedDataType() const override
122 {
123 return QSet<int>( { QgsMeshDatasetGroupMetadata::DataOnEdges } );
124 }
125 Qgis::ProcessingSourceType sinkType() const override { return Qgis::ProcessingSourceType::VectorLine; }
126 QgsGeometry meshElement( int index ) const override;
127 QgsMesh::ElementType meshElementType() const override { return QgsMesh::Edge; }
128};
129
130
131class QgsExportMeshOnGridAlgorithm : public QgsProcessingAlgorithm
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 QString shortDescription() const override;
140
141 protected:
142 QgsProcessingAlgorithm *createInstance() const override;
143 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
144 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
145 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
146
147 private:
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
158class QgsMeshRasterizeAlgorithm : public QgsProcessingAlgorithm
159{
160 public:
161 QString name() const override;
162 QString displayName() const override;
163 QString group() const override;
164 QString groupId() const override;
165 QString shortHelpString() const override;
166 QString shortDescription() 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 QSet<int> supportedDataType();
176
177 QgsTriangularMesh mTriangularMesh;
178
179 QList<DataGroup> mDataPerGroup;
180 QgsCoordinateTransform mTransform;
181 QgsMeshRendererSettings mLayerRendererSettings;
182};
183
184class QgsMeshContoursAlgorithm : public QgsProcessingAlgorithm
185{
186 public:
187 QString name() const override;
188 QString displayName() const override;
189 QString group() const override;
190 QString groupId() const override;
191 QString shortHelpString() const override;
192 QString shortDescription() const override;
193
194 protected:
195 QgsProcessingAlgorithm *createInstance() const override;
196 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
197 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
198 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
199
200 private:
201 QSet<int> supportedDataType()
202 {
203 return QSet<int>(
207 );
208 }
209
210 QgsTriangularMesh mTriangularMesh;
211 QgsMesh mNativeMesh;
212 QVector<double> mLevels;
213
214 QList<DataGroup> mDataPerGroup;
215 QgsCoordinateTransform mTransform;
216 QgsMeshRendererSettings mLayerRendererSettings;
217 QString mDateTimeString;
218};
219
220class QgsMeshExportCrossSection : public QgsProcessingAlgorithm
221{
222 public:
223 QString name() const override;
224 QString displayName() const override;
225 QString group() const override;
226 QString groupId() const override;
227 QString shortHelpString() const override;
228 QString shortDescription() const override;
229
230 protected:
231 QgsProcessingAlgorithm *createInstance() const override;
232 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
233 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
234 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
235
236 private:
237 QSet<int> supportedDataType()
238 {
239 return QSet<int>(
243 );
244 }
245
246 QgsTriangularMesh mTriangularMesh;
247
248 QList<DataGroup> mDataPerGroup;
249 QgsCoordinateReferenceSystem mMeshLayerCrs;
250 QgsMeshRendererSettings mLayerRendererSettings;
251};
252
253class QgsMeshExportTimeSeries : public QgsProcessingAlgorithm
254{
255 public:
256 QString name() const override;
257 QString displayName() const override;
258 QString group() const override;
259 QString groupId() const override;
260 QString shortHelpString() const override;
261 QString shortDescription() const override;
262
263 protected:
264 QgsProcessingAlgorithm *createInstance() const override;
265 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
266 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
267 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
268
269 private:
270 QSet<int> supportedDataType()
271 {
272 return QSet<int>(
276 );
277 }
278
279 QgsTriangularMesh mTriangularMesh;
280
281 QgsCoordinateReferenceSystem mMeshLayerCrs;
282 QgsMeshRendererSettings mLayerRendererSettings;
283
284 QList<int> mGroupIndexes;
285 QList<DataGroup> mDatasets;
286 QList<qint64> mRelativeTimeSteps;
287 QStringList mTimeStepString;
288 QMap<qint64, QMap<int, int>> mRelativeTimeToData;
289 QMap<int, QgsMeshDatasetGroupMetadata> mGroupsMetadata;
290};
291
292
294
295#endif // QGSALGORITHMEXPORTMESH_H
ProcessingSourceType
Processing data source types.
Definition qgis.h:3315
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
WkbType
The WKB type describes the number of dimensions a geometry has.
Definition qgis.h:256
@ PointZ
PointZ.
@ LineStringZ
LineStringZ.
@ PolygonZ
PolygonZ.
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.
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 QgsProcessingAlgorithm * createInstance() const =0
Creates a new instance of the algorithm class.
virtual QString group() const
Returns the name of the group this algorithm belongs to.
virtual bool prepareAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Prepares the algorithm to run using the specified parameters.
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 QString shortDescription() const
Returns an optional translated short description of the algorithm.
virtual QString displayName() const =0
Returns the translated algorithm name, which should be used for any user-visible display of the algor...
virtual QVariantMap processAlgorithm(const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback)=0
Runs the algorithm using the specified parameters.
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.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
Mesh - vertices, edges and faces.
ElementType
Defines type of mesh elements.