QGIS API Documentation  3.20.0-Odense (decaadbb31)
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 
35 class QgsRectangle;
36 
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 
109  static bool compareFaces( const QgsMeshFace &face1, const QgsMeshFace &face2 );
110 
111  QVector<QgsMeshVertex> vertices SIP_SKIP;
112  QVector<QgsMeshEdge> edges SIP_SKIP;
113  QVector<QgsMeshFace> faces SIP_SKIP;
114 };
115 
135 {
136  public:
138  virtual ~QgsMeshDataSourceInterface() = default;
139 
144  bool contains( const QgsMesh::ElementType &type ) const;
145 
150  virtual int vertexCount() const = 0;
151 
156  virtual int faceCount() const = 0;
157 
164  virtual int edgeCount() const = 0;
165 
170  virtual void populateMesh( QgsMesh *mesh ) const = 0;
171 };
172 
189 {
190  public:
193  virtual ~QgsMeshDatasetSourceInterface() = default;
194 
200  virtual bool addDataset( const QString &uri ) = 0;
201 
205  virtual QStringList extraDatasets() const = 0;
206 
210  virtual int datasetGroupCount( ) const = 0;
211 
215  virtual int datasetCount( int groupIndex ) const = 0;
216 
220  int datasetCount( QgsMeshDatasetIndex index ) const;
221 
225  virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
226 
230  QgsMeshDatasetGroupMetadata datasetGroupMetadata( QgsMeshDatasetIndex index ) const;
231 
236 
248  virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
249 
261  virtual QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const = 0;
262 
274  virtual QgsMesh3dDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
275 
286  virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
287 
293  virtual QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
294 
314  Q_DECL_DEPRECATED virtual bool persistDatasetGroup( const QString &path,
315  const QgsMeshDatasetGroupMetadata &meta,
316  const QVector<QgsMeshDataBlock> &datasetValues,
317  const QVector<QgsMeshDataBlock> &datasetActive,
318  const QVector<double> &times
319  ) SIP_DEPRECATED;
320 
338  virtual bool persistDatasetGroup( const QString &outputFilePath,
339  const QString &outputDriver,
340  const QgsMeshDatasetGroupMetadata &meta,
341  const QVector<QgsMeshDataBlock> &datasetValues,
342  const QVector<QgsMeshDataBlock> &datasetActive,
343  const QVector<double> &times
344  ) = 0;
345 
346 
361  virtual bool persistDatasetGroup( const QString &outputFilePath,
362  const QString &outputDriver,
364  int datasetGroupIndex
365  ) = 0;
366 
377  QgsMeshDatasetIndex datasetIndexAtTime( const QDateTime &referenceTime,
378  int groupIndex,
379  quint64 time,
381 
382  protected:
383  std::unique_ptr<QgsMeshDataProviderTemporalCapabilities> mTemporalCapabilities;
384 };
385 
386 
398 {
399  Q_OBJECT
400  public:
402  QgsMeshDataProvider( const QString &uri,
403  const QgsDataProvider::ProviderOptions &providerOptions,
404  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
405 
406  QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() override;
407  const QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() const override SIP_SKIP;
408 
416  void setTemporalUnit( QgsUnitTypes::TemporalUnit unit );
417 
418  signals:
420  void datasetGroupsAdded( int count );
421 
422 };
423 
424 #endif // QGSMESHDATAPROVIDER_H
Abstract base class for spatial data provider implementations.
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....
Class for handling properties relating to a mesh data provider's temporal capabilities.
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
Base class for providing data for QgsMeshLayer.
void datasetGroupsAdded(int count)
Emitted when some new dataset groups have been added.
Interface for mesh data sources.
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
virtual void populateMesh(QgsMesh *mesh) const =0
Populates the mesh vertices, edges and faces.
virtual ~QgsMeshDataSourceInterface()=default
Dtor.
virtual int edgeCount() const =0
Returns number of edges in the native mesh.
virtual int faceCount() const =0
Returns number of faces in the native mesh.
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Interface for mesh datasets and dataset groups.
virtual QgsMeshDataBlock datasetValues(QgsMeshDatasetIndex index, int valueIndex, int count) const =0
Returns N vector/scalar values from the index from the dataset.
virtual bool persistDatasetGroup(const QString &outputFilePath, const QString &outputDriver, QgsMeshDatasetSourceInterface *source, int datasetGroupIndex)=0
Saves a an existing dataset group provided by source to a file with a specified driver.
virtual int datasetCount(int groupIndex) const =0
Returns number of datasets loaded in the group.
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const =0
Returns dataset group metadata.
virtual ~QgsMeshDatasetSourceInterface()=default
Dtor.
virtual QgsMeshDataBlock areFacesActive(QgsMeshDatasetIndex index, int faceIndex, int count) const =0
Returns whether the faces are active for particular dataset.
virtual QgsMeshDatasetMetadata datasetMetadata(QgsMeshDatasetIndex index) const =0
Returns dataset metadata.
virtual int datasetGroupCount() const =0
Returns number of datasets groups loaded.
std::unique_ptr< QgsMeshDataProviderTemporalCapabilities > mTemporalCapabilities
virtual QStringList extraDatasets() const =0
Returns list of additional dataset file URIs added using addDataset() calls.
virtual bool isFaceActive(QgsMeshDatasetIndex index, int faceIndex) const =0
Returns whether the face is active for particular dataset.
virtual bool persistDatasetGroup(const QString &outputFilePath, const QString &outputDriver, const QgsMeshDatasetGroupMetadata &meta, const QVector< QgsMeshDataBlock > &datasetValues, const QVector< QgsMeshDataBlock > &datasetActive, const QVector< double > &times)=0
Creates a new dataset group from a data and persists it into a destination path.
virtual QgsMeshDatasetValue datasetValue(QgsMeshDatasetIndex index, int valueIndex) const =0
Returns vector/scalar value associated with the index from the dataset To read multiple continuous va...
virtual bool addDataset(const QString &uri)=0
Associate dataset with the mesh.
virtual QgsMesh3dDataBlock dataset3dValues(QgsMeshDatasetIndex index, int faceIndex, int count) const =0
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
QgsMeshDatasetValue represents single dataset value.
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:49
A rectangle specified with double values.
Definition: qgsrectangle.h:42
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:150
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_ABSTRACT
Definition: qgis_sip.h:199
QVector< int > QgsMeshFace
List of vertex indexes.
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
QgsPoint QgsMeshVertex
xyz coords of vertex
Setting options for creating vector data providers.
Mesh - vertices, edges and faces.
ElementType
Defines type of mesh elements.