QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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
117// we need to declare metatype so QgsMesh can be passed as QVariant for expressions
119
120
140{
141 public:
142
143 virtual ~QgsMeshDataSourceInterface() = default;
144
149 bool contains( const QgsMesh::ElementType &type ) const;
150
155 virtual int vertexCount() const = 0;
156
161 virtual int faceCount() const = 0;
162
169 virtual int edgeCount() const = 0;
170
179 virtual int maximumVerticesCountPerFace() const {return 0;};
180
185 virtual void populateMesh( QgsMesh *mesh ) const = 0;
186
196 virtual bool saveMeshFrame( const QgsMesh &mesh ) = 0;
197};
198
215{
216 public:
219
225 virtual bool addDataset( const QString &uri ) = 0;
226
230 virtual QStringList extraDatasets() const = 0;
231
235 virtual int datasetGroupCount( ) const = 0;
236
240 virtual int datasetCount( int groupIndex ) const = 0;
241
245 int datasetCount( QgsMeshDatasetIndex index ) const;
246
250 virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
251
255 QgsMeshDatasetGroupMetadata datasetGroupMetadata( QgsMeshDatasetIndex index ) const;
256
261
273 virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
274
286 virtual QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const = 0;
287
299 virtual QgsMesh3DDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
300
311 virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
312
318 virtual QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
319
339 Q_DECL_DEPRECATED virtual bool persistDatasetGroup( const QString &path,
340 const QgsMeshDatasetGroupMetadata &meta,
341 const QVector<QgsMeshDataBlock> &datasetValues,
342 const QVector<QgsMeshDataBlock> &datasetActive,
343 const QVector<double> &times
345
363 virtual bool persistDatasetGroup( const QString &outputFilePath,
364 const QString &outputDriver,
365 const QgsMeshDatasetGroupMetadata &meta,
366 const QVector<QgsMeshDataBlock> &datasetValues,
367 const QVector<QgsMeshDataBlock> &datasetActive,
368 const QVector<double> &times
369 ) = 0;
370
371
386 virtual bool persistDatasetGroup( const QString &outputFilePath,
387 const QString &outputDriver,
389 int datasetGroupIndex
390 ) = 0;
391
402 QgsMeshDatasetIndex datasetIndexAtTime( const QDateTime &referenceTime,
403 int groupIndex,
404 qint64 time,
406
419 QList<QgsMeshDatasetIndex> datasetIndexInTimeInterval( const QDateTime &referenceTime,
420 int groupIndex,
421 qint64 time1,
422 qint64 time2 ) const;
423
424 protected:
425 std::unique_ptr<QgsMeshDataProviderTemporalCapabilities> mTemporalCapabilities;
426};
427
428
440{
441 Q_OBJECT
442 public:
444 QgsMeshDataProvider( const QString &uri,
445 const QgsDataProvider::ProviderOptions &providerOptions,
447
448 QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() override;
449 const QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() const override SIP_SKIP;
450
458 void setTemporalUnit( Qgis::TemporalUnit unit );
459
460
468 virtual QgsMeshDriverMetadata driverMetadata() const;
469
470
476 virtual void close() = 0;
477
478 signals:
480 void datasetGroupsAdded( int count );
481
482};
483
484#endif // QGSMESHDATAPROVIDER_H
TemporalUnit
Temporal units.
Definition qgis.h:4815
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
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
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 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.
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
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.
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.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_ABSTRACT
Definition qgis_sip.h:213
QVector< int > QgsMeshFace
List of vertex indexes.
Q_DECLARE_METATYPE(QgsMesh)
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.