QGIS API Documentation 3.35.0-Master (f6e073f0eed)
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:
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:
220
226 virtual bool addDataset( const QString &uri ) = 0;
227
231 virtual QStringList extraDatasets() const = 0;
232
236 virtual int datasetGroupCount( ) const = 0;
237
241 virtual int datasetCount( int groupIndex ) const = 0;
242
246 int datasetCount( QgsMeshDatasetIndex index ) const;
247
251 virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
252
256 QgsMeshDatasetGroupMetadata datasetGroupMetadata( QgsMeshDatasetIndex index ) const;
257
262
274 virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
275
287 virtual QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const = 0;
288
300 virtual QgsMesh3DDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
301
312 virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
313
319 virtual QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
320
340 Q_DECL_DEPRECATED virtual bool persistDatasetGroup( const QString &path,
341 const QgsMeshDatasetGroupMetadata &meta,
342 const QVector<QgsMeshDataBlock> &datasetValues,
343 const QVector<QgsMeshDataBlock> &datasetActive,
344 const QVector<double> &times
346
364 virtual bool persistDatasetGroup( const QString &outputFilePath,
365 const QString &outputDriver,
366 const QgsMeshDatasetGroupMetadata &meta,
367 const QVector<QgsMeshDataBlock> &datasetValues,
368 const QVector<QgsMeshDataBlock> &datasetActive,
369 const QVector<double> &times
370 ) = 0;
371
372
387 virtual bool persistDatasetGroup( const QString &outputFilePath,
388 const QString &outputDriver,
390 int datasetGroupIndex
391 ) = 0;
392
403 QgsMeshDatasetIndex datasetIndexAtTime( const QDateTime &referenceTime,
404 int groupIndex,
405 qint64 time,
407
420 QList<QgsMeshDatasetIndex> datasetIndexInTimeInterval( const QDateTime &referenceTime,
421 int groupIndex,
422 qint64 time1,
423 qint64 time2 ) const;
424
425 protected:
426 std::unique_ptr<QgsMeshDataProviderTemporalCapabilities> mTemporalCapabilities;
427};
428
429
441{
442 Q_OBJECT
443 public:
445 QgsMeshDataProvider( const QString &uri,
446 const QgsDataProvider::ProviderOptions &providerOptions,
447 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
448
449 QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() override;
450 const QgsMeshDataProviderTemporalCapabilities *temporalCapabilities() const override SIP_SKIP;
451
459 void setTemporalUnit( Qgis::TemporalUnit unit );
460
461
469 virtual QgsMeshDriverMetadata driverMetadata() const;
470
471
477 virtual void close() = 0;
478
479 signals:
481 void datasetGroupsAdded( int count );
482
483};
484
485#endif // QGSMESHDATAPROVIDER_H
TemporalUnit
Temporal units.
Definition qgis.h:4169
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 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
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.
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.