QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgsprovidermetadata.h"
32 #include "qgsmeshdataset.h"
34 
35 
37 
39 typedef QgsPoint QgsMeshVertex;
40 
42 typedef QVector<int> QgsMeshFace;
43 
49 typedef QPair<int, int> QgsMeshEdge;
50 
58 struct CORE_EXPORT QgsMesh
59 {
60 
66  {
67  Vertex = 1,
68  Edge = 2,
69  Face = 4
70  };
71 
76  bool contains( const ElementType &type ) const;
77 
79  int vertexCount() const;
81  int faceCount() const;
82 
87  int edgeCount() const;
88 
90  QgsMeshVertex vertex( int index ) const;
92  QgsMeshFace face( int index ) const;
93 
98  QgsMeshEdge edge( int index ) const;
99 
104  void clear();
105 
110  static bool compareFaces( const QgsMeshFace &face1, const QgsMeshFace &face2 );
111 
112  QVector<QgsMeshVertex> vertices SIP_SKIP;
113  QVector<QgsMeshEdge> edges SIP_SKIP;
114  QVector<QgsMeshFace> faces SIP_SKIP;
115 };
116 
136 {
137  public:
139  virtual ~QgsMeshDataSourceInterface() = default;
140 
145  bool contains( const QgsMesh::ElementType &type ) const;
146 
151  virtual int vertexCount() const = 0;
152 
157  virtual int faceCount() const = 0;
158 
165  virtual int edgeCount() const = 0;
166 
175  virtual int maximumVerticesCountPerFace() const {return 0;};
176 
181  virtual void populateMesh( QgsMesh *mesh ) const = 0;
182 
192  virtual bool saveMeshFrame( const QgsMesh &mesh ) = 0;
193 };
194 
211 {
212  public:
215  virtual ~QgsMeshDatasetSourceInterface() = default;
216 
222  virtual bool addDataset( const QString &uri ) = 0;
223 
227  virtual QStringList extraDatasets() const = 0;
228 
232  virtual int datasetGroupCount( ) const = 0;
233 
237  virtual int datasetCount( int groupIndex ) const = 0;
238 
242  int datasetCount( QgsMeshDatasetIndex index ) const;
243 
247  virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
248 
252  QgsMeshDatasetGroupMetadata datasetGroupMetadata( QgsMeshDatasetIndex index ) const;
253 
257  virtual QgsMeshDatasetMetadata datasetMetadata( QgsMeshDatasetIndex index ) const = 0;
258 
270  virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
271 
283  virtual QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const = 0;
284 
296  virtual QgsMesh3dDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
297 
308  virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
309 
315  virtual QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
316 
336  Q_DECL_DEPRECATED virtual bool persistDatasetGroup( const QString &path,
337  const QgsMeshDatasetGroupMetadata &meta,
338  const QVector<QgsMeshDataBlock> &datasetValues,
339  const QVector<QgsMeshDataBlock> &datasetActive,
340  const QVector<double> &times
341  ) SIP_DEPRECATED;
342 
360  virtual bool persistDatasetGroup( const QString &outputFilePath,
361  const QString &outputDriver,
362  const QgsMeshDatasetGroupMetadata &meta,
363  const QVector<QgsMeshDataBlock> &datasetValues,
364  const QVector<QgsMeshDataBlock> &datasetActive,
365  const QVector<double> &times
366  ) = 0;
367 
368 
383  virtual bool persistDatasetGroup( const QString &outputFilePath,
384  const QString &outputDriver,
386  int datasetGroupIndex
387  ) = 0;
388 
399  QgsMeshDatasetIndex datasetIndexAtTime( const QDateTime &referenceTime,
400  int groupIndex,
401  qint64 time,
403 
416  QList<QgsMeshDatasetIndex> datasetIndexInTimeInterval( const QDateTime &referenceTime,
417  int groupIndex,
418  qint64 time1,
419  qint64 time2 ) const;
420 
421  protected:
422  std::unique_ptr<QgsMeshDataProviderTemporalCapabilities> mTemporalCapabilities;
423 };
424 
425 
437 {
438  Q_OBJECT
439  public:
441  QgsMeshDataProvider( const QString &uri,
442  const QgsDataProvider::ProviderOptions &providerOptions,
443  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
444 
447 
455  void setTemporalUnit( QgsUnitTypes::TemporalUnit unit );
456 
457 
465  virtual QgsMeshDriverMetadata driverMetadata() const;
466 
467 
473  virtual void close() = 0;
474 
475  signals:
477  void datasetGroupsAdded( int count );
478 
479 };
480 
481 #endif // QGSMESHDATAPROVIDER_H
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
QgsDataProvider
Abstract base class for spatial data provider implementations.
Definition: qgsdataprovider.h:40
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
QgsMeshVertex
QgsPoint QgsMeshVertex
xyz coords of vertex
Definition: qgsmeshdataprovider.h:36
QgsMeshDataProviderTemporalCapabilities
Class for handling properties relating to a mesh data provider's temporal capabilities.
Definition: qgsmeshdataprovidertemporalcapabilities.h:34
QgsMeshDatasetValue
QgsMeshDatasetValue represents single dataset value.
Definition: qgsmeshdataset.h:79
qgspoint.h
QgsMesh
Mesh - vertices, edges and faces.
Definition: qgsmeshdataprovider.h:58
QgsUnitTypes::TemporalUnit
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:149
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsMeshDatasetMetadata
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Definition: qgsmeshdataset.h:478
QgsMesh3dDataBlock
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
Definition: qgsmeshdataset.h:246
QgsMeshDriverMetadata
Holds metadata about mesh driver.
Definition: qgsprovidermetadata.h:57
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
qgsprovidermetadata.h
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. wind speed) and a dataset in thi...
Definition: qgsmeshdataset.h:48
QgsMeshDataProvider
Base class for providing data for QgsMeshLayer.
Definition: qgsmeshdataprovider.h:436
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
Definition: qgsmeshdataprovidertemporalcapabilities.h:41
QgsMeshDatasetSourceInterface
Interface for mesh datasets and dataset groups.
Definition: qgsmeshdataprovider.h:210
QgsMeshFace
QVector< int > QgsMeshFace
List of vertex indexes.
Definition: qgsmeshdataprovider.h:42
QgsMeshDataSourceInterface::maximumVerticesCountPerFace
virtual int maximumVerticesCountPerFace() const
Returns the maximum number of vertices per face supported by the current mesh, if returns 0,...
Definition: qgsmeshdataprovider.h:175
QgsDataProvider::temporalCapabilities
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
Definition: qgsdataprovider.cpp:35
QgsMeshDatasetGroupMetadata
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
Definition: qgsmeshdataset.h:351
QgsMeshEdge
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
Definition: qgsmeshdataprovider.h:49
qgsmeshdataset.h
qgsmeshdataprovidertemporalcapabilities.h
qgsdataprovider.h
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:137
QgsMeshDatasetSourceInterface::mTemporalCapabilities
std::unique_ptr< QgsMeshDataProviderTemporalCapabilities > mTemporalCapabilities
Definition: qgsmeshdataprovider.h:422
SIP_ABSTRACT
#define SIP_ABSTRACT
Definition: qgis_sip.h:208