QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 
408 
416  void setTemporalUnit( QgsUnitTypes::TemporalUnit unit );
417 
418  signals:
420  void datasetGroupsAdded( int count );
421 
422 };
423 
424 #endif // QGSMESHDATAPROVIDER_H
QgsMeshDatasetSourceInterface::datasetGroupCount
virtual int datasetGroupCount() const =0
Returns number of datasets groups loaded.
QgsMeshDatasetSourceInterface::datasetValue
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...
QgsMeshDatasetSourceInterface::datasetCount
virtual int datasetCount(int groupIndex) const =0
Returns number of datasets loaded in the group.
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:105
QgsDataProvider
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:42
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
QgsMeshVertex
QgsPoint QgsMeshVertex
xyz coords of vertex
Definition: qgsmeshdataprovider.h:35
QgsMeshDatasetSourceInterface::addDataset
virtual bool addDataset(const QString &uri)=0
Associate dataset with the mesh.
QgsMeshDataProviderTemporalCapabilities
Class for handling properties relating to a mesh data provider's temporal capabilities.
Definition: qgsmeshdataprovidertemporalcapabilities.h:35
QgsMeshDataSourceInterface::populateMesh
virtual void populateMesh(QgsMesh *mesh) const =0
Populates the mesh vertices, edges and faces.
Face_t
Definition: qgsgeometrymakevalid.cpp:37
QgsMeshDatasetValue
QgsMeshDatasetValue represents single dataset value.
Definition: qgsmeshdataset.h:78
QgsMeshDataSourceInterface::~QgsMeshDataSourceInterface
virtual ~QgsMeshDataSourceInterface()=default
Dtor.
qgspoint.h
QgsMesh
Mesh - vertices, edges and faces.
Definition: qgsmeshdataprovider.h:58
QgsUnitTypes::TemporalUnit
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:150
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsMeshDatasetMetadata
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Definition: qgsmeshdataset.h:476
QgsMesh3dDataBlock
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
Definition: qgsmeshdataset.h:245
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsMeshDatasetSourceInterface::datasetValues
virtual QgsMeshDataBlock datasetValues(QgsMeshDatasetIndex index, int valueIndex, int count) const =0
Returns N vector/scalar values from the index from the dataset.
QgsMeshDatasetSourceInterface::~QgsMeshDatasetSourceInterface
virtual ~QgsMeshDatasetSourceInterface()=default
Dtor.
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsMeshDataSourceInterface
Interface for mesh data sources.
Definition: qgsmeshdataprovider.h:135
QgsMesh::ElementType
ElementType
Defines type of mesh elements.
Definition: qgsmeshdataprovider.h:65
QgsMeshDatasetIndex
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Definition: qgsmeshdataset.h:47
QgsMeshDataProvider
Base class for providing data for QgsMeshLayer.
Definition: qgsmeshdataprovider.h:398
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
Definition: qgsmeshdataprovidertemporalcapabilities.h:42
QgsMeshDataSourceInterface::edgeCount
virtual int edgeCount() const =0
Returns number of edges in the native mesh.
QgsMeshDatasetSourceInterface::isFaceActive
virtual bool isFaceActive(QgsMeshDatasetIndex index, int faceIndex) const =0
Returns whether the face is active for particular dataset.
QgsMeshDataSourceInterface::vertexCount
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
QgsMeshDatasetSourceInterface
Interface for mesh datasets and dataset groups.
Definition: qgsmeshdataprovider.h:189
QgsMeshFace
QVector< int > QgsMeshFace
List of vertex indexes.
Definition: qgsmeshdataprovider.h:41
QgsMeshDatasetSourceInterface::persistDatasetGroup
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.
QgsMeshDatasetSourceInterface::datasetMetadata
virtual QgsMeshDatasetMetadata datasetMetadata(QgsMeshDatasetIndex index) const =0
Returns dataset metadata.
QgsMeshDataSourceInterface::faceCount
virtual int faceCount() const =0
Returns number of faces in the native mesh.
QgsMeshDatasetGroupMetadata
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
Definition: qgsmeshdataset.h:350
QgsMeshEdge
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
Definition: qgsmeshdataprovider.h:48
QgsDataProvider::temporalCapabilities
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
Definition: qgsdataprovider.cpp:30
QgsMeshDatasetSourceInterface::extraDatasets
virtual QStringList extraDatasets() const =0
Returns list of additional dataset file URIs added using addDataset() calls.
qgsmeshdataset.h
QgsMeshDatasetSourceInterface::dataset3dValues
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.
qgsmeshdataprovidertemporalcapabilities.h
QgsMeshDataProvider::datasetGroupsAdded
void datasetGroupsAdded(int count)
Emitted when some new dataset groups have been added.
qgsdataprovider.h
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:136
QgsMeshDatasetSourceInterface::persistDatasetGroup
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.
QgsMeshDatasetSourceInterface::areFacesActive
virtual QgsMeshDataBlock areFacesActive(QgsMeshDatasetIndex index, int faceIndex, int count) const =0
Returns whether the faces are active for particular dataset.
QgsMeshDatasetSourceInterface::datasetGroupMetadata
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const =0
Returns dataset group metadata.
QgsMeshDatasetSourceInterface::mTemporalCapabilities
std::unique_ptr< QgsMeshDataProviderTemporalCapabilities > mTemporalCapabilities
Definition: qgsmeshdataprovider.h:383
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:199