Skip to content

Commit 7cbf80f

Browse files
authoredSep 11, 2020
Merge pull request #38309 from vcloarec/TINMeshCreaton
TIN Mesh creation
2 parents 5941261 + 89e4d49 commit 7cbf80f

40 files changed

+2203
-23
lines changed
 

‎CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ IF (WITH_CORE AND WITH_BINDINGS)
871871
INCLUDE(SIPMacros)
872872

873873
SET(SIP_INCLUDES ${PYQT_SIP_DIR} ${CMAKE_SOURCE_DIR}/python)
874-
SET(SIP_CONCAT_PARTS 9)
874+
SET(SIP_CONCAT_PARTS 11)
875875

876876
IF (NOT BINDINGS_GLOBAL_INSTALL)
877877
SET(PYTHON_SITE_PACKAGES_DIR ${QGIS_DATA_DIR}/python)

‎python/analysis/analysis_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
%Include auto_generated/interpolation/qgsinterpolator.sip
66
%Include auto_generated/interpolation/qgstininterpolator.sip
77
%Include auto_generated/mesh/qgsmeshcontours.sip
8+
%Include auto_generated/mesh/qgsmeshtriangulation.sip
89
%Include auto_generated/network/qgsgraph.sip
910
%Include auto_generated/network/qgsgraphanalyzer.sip
1011
%Include auto_generated/network/qgsgraphbuilder.sip
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/analysis/mesh/qgsmeshtriangulation.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
13+
14+
class QgsMeshTriangulation : QObject
15+
{
16+
%Docstring
17+
18+
Class that handles mesh creation with Delaunay constrained triangulation
19+
20+
.. versionadded:: 3.16
21+
%End
22+
23+
%TypeHeaderCode
24+
#include "qgsmeshtriangulation.h"
25+
%End
26+
public:
27+
28+
QgsMeshTriangulation();
29+
%Docstring
30+
Constructor
31+
%End
32+
33+
~QgsMeshTriangulation();
34+
35+
bool addVertices( QgsFeatureIterator &vertexFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transform, QgsFeedback *feedback = 0, long featureCount = 1 );
36+
%Docstring
37+
Adds vertices to the triangulation from a feature iterator, return ``True`` if successful.
38+
39+
:param vertexFeatureIterator: the feature iterator of vertices to insert
40+
:param valueAttribute: the index of the attribute that represents the value of vertices, if -1 uses Z coordinate of vertices
41+
:param transform: the coordinates transform used to transform coordinates
42+
:param feedback: feedback argument may be specified to allow cancellation and progress reports
43+
:param featureCount: the count of feature to allow progress report of the feedback
44+
%End
45+
46+
bool addBreakLines( QgsFeatureIterator &lineFeatureIterator, int valueAttribute, const QgsCoordinateTransform &transformContext, QgsFeedback *feedback = 0, long featureCount = 1 );
47+
%Docstring
48+
Adds break lines from a vector layer, return ``True`` if successful.
49+
50+
:param lineFeatureIterator: the feature iterator of break lines to insert
51+
:param valueAttribute: the index of the attribute that represents the value of vertices, if -1 uses Z coordinate of vertices
52+
:param transform: the coordinates transform used to transform coordinates
53+
:param feedback: feedback argument may be specified to allow cancellation and progress reports
54+
:param featureCount: the count of feature to allow progress report of the feedback
55+
56+
.. warning::
57+
58+
if the feature iterator contains only point geometries, the vertices will be added only without treating them as breaklines
59+
%End
60+
61+
QgsMesh triangulatedMesh() const;
62+
%Docstring
63+
Returns the triangulated mesh
64+
%End
65+
66+
void setCrs( const QgsCoordinateReferenceSystem &crs );
67+
%Docstring
68+
Sets the coordinate reference system used for the triangulation
69+
%End
70+
71+
private:
72+
QgsMeshTriangulation( const QgsMeshTriangulation &rhs );
73+
};
74+
75+
76+
class QgsMeshZValueDatasetGroup: QgsMeshDatasetGroup
77+
{
78+
%Docstring
79+
80+
Convenient class that can be used to obtain a datasetgroup on vertices that represents the Z value of the mesh vertices
81+
82+
.. versionadded:: 3.16
83+
%End
84+
85+
%TypeHeaderCode
86+
#include "qgsmeshtriangulation.h"
87+
%End
88+
public:
89+
90+
QgsMeshZValueDatasetGroup( const QString &datasetGroupName, const QgsMesh &mesh );
91+
%Docstring
92+
Constructor
93+
94+
:param datasetGroupName: the name of the dataset group
95+
:param mesh: the mesh used to create the Z value dataset
96+
%End
97+
98+
virtual void initialize();
99+
100+
virtual QgsMeshDatasetMetadata datasetMetadata( int datasetIndex ) const;
101+
102+
virtual int datasetCount() const;
103+
104+
virtual QgsMeshDataset *dataset( int index ) const;
105+
106+
virtual QgsMeshDatasetGroup::Type type() const;
107+
virtual QDomElement writeXml( QDomDocument &doc, const QgsReadWriteContext &context ) const;
108+
109+
110+
private:
111+
QgsMeshZValueDatasetGroup( const QgsMeshZValueDatasetGroup &rhs );
112+
};
113+
114+
/************************************************************************
115+
* This file has been generated automatically from *
116+
* *
117+
* src/analysis/mesh/qgsmeshtriangulation.h *
118+
* *
119+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
120+
************************************************************************/

‎python/core/auto_generated/mesh/qgsmeshlayer.sip.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,16 @@ Adds datasets to the mesh from file with ``path``. Use the the time ``defaultRef
164164
.. versionadded:: 3.14
165165
%End
166166

167+
bool addDatasets( QgsMeshDatasetGroup *datasetGroup /Transfer/ );
168+
%Docstring
169+
Adds extra datasets to the mesh. Take ownership.
170+
171+
:param datasetGroup: the extra dataset group
172+
173+
:return: whether the dataset is effectively added
174+
175+
.. versionadded:: 3.16
176+
%End
167177

168178
bool saveDataset( const QString &path, int datasetGroupIndex, QString driver );
169179
%Docstring

‎python/core/auto_generated/processing/qgsprocessingparameters.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ their acceptable ranges, defaults, etc.
299299
sipType = sipType_QgsProcessingParameterDatabaseTable;
300300
else if ( sipCpp->type() == QgsProcessingParameterFieldMapping::typeName() )
301301
sipType = sipType_QgsProcessingParameterFieldMapping;
302+
else if ( sipCpp->type() == QgsProcessingParameterTinInputLayers::typeName() )
303+
sipType = sipType_QgsProcessingParameterTinInputLayers;
302304
else
303305
sipType = nullptr;
304306
%End
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/core/processing/qgsprocessingparametertininputlayers.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
class QgsProcessingParameterTinInputLayers: QgsProcessingParameterDefinition
12+
{
13+
%Docstring
14+
A parameter for processing algorithms that need a list of input vector layers to construct a TIN
15+
A valid value for this parameter is a list (QVariantList), where each item is a map (QVariantMap) in this form:
16+
{
17+
'source': string that represents identification of the vector layer,
18+
'type': how the vector layer is used : as vertices, structure lines or break lines
19+
'attributeIndex' : the index of the attribute of the vector layer used to defined the Z value of vertices,
20+
if -1, the Z coordinates of features are used
21+
}
22+
23+
.. versionadded:: 3.16
24+
%End
25+
26+
%TypeHeaderCode
27+
#include "qgsprocessingparametertininputlayers.h"
28+
%End
29+
public:
30+
31+
enum Type
32+
{
33+
Vertices,
34+
StructureLines,
35+
BreakLines
36+
};
37+
38+
struct InputLayer
39+
{
40+
QString source; //!The source of the input layer
41+
Type type; //!The type of the input layer (see Type)
42+
int attributeIndex; //! The attribute index used for Z value of vertices
43+
};
44+
45+
QgsProcessingParameterTinInputLayers( const QString &name, const QString &description = QString() );
46+
%Docstring
47+
Constructor
48+
%End
49+
50+
virtual QgsProcessingParameterDefinition *clone() const;
51+
52+
virtual QString type() const;
53+
54+
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;
55+
56+
virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;
57+
58+
virtual QString asPythonString( QgsProcessing::PythonOutputType outputType = QgsProcessing::PythonQgsProcessingAlgorithmSubclass ) const;
59+
60+
61+
static QString typeName();
62+
%Docstring
63+
Returns the type name for the parameter class.
64+
%End
65+
};
66+
67+
class QgsProcessingParameterTypeTinInputLayers : QgsProcessingParameterType
68+
{
69+
%Docstring
70+
Parameter type definition for QgsProcessingParameterTinInputLayers.
71+
72+
.. versionadded:: 3.16
73+
%End
74+
75+
%TypeHeaderCode
76+
#include "qgsprocessingparametertininputlayers.h"
77+
%End
78+
public:
79+
virtual QgsProcessingParameterDefinition *create( const QString &name ) const /Factory/;
80+
81+
virtual QString description() const;
82+
83+
virtual QString name() const;
84+
85+
virtual QString id() const;
86+
87+
virtual QString pythonImportString() const;
88+
89+
virtual QString className() const;
90+
91+
virtual QStringList acceptedPythonTypes() const;
92+
};
93+
94+
/************************************************************************
95+
* This file has been generated automatically from *
96+
* *
97+
* src/core/processing/qgsprocessingparametertininputlayers.h *
98+
* *
99+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
100+
************************************************************************/

‎python/core/auto_generated/qgsprovidermetadata.sip.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Holds metadata about mesh driver
3434
CanWriteFaceDatasets,
3535
CanWriteVertexDatasets,
3636
CanWriteEdgeDatasets,
37+
CanWriteMeshData,
3738
};
3839

3940
typedef QFlags<QgsMeshDriverMetadata::MeshDriverCapability> MeshDriverCapabilities;
@@ -225,6 +226,17 @@ eg. "yes" value will be returned as true, 0 will be returned as false
225226
Creates a new instance of the raster data provider.
226227

227228
.. versionadded:: 3.10
229+
%End
230+
231+
virtual bool createMeshData(
232+
const QgsMesh &mesh,
233+
const QString uri,
234+
const QString &driverName,
235+
const QgsCoordinateReferenceSystem &crs ) const;
236+
%Docstring
237+
Creates mesh data source, that is the mesh frame stored in file, memory or with other way (depending of the provider)
238+
239+
.. versionadded:: 3.16
228240
%End
229241

230242
virtual QList<QPair<QString, QString> > pyramidResamplingMethods();

‎python/core/core_auto.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@
469469
%Include auto_generated/processing/qgsprocessingparameteraggregate.sip
470470
%Include auto_generated/processing/qgsprocessingparameterfieldmap.sip
471471
%Include auto_generated/processing/qgsprocessingparameters.sip
472+
%Include auto_generated/processing/qgsprocessingparametertininputlayers.sip
472473
%Include auto_generated/processing/qgsprocessingparametertype.sip
473474
%Include auto_generated/processing/qgsprocessingparametervectortilewriterlayers.sip
474475
%Include auto_generated/processing/qgsprocessingprovider.sip

‎python/plugins/processing/gui/Postprocessing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def handleAlgorithmResults(alg, context, feedback=None, showResults=True, parame
8383
if style is None:
8484
if layer.type() == QgsMapLayerType.RasterLayer:
8585
style = ProcessingConfig.getSetting(ProcessingConfig.RASTER_STYLE)
86-
else:
86+
elif layer.type() == QgsMapLayerType.VectorLayer:
8787
if layer.geometryType() == QgsWkbTypes.PointGeometry:
8888
style = ProcessingConfig.getSetting(ProcessingConfig.VECTOR_POINT_STYLE)
8989
elif layer.geometryType() == QgsWkbTypes.LineGeometry:

‎src/analysis/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ SET(QGIS_ANALYSIS_SRCS
186186
processing/qgsalgorithmsumlinelength.cpp
187187
processing/qgsalgorithmsymmetricaldifference.cpp
188188
processing/qgsalgorithmtaperedbuffer.cpp
189+
processing/qgsalgorithmtinmeshcreation.cpp
189190
processing/qgsalgorithmtransect.cpp
190191
processing/qgsalgorithmtransform.cpp
191192
processing/qgsalgorithmtranslate.cpp
@@ -228,6 +229,7 @@ SET(QGIS_ANALYSIS_SRCS
228229
vector/qgszonalstatistics.cpp
229230

230231
mesh/qgsmeshcontours.cpp
232+
mesh/qgsmeshtriangulation.cpp
231233

232234
network/qgsgraph.cpp
233235
network/qgsgraphbuilder.cpp
@@ -295,6 +297,7 @@ SET(QGIS_ANALYSIS_HDRS
295297
interpolation/qgstininterpolator.h
296298

297299
mesh/qgsmeshcontours.h
300+
mesh/qgsmeshtriangulation.h
298301

299302
network/qgsgraph.h
300303
network/qgsgraphanalyzer.h

‎src/analysis/interpolation/NormVecDecorator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,12 @@ bool NormVecDecorator::saveTriangulation( QgsFeatureSink *sink, QgsFeedback *fee
577577
return mTIN->saveTriangulation( sink, feedback );
578578
}
579579

580-
QgsMesh NormVecDecorator::triangulationToMesh() const
580+
QgsMesh NormVecDecorator::triangulationToMesh( QgsFeedback *feedback ) const
581581
{
582582
if ( !mTIN )
583583
{
584584
return QgsMesh();
585585
}
586-
return mTIN->triangulationToMesh();
586+
return mTIN->triangulationToMesh( feedback );
587587
}
588588

‎src/analysis/interpolation/NormVecDecorator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ANALYSIS_EXPORT NormVecDecorator: public TriDecorator
6969

7070
bool saveTriangulation( QgsFeatureSink *sink, QgsFeedback *feedback = nullptr ) const override;
7171

72-
QgsMesh triangulationToMesh() const override;
72+
QgsMesh triangulationToMesh( QgsFeedback *feedback = nullptr ) const override;
7373

7474
protected:
7575
//! Is TRUE, if the normals already have been estimated

‎src/analysis/interpolation/qgsdualedgetriangulation.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,10 @@ int QgsDualEdgeTriangulation::addPoint( const QgsPoint &p )
266266
//edges to modify
267267
int edgeFromVirtualToExtremeSide1 = mHalfEdge[mHalfEdge[closestEdge]->getNext()]->getDual();
268268
int edgeFromVirtualToExtremeSide2 = mHalfEdge[mHalfEdge[mHalfEdge[closestEdge]->getDual()]->getNext()]->getNext();
269-
int edgeFromeExtremeToVirtualSide2 = mHalfEdge[edgeFromVirtualToExtremeSide2]->getDual();
269+
int edgeFromExtremeToVirtualSide2 = mHalfEdge[edgeFromVirtualToExtremeSide2]->getDual();
270270
//insert new edge
271271
int edgeFromExtremeToNewPoint = insertEdge( -10, -10, newPoint, false, false );
272-
int edgeFromNewPointToExtrem = insertEdge( edgeFromExtremeToNewPoint, edgeFromeExtremeToVirtualSide2, extremPoint, false, false );
272+
int edgeFromNewPointToExtrem = insertEdge( edgeFromExtremeToNewPoint, edgeFromExtremeToVirtualSide2, extremPoint, false, false );
273273
int edgeFromNewPointToVirtualSide1 = insertEdge( -10, edgeFromVirtualToExtremeSide1, -1, false, false );
274274
int edgeFromVirtualToNewPointSide1 = insertEdge( edgeFromNewPointToVirtualSide1, -10, newPoint, false, false );
275275
int edgeFromNewPointToVirtualSide2 = insertEdge( -10, edgeFromVirtualToNewPointSide1, -1, false, false );
@@ -282,7 +282,7 @@ int QgsDualEdgeTriangulation::addPoint( const QgsPoint &p )
282282
//modify existing edges
283283
mHalfEdge.at( edgeFromVirtualToExtremeSide1 )->setNext( edgeFromExtremeToNewPoint );
284284
mHalfEdge.at( edgeFromVirtualToExtremeSide2 )->setNext( edgeFromExtremeToOpposite );
285-
mHalfEdge.at( edgeFromeExtremeToVirtualSide2 )->setNext( edgeFromVirtualToNewPointSide2 );
285+
mHalfEdge.at( edgeFromExtremeToVirtualSide2 )->setNext( edgeFromVirtualToNewPointSide2 );
286286

287287
return newPoint;
288288
}
@@ -3167,7 +3167,7 @@ bool QgsDualEdgeTriangulation::saveTriangulation( QgsFeatureSink *sink, QgsFeedb
31673167
return !feedback || !feedback->isCanceled();
31683168
}
31693169

3170-
QgsMesh QgsDualEdgeTriangulation::triangulationToMesh() const
3170+
QgsMesh QgsDualEdgeTriangulation::triangulationToMesh( QgsFeedback *feedBack ) const
31713171
{
31723172
QVector<bool> alreadyVisitedEdges( mHalfEdge.count(), false );
31733173

@@ -3199,7 +3199,7 @@ QgsMesh QgsDualEdgeTriangulation::triangulationToMesh() const
31993199
containVirtualPoint |= currentEdge->getPoint() == -1;
32003200
currentEdge = mHalfEdge.at( currentEdge->getNext() );
32013201
}
3202-
while ( currentEdge != firstEdge && !containVirtualPoint );
3202+
while ( currentEdge != firstEdge && !containVirtualPoint && ( !feedBack || !feedBack->isCanceled() ) );
32033203
if ( !containVirtualPoint )
32043204
mesh.faces.append( face );
32053205
}

0 commit comments

Comments
 (0)
Please sign in to comment.