QGIS API Documentation  3.13.0-Master (b73bd58cfb)
qgsmeshdataprovider.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshdataprovider.h
3  ---------------------
4  begin : April 2018
5  copyright : (C) 2018 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 QGSMESHDATAPROVIDER_H
19 #define QGSMESHDATAPROVIDER_H
20 
21 #include <QVector>
22 #include <QString>
23 #include <QMap>
24 #include <QPair>
25 
26 #include <limits>
27 
28 #include "qgis_core.h"
29 #include "qgspoint.h"
30 #include "qgsdataprovider.h"
31 #include "qgsmeshdataset.h"
33 
34 
36 
38 typedef QgsPoint QgsMeshVertex;
39 
41 typedef QVector<int> QgsMeshFace;
42 
48 typedef QPair<int, int> QgsMeshEdge;
49 
57 struct CORE_EXPORT QgsMesh
58 {
59 
65  {
66  Vertex = 1,
67  Edge = 2,
68  Face = 4
69  };
70 
75  bool contains( const ElementType &type ) const;
76 
78  int vertexCount() const;
80  int faceCount() const;
81 
86  int edgeCount() const;
87 
89  QgsMeshVertex vertex( int index ) const;
91  QgsMeshFace face( int index ) const;
92 
97  QgsMeshEdge edge( int index ) const;
98 
103  void clear();
104 
105  QVector<QgsMeshVertex> vertices SIP_SKIP;
106  QVector<QgsMeshEdge> edges SIP_SKIP;
107  QVector<QgsMeshFace> faces SIP_SKIP;
108 };
109 
128 {
129  public:
131  virtual ~QgsMeshDataSourceInterface() = default;
132 
137  bool contains( const QgsMesh::ElementType &type ) const;
138 
143  virtual int vertexCount() const = 0;
144 
149  virtual int faceCount() const = 0;
150 
157  virtual int edgeCount() const = 0;
158 
163  virtual void populateMesh( QgsMesh *mesh ) const = 0;
164 };
165 
182 {
183  public:
185  virtual ~QgsMeshDatasetSourceInterface() = default;
186 
192  virtual bool addDataset( const QString &uri ) = 0;
193 
197  virtual QStringList extraDatasets() const = 0;
198 
202  virtual int datasetGroupCount( ) const = 0;
203 
207  virtual int datasetCount( int groupIndex ) const = 0;
208 
212  int datasetCount( QgsMeshDatasetIndex index ) const;
213 
217  virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
218 
222  QgsMeshDatasetGroupMetadata datasetGroupMetadata( QgsMeshDatasetIndex index ) const;
223 
227  virtual QgsMeshDatasetMetadata datasetMetadata( QgsMeshDatasetIndex index ) const = 0;
228 
240  virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
241 
253  virtual QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const = 0;
254 
266  virtual QgsMesh3dDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
267 
278  virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
279 
285  virtual QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
286 
303  virtual bool persistDatasetGroup( const QString &path,
304  const QgsMeshDatasetGroupMetadata &meta,
305  const QVector<QgsMeshDataBlock> &datasetValues,
306  const QVector<QgsMeshDataBlock> &datasetActive,
307  const QVector<double> &times
308  ) = 0;
309 };
310 
311 
323 {
324  Q_OBJECT
325 
326  public:
328  QgsMeshDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions );
329 
332 
340  void setTemporalUnit( QgsUnitTypes::TemporalUnit unit );
341 
342  signals:
344  void datasetGroupsAdded( int count );
345 
346  private:
347  std::unique_ptr<QgsMeshDataProviderTemporalCapabilities> mTemporalCapabilities;
348 };
349 
350 #endif // QGSMESHDATAPROVIDER_H
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Class for handling properties relating to a mesh data provider&#39;s temporal capabilities.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e...
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame...
ElementType
Defines type of mesh elements.
Abstract base class for spatial data provider implementations.
#define SIP_ABSTRACT
Definition: qgis_sip.h:194
#define SIP_SKIP
Definition: qgis_sip.h:126
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
Base class for providing data for QgsMeshLayer.
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
Setting options for creating vector data providers.
Mesh - vertices, edges and faces.
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider&#39;s temporal capabilities.
Interface for mesh datasets and dataset groups.
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
QVector< int > QgsMeshFace
List of vertex indexes.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:149
QgsMeshDatasetValue represents single dataset value.
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Interface for mesh data sources.
QgsPoint QgsMeshVertex
xyz coords of vertex