QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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};
109
110// we need to declare metatype so QgsMesh can be passed as QVariant for expressions
112
113
133{
134 public:
135 virtual ~QgsMeshDataSourceInterface() = default;
136
141 bool contains( const QgsMesh::ElementType &type ) const;
142
147 virtual int vertexCount() const = 0;
148
153 virtual int faceCount() const = 0;
154
161 virtual int edgeCount() const = 0;
162
171 virtual int maximumVerticesCountPerFace() const { return 0; };
172
177 virtual void populateMesh( QgsMesh *mesh ) const = 0;
178
188 virtual bool saveMeshFrame( const QgsMesh &mesh ) = 0;
189};
190
207{
208 public:
211
217 virtual bool addDataset( const QString &uri ) = 0;
218
222 virtual QStringList extraDatasets() const = 0;
223
227 virtual int datasetGroupCount() const = 0;
228
232 virtual int datasetCount( int groupIndex ) const = 0;
233
237 int datasetCount( QgsMeshDatasetIndex index ) const;
238
242 virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata( int groupIndex ) const = 0;
243
248
253
265 virtual QgsMeshDatasetValue datasetValue( QgsMeshDatasetIndex index, int valueIndex ) const = 0;
266
278 virtual QgsMeshDataBlock datasetValues( QgsMeshDatasetIndex index, int valueIndex, int count ) const = 0;
279
291 virtual QgsMesh3DDataBlock dataset3dValues( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
292
303 virtual bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const = 0;
304
310 virtual QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const = 0;
311
331 Q_DECL_DEPRECATED virtual bool persistDatasetGroup(
332 const QString &path, const QgsMeshDatasetGroupMetadata &meta, const QVector<QgsMeshDataBlock> &datasetValues, const QVector<QgsMeshDataBlock> &datasetActive, const QVector<double> &times
334
353 const QString &outputFilePath,
354 const QString &outputDriver,
355 const QgsMeshDatasetGroupMetadata &meta,
356 const QVector<QgsMeshDataBlock> &datasetValues,
357 const QVector<QgsMeshDataBlock> &datasetActive,
358 const QVector<double> &times
359 ) = 0;
360
361
376 virtual bool persistDatasetGroup( const QString &outputFilePath, const QString &outputDriver, QgsMeshDatasetSourceInterface *source, int datasetGroupIndex ) = 0;
377
388 QgsMeshDatasetIndex datasetIndexAtTime( const QDateTime &referenceTime, int groupIndex, qint64 time, QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod method ) const;
389
402 QList<QgsMeshDatasetIndex> datasetIndexInTimeInterval( const QDateTime &referenceTime, int groupIndex, qint64 time1, qint64 time2 ) const;
403
404 protected:
405 std::unique_ptr<QgsMeshDataProviderTemporalCapabilities> mTemporalCapabilities;
406};
407
408
420{
421 Q_OBJECT
422 public:
425
428
437
438
447
448
454 virtual void close() = 0;
455
465 virtual bool removeDatasetGroup( int index ) = 0;
466
467 signals:
469 void datasetGroupsAdded( int count );
470};
471
472#endif // QGSMESHDATAPROVIDER_H
TemporalUnit
Temporal units.
Definition qgis.h:5316
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:512
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:133
#define SIP_ABSTRACT
Definition qgis_sip.h:220
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.
QVector< QgsMeshVertex > vertices
QVector< QgsMeshFace > faces
ElementType
Defines type of mesh elements.
QVector< QgsMeshEdge > edges