QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 #include "qgsmeshadvancedediting.h"
23 
24 #include "qgis_analysis.h"
25 
26 
27 class QgsVectorLayer;
29 class QgsFeature;
30 class QgsFeatureIterator;
31 class QgsTriangulation;
32 class QgsFeedback;
33 
42 class ANALYSIS_EXPORT QgsMeshTriangulation : public QObject
43 {
44  Q_OBJECT
45  public:
46 
49 
52 
62  bool addVertices( QgsFeatureIterator &vertexFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback = nullptr, long featureCount = 1 );
63 
74  bool addBreakLines( QgsFeatureIterator &lineFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transformContext, QgsFeedback *feedback = nullptr, long featureCount = 1 );
75 
81  int addVertex( const QgsPoint &vertex );
82 
84  QgsMesh triangulatedMesh( QgsFeedback *feedback = nullptr ) const;
85 
87  void setCrs( const QgsCoordinateReferenceSystem &crs );
88 
89  private:
90 #ifdef SIP_RUN
92 #endif
93 
95  std::unique_ptr<QgsTriangulation> mTriangulation;
96 
97  void addVerticesFromFeature( const QgsFeature &feature, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback = nullptr );
98  void addBreakLinesFromFeature( const QgsFeature &feature, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback = nullptr );
99 };
100 
101 #ifndef SIP_RUN
102 
112 {
113  public:
114 
116  QgsMeshZValueDataset( const QgsMesh &mesh );
117 
118  QgsMeshDatasetValue datasetValue( int valueIndex ) const override;
119  QgsMeshDataBlock datasetValues( bool isScalar, int valueIndex, int count ) const override;
120  QgsMeshDataBlock areFacesActive( int faceIndex, int count ) const override;
121  bool isActive( int faceIndex ) const override;
122  QgsMeshDatasetMetadata metadata() const override;
123  int valuesCount() const override;
124 
125  private:
126  QgsMesh mMesh;
127  double mZMinimum = std::numeric_limits<double>::max();
128  double mZMaximum = -std::numeric_limits<double>::max();
129 };
130 
131 #endif //SIP_RUN
132 
141 class ANALYSIS_EXPORT QgsMeshZValueDatasetGroup: public QgsMeshDatasetGroup
142 {
143  public:
144 
151  QgsMeshZValueDatasetGroup( const QString &datasetGroupName, const QgsMesh &mesh );
152 
153  void initialize() override;
154  QgsMeshDatasetMetadata datasetMetadata( int datasetIndex ) const override;
155  int datasetCount() const override;
156  QgsMeshDataset *dataset( int index ) const override;
158  QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
159 
160  private:
161 #ifdef SIP_RUN
163 #endif
164  std::unique_ptr<QgsMeshZValueDataset> mDataset;
165 };
166 
167 
178 {
179  public:
180 
183 
184  QString text() const override;
185 
186  private:
187  QgsTopologicalMesh::Changes apply( QgsMeshEditor *meshEditor ) override;
188 };
189 
190 #endif // QGSMESHTRIANGULATION_H
QgsMeshAdvancedEditing
Abstract class that can be derived to implement advanced editing on mesh.
Definition: qgsmeshadvancedediting.h:38
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:57
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsTopologicalMesh::Changes
Class that contains topological differences between two states of a topological mesh,...
Definition: qgstopologicalmesh.h:96
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
QgsMeshDatasetGroup::writeXml
virtual QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Write dataset group information in a DOM element.
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsMeshDatasetGroup::datasetCount
virtual int datasetCount() const =0
Returns the count of datasets in the group.
QgsMeshDatasetValue
QgsMeshDatasetValue represents single dataset value.
Definition: qgsmeshdataset.h:79
QgsTriangulation
Interface for Triangulation classes.
Definition: qgstriangulation.h:41
QgsMeshZValueDataset::areFacesActive
QgsMeshDataBlock areFacesActive(int faceIndex, int count) const override
Returns whether faces are active.
Definition: qgsmeshtriangulation.cpp:314
QgsMeshZValueDataset::valuesCount
int valuesCount() const override
Returns the values count.
Definition: qgsmeshtriangulation.cpp:333
QgsMeshDataset
Abstract class that represents a dataset.
Definition: qgsmeshdataset.h:543
QgsMeshZValueDataset::datasetValue
QgsMeshDatasetValue datasetValue(int valueIndex) const override
Returns the value with index valueIndex.
Definition: qgsmeshtriangulation.cpp:295
QgsMeshZValueDatasetGroup::type
QgsMeshDatasetGroup::Type type() const override
Returns the type of dataset group.
Definition: qgsmeshtriangulation.h:157
QgsMeshAdvancedEditing::text
virtual QString text() const
Returns a short text string describing what this advanced edit does. Default implementation return a ...
Definition: qgsmeshadvancedediting.cpp:60
QgsMesh
Mesh - vertices, edges and faces.
Definition: qgsmeshdataprovider.h:58
QgsMeshDatasetMetadata
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Definition: qgsmeshdataset.h:478
QgsMeshEditor
Class that makes edit operation on a mesh.
Definition: qgsmesheditor.h:67
QgsMeshZValueDataset::datasetValues
QgsMeshDataBlock datasetValues(bool isScalar, int valueIndex, int count) const override
Returns count values from valueIndex.
Definition: qgsmeshtriangulation.cpp:303
QgsMeshZValueDataset::isActive
bool isActive(int faceIndex) const override
Returns whether the face is active.
Definition: qgsmeshtriangulation.cpp:323
qgsmeshadvancedediting.h
QgsFeedback
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition: qgsfeedback.h:44
QgsMeshDatasetGroup::initialize
virtual void initialize()=0
Initialize the dataset group.
QgsMeshTriangulation
Class that handles mesh creation with Delaunay constrained triangulation.
Definition: qgsmeshtriangulation.h:42
QgsMeshZValueDatasetGroup
Convenient class that can be used to obtain a datasetgroup on vertices that represents the Z value of...
Definition: qgsmeshtriangulation.h:141
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsMeshDatasetGroup::dataset
virtual QgsMeshDataset * dataset(int index) const =0
Returns the dataset with index.
QgsMeshDatasetGroup
Abstract class that represents a dataset group.
Definition: qgsmeshdataset.h:578
QgsMeshDatasetGroup::datasetMetadata
virtual QgsMeshDatasetMetadata datasetMetadata(int datasetIndex) const =0
Returns the metadata of the dataset with index datasetIndex.
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsMeshDatasetGroup::Type
Type
Type of the dataset group.
Definition: qgsmeshdataset.h:587
QgsMeshEditingDelaunayTriangulation
Class that can be used with QgsMeshEditor::advancedEdit() to add triangle faces to a mesh created by ...
Definition: qgsmeshtriangulation.h:177
QgsMeshZValueDataset
Convenient class that can be used to obtain a dataset that represents the Z values of mesh vertices.
Definition: qgsmeshtriangulation.h:111
QgsMeshZValueDataset::QgsMeshZValueDataset
QgsMeshZValueDataset(const QgsMesh &mesh)
Constructor with the mesh.
Definition: qgsmeshtriangulation.cpp:284
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:137
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:289
qgscoordinatereferencesystem.h
QgsMeshAdvancedEditing::apply
virtual QgsTopologicalMesh::Changes apply(QgsMeshEditor *meshEditor)=0
Apply a change to mesh Editor.
qgsmeshdataprovider.h
QgsMeshZValueDataset::metadata
QgsMeshDatasetMetadata metadata() const override
Returns the metadata of the dataset.
Definition: qgsmeshtriangulation.cpp:328
QgsMeshDatasetGroup::Virtual
@ Virtual
Temporary dataset group in memory.
Definition: qgsmeshdataset.h:592