QGIS API Documentation  3.17.0-Master (a035f434f4)
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 
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 
235  virtual QgsMeshDatasetMetadata datasetMetadata( QgsMeshDatasetIndex index ) const = 0;
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
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.
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
Abstract base class for spatial data provider implementations.
#define SIP_ABSTRACT
Definition: qgis_sip.h:199
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
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 ...
std::unique_ptr< QgsMeshDataProviderTemporalCapabilities > mTemporalCapabilities
Interface for mesh data sources.
QgsPoint QgsMeshVertex
xyz coords of vertex