QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
36class QgsRectangle;
37
40
42typedef QVector<int> QgsMeshFace;
43
49typedef QPair<int, int> QgsMeshEdge;
50
58struct 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:
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
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
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
445 QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() override;
446 const QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() const override SIP_SKIP;
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
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.
virtual void close()=0
Closes the data provider and free every resources used.
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 bool saveMeshFrame(const QgsMesh &mesh)=0
Saves the mesh frame to the source.
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.
virtual int maximumVerticesCountPerFace() const
Returns the maximum number of vertices per face supported by the current mesh, if returns 0,...
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.
Holds metadata about mesh driver.
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:208
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.