QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
qgsmeshtriangulation.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshtriangulation.h
3  -----------------
4  begin : August 9th, 2020
5  copyright : (C) 2020 by Vincent Cloarec
6  email : vcloarec 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 #ifndef QGSMESHTRIANGULATION_H
18 #define QGSMESHTRIANGULATION_H
19 
21 #include "qgsmeshdataprovider.h"
22 
23 #include "qgis_analysis.h"
24 
25 
26 class QgsVectorLayer;
28 class QgsFeature;
29 class QgsFeatureIterator;
30 class QgsTriangulation;
31 class QgsFeedback;
32 
41 class ANALYSIS_EXPORT QgsMeshTriangulation : public QObject
42 {
43  Q_OBJECT
44  public:
45 
48 
51 
61  bool addVertices( QgsFeatureIterator &vertexFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback = nullptr, long featureCount = 1 );
62 
73  bool addBreakLines( QgsFeatureIterator &lineFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transformContext, QgsFeedback *feedback = nullptr, long featureCount = 1 );
74 
76  QgsMesh triangulatedMesh( QgsFeedback *feedback = nullptr ) const;
77 
79  void setCrs( const QgsCoordinateReferenceSystem &crs );
80 
81  private:
82 #ifdef SIP_RUN
84 #endif
85 
87  std::unique_ptr<QgsTriangulation> mTriangulation;
88 
89  void addVerticesFromFeature( const QgsFeature &feature, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback = nullptr );
90  void addBreakLinesFromFeature( const QgsFeature &feature, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback = nullptr );
91 };
92 
93 #ifndef SIP_RUN
94 
104 {
105  public:
106 
108  QgsMeshZValueDataset( const QgsMesh &mesh );
109 
110  QgsMeshDatasetValue datasetValue( int valueIndex ) const override;
111  QgsMeshDataBlock datasetValues( bool isScalar, int valueIndex, int count ) const override;
112  QgsMeshDataBlock areFacesActive( int faceIndex, int count ) const override;
113  bool isActive( int faceIndex ) const override;
114  QgsMeshDatasetMetadata metadata() const override;
115  int valuesCount() const override;
116 
117  private:
118  QgsMesh mMesh;
119  double mZMinimum = std::numeric_limits<double>::max();
120  double mZMaximum = -std::numeric_limits<double>::max();
121 };
122 
123 #endif //SIP_RUN
124 
133 class ANALYSIS_EXPORT QgsMeshZValueDatasetGroup: public QgsMeshDatasetGroup
134 {
135  public:
136 
143  QgsMeshZValueDatasetGroup( const QString &datasetGroupName, const QgsMesh &mesh );
144 
145  void initialize() override;
146  QgsMeshDatasetMetadata datasetMetadata( int datasetIndex ) const override;
147  int datasetCount() const override;
148  QgsMeshDataset *dataset( int index ) const override;
150  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
151 
152  private:
153 #ifdef SIP_RUN
155 #endif
156  std::unique_ptr<QgsMeshZValueDataset> mDataset;
157 };
158 
159 #endif // QGSMESHTRIANGULATION_H
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
Class for doing transforms between two map coordinate systems.
Wrapper for iterator of features from vector data provider or vector layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:56
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:45
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Abstract class that represents a dataset group.
Type
Type of the dataset group.
@ Virtual
Temporary dataset group in memory.
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
QgsMeshDatasetValue represents single dataset value.
Abstract class that represents a dataset.
Class that handles mesh creation with Delaunay constrained triangulation.
~QgsMeshTriangulation()
Destructor.
Convenient class that can be used to obtain a datasetgroup on vertices that represents the Z value of...
QgsMeshDatasetGroup::Type type() const override
Returns the type of dataset group.
Convenient class that can be used to obtain a dataset that represents the Z values of mesh vertices.
QgsMeshDataBlock areFacesActive(int faceIndex, int count) const override
Returns whether faces are active.
QgsMeshDatasetMetadata metadata() const override
Returns the metadata of the dataset.
QgsMeshZValueDataset(const QgsMesh &mesh)
Constructor with the mesh.
bool isActive(int faceIndex) const override
Returns whether the face is active.
int valuesCount() const override
Returns the values count.
QgsMeshDatasetValue datasetValue(int valueIndex) const override
Returns the value with index valueIndex.
QgsMeshDataBlock datasetValues(bool isScalar, int valueIndex, int count) const override
Returns count values from valueIndex.
The class is used as a container of context for various read/write operations on other objects.
Interface for Triangulation classes.
Represents a vector layer which manages a vector based data sets.
const QgsCoordinateReferenceSystem & crs
Mesh - vertices, edges and faces.