QGIS API Documentation 4.3.0-Master (6ece89243d2)
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 <limits>
22
23#include "qgis_core.h"
24#include "qgsdataprovider.h"
26#include "qgsmeshdataset.h"
27#include "qgsmeshutils.h"
28#include "qgsprovidermetadata.h"
29
30#include <QMap>
31#include <QPair>
32#include <QString>
33#include <QVector>
34
35#ifdef SIP_RUN
36// clang-format off
37% ModuleHeaderCode
38#include "qgsmeshutils.h"
39% End
40// clang-format on
41#endif
42
43 class QgsRectangle;
44
52struct CORE_EXPORT QgsMesh
53{
59 {
60 Vertex = 1,
61 Edge = 2,
62 Face = 4
63 };
64
69 bool contains( const ElementType &type ) const;
70
72 int vertexCount() const;
74 int faceCount() const;
75
80 int edgeCount() const;
81
83 QgsMeshVertex vertex( int index ) const;
85 QgsMeshFace face( int index ) const;
86
91 QgsMeshEdge edge( int index ) const;
92
97 void clear();
98
103 static bool compareFaces( const QgsMeshFace &face1, const QgsMeshFace &face2 );
104
105 QVector<QgsMeshVertex> vertices SIP_SKIP;
106 QVector<QgsMeshEdge> edges SIP_SKIP;
107 QVector<QgsMeshFace> faces SIP_SKIP;
108
113 double minimumElevation() const;
114
119 double maximumElevation() const;
120
126 void invalidateZMinMax();
127
128 private:
129 mutable double mZMin = std::numeric_limits<double>::quiet_NaN();
130 mutable double mZMax = std::numeric_limits<double>::quiet_NaN();
131
132 bool zMinMaxIsValid() const;
133 void calculateZMinMax() const;
134};
135
136// we need to declare metatype so QgsMesh can be passed as QVariant for expressions
138
139
159{
160 public:
161 virtual ~QgsMeshDataSourceInterface() = default;
162
167 bool contains( const QgsMesh::ElementType &type ) const;
168
173 virtual int vertexCount() const = 0;
174
179 virtual int faceCount() const = 0;
180
187 virtual int edgeCount() const = 0;
188
197 virtual int maximumVerticesCountPerFace() const { return 0; };
198
203 virtual void populateMesh( QgsMesh *mesh ) const = 0;
204
214 virtual bool saveMeshFrame( const QgsMesh &mesh ) = 0;
215};
216
233{
234 public:
237
243 virtual bool addDataset( const QString &uri ) = 0;
244
248 virtual QStringList extraDatasets() const = 0;
249
253 virtual int datasetGroupCount() const = 0;
254
258 virtual int datasetCount( int groupIndex ) const = 0;
259
263 int datasetCount( QgsMeshDatasetIndex index ) const;
264
268 virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
269
274
279
291 virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
292
304 virtual QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const = 0;
305
317 virtual QgsMesh3DDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
318
329 virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
330
336 virtual QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
337
357 Q_DECL_DEPRECATED virtual bool persistDatasetGroup(
358 const QString &path, const QgsMeshDatasetGroupMetadata &meta, const QVector<QgsMeshDataBlock> &datasetValues, const QVector<QgsMeshDataBlock> &datasetActive, const QVector<double> &times
360
379 const QString &outputFilePath,
380 const QString &outputDriver,
381 const QgsMeshDatasetGroupMetadata &meta,
382 const QVector<QgsMeshDataBlock> &datasetValues,
383 const QVector<QgsMeshDataBlock> &datasetActive,
384 const QVector<double> &times
385 ) = 0;
386
387
402 virtual bool persistDatasetGroup( const QString &outputFilePath, const QString &outputDriver, QgsMeshDatasetSourceInterface *source, int datasetGroupIndex ) = 0;
403
414 QgsMeshDatasetIndex datasetIndexAtTime( const QDateTime &referenceTime, int groupIndex, qint64 time, QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod method ) const;
415
428 QList<QgsMeshDatasetIndex> datasetIndexInTimeInterval( const QDateTime &referenceTime, int groupIndex, qint64 time1, qint64 time2 ) const;
429
430 protected:
431 std::unique_ptr<QgsMeshDataProviderTemporalCapabilities> mTemporalCapabilities;
432};
433
434
446{
447 Q_OBJECT
448 public:
451
454
463
464
473
474
480 virtual void close() = 0;
481
491 virtual bool removeDatasetGroup( int index ) = 0;
492
493 signals:
495 void datasetGroupsAdded( int count );
496};
497
498#endif // QGSMESHDATAPROVIDER_H
TemporalUnit
Temporal units.
Definition qgis.h:5746
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:532
QgsDataProvider(const QString &uri=QString(), const QgsDataProvider::ProviderOptions &providerOptions=QgsDataProvider::ProviderOptions(), Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Create a new dataprovider with the specified in the uri.
QgsDataSourceUri uri() const
Gets the data source specification.
A block of 3d stacked mesh data related N faces defined on base mesh frame.
A block of integers/doubles from a mesh dataset.
Handles properties relating to a mesh data provider's temporal capabilities.
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
virtual QgsMeshDriverMetadata driverMetadata() const
Returns the mesh driver metadata of the provider.
void setTemporalUnit(Qgis::TemporalUnit unit)
Sets the temporal unit of the provider and reload data if it changes.
QgsMeshDataProvider(const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags=Qgis::DataProviderReadFlags())
Ctor.
virtual bool removeDatasetGroup(int index)=0
Remove dataset group from the mesh.
void datasetGroupsAdded(int count)
Emitted when some new dataset groups have been added.
QgsMeshDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
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.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
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,...
A collection of dataset group metadata such as whether the data is vector or scalar,...
An index that identifies the dataset group (e.g.
Represents mesh dataset metadata, such as whether the data is valid or the associated time.
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 Q_DECL_DEPRECATED bool persistDatasetGroup(const QString &path, const QgsMeshDatasetGroupMetadata &meta, const QVector< QgsMeshDataBlock > &datasetValues, const QVector< QgsMeshDataBlock > &datasetActive, const QVector< double > &times)
Creates a new dataset group from a data and persists it into a destination path.
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
QgsMeshDatasetIndex datasetIndexAtTime(const QDateTime &referenceTime, int groupIndex, qint64 time, QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod method) const
Returns the dataset index of the dataset in a specific dataset group at time from the reference time.
virtual QStringList extraDatasets() const =0
Returns list of additional dataset file URIs added using addDataset() calls.
QList< QgsMeshDatasetIndex > datasetIndexInTimeInterval(const QDateTime &referenceTime, int groupIndex, qint64 time1, qint64 time2) const
Returns a list of dataset indexes of the dataset in a specific dataset group that are between time1 a...
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.
Represents a single mesh dataset value.
Holds metadata about mesh drivers.
A rectangle specified with double values.
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:138
#define SIP_ABSTRACT
Definition qgis_sip.h:225
Q_DECLARE_METATYPE(QgsMesh)
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.
double maximumElevation() const
Returns the maximum elevation value of all vertices of the mesh.
QVector< QgsMeshVertex > vertices
QVector< QgsMeshFace > faces
ElementType
Defines type of mesh elements.
double minimumElevation() const
Returns the minimum elevation value of all vertices of the mesh.
void invalidateZMinMax()
Invalidates the minimum and maximum elevation values, therefoe when querying zMinimum() or zMaximum()...
QVector< QgsMeshEdge > edges