@@ -36,6 +36,7 @@ class TestQgsTriangulation : public QObject
36
36
void dualEdge ();
37
37
38
38
void meshTriangulation ();
39
+ void meshTriangulationWithOnlyBreakLine ();
39
40
40
41
private:
41
42
};
@@ -239,5 +240,57 @@ void TestQgsTriangulation::meshTriangulation()
239
240
QVERIFY ( QgsMesh::compareFaces ( mesh.face ( 5 ), QgsMeshFace ( {2 , 4 , 3 } ) ) );
240
241
}
241
242
243
+ void TestQgsTriangulation::meshTriangulationWithOnlyBreakLine ()
244
+ {
245
+ QgsMeshTriangulation meshTri;
246
+
247
+ QgsVectorLayer *mLayerLineZ = new QgsVectorLayer ( QStringLiteral ( " LineStringZ" ),
248
+ QStringLiteral ( " break line Z" ),
249
+ QStringLiteral ( " memory" ) );
250
+
251
+ QStringList wktLines;
252
+
253
+ wktLines << QStringLiteral ( " LineStringZ (315377.05605000001378357 5839566.94189499784260988 24.94718200000000152, 315374.77223399997455999 5839565.11973000038415194 24.04360499999999945)" )
254
+ << QStringLiteral ( " LineStringZ (315369.53268400009255856 5839567.42751600034534931 25.41215299999999999, 315369.31927300000097603 5839570.36336500104516745 25.47851700000000008)" )
255
+ << QStringLiteral ( " LineStringZ (315369.31927300000097603 5839570.36336500104516745 25.47851700000000008, 315377.62744900002144277 5839568.60983499884605408 24.98952099999999987)" )
256
+ << QStringLiteral ( " LineStringZ (315369.53268400009255856 5839567.42751600034534931 25.41215299999999999, 315377.05605000001378357 5839566.94189499784260988 24.94718200000000152)" )
257
+ << QStringLiteral ( " LineStringZ (315374.77223399997455999 5839565.11973000038415194 24.04360499999999945, 315370.67597402411047369 5839565.22503056097775698 24.04360499999999945)" )
258
+ << QStringLiteral ( " LineStringZ (315370.67597402411047369 5839565.22503056097775698 24.04360499999999945, 315369.53268400009255856 5839567.42751600034534931 25.41215299999999999)" )
259
+ << QStringLiteral ( " LineStringZ (315369.31927300000097603 5839570.36336500104516745 25.47851700000000008, 315371.93385799997486174 5839571.38528699986636639 24.06699300000000008)" )
260
+ << QStringLiteral ( " LineStringZ (315371.93385799997486174 5839571.38528699986636639 24.06699300000000008, 315376.77400700020371005 5839570.69979299977421761 24.0794150000000009)" )
261
+ << QStringLiteral ( " LineStringZ (315376.77400700020371005 5839570.69979299977421761 24.0794150000000009, 315377.62744900002144277 5839568.60983499884605408 24.98952099999999987)" )
262
+ << QStringLiteral ( " LineStringZ (315377.62744900002144277 5839568.60983499884605408 24.98952099999999987, 315377.05605000001378357 5839566.94189499784260988 24.94718200000000152)" );
263
+
264
+ QgsFeatureList flist;
265
+ for ( const QString &wkt : wktLines )
266
+ {
267
+ QgsFeature feat;
268
+ feat.setGeometry ( QgsGeometry::fromWkt ( wkt ) );
269
+ flist << feat;
270
+ }
271
+
272
+ mLayerLineZ ->dataProvider ()->addFeatures ( flist );
273
+
274
+ QgsCoordinateTransformContext transformContext;
275
+ QgsCoordinateTransform transform ( mLayerLineZ ->crs (),
276
+ QgsCoordinateReferenceSystem (),
277
+ transformContext );
278
+
279
+ QgsFeatureIterator fIt = mLayerLineZ ->getFeatures ();
280
+ meshTri.addBreakLines ( fIt , -1 , transform );
281
+
282
+ QgsMesh mesh = meshTri.triangulatedMesh ();
283
+
284
+ QCOMPARE ( mesh.vertexCount (), 8 );
285
+ QCOMPARE ( mesh.faceCount (), 6 );
286
+
287
+ QVERIFY ( QgsMesh::compareFaces ( mesh.face ( 0 ), QgsMeshFace ( {2 , 0 , 4 } ) ) );
288
+ QVERIFY ( QgsMesh::compareFaces ( mesh.face ( 1 ), QgsMeshFace ( {0 , 2 , 1 } ) ) );
289
+ QVERIFY ( QgsMesh::compareFaces ( mesh.face ( 2 ), QgsMeshFace ( {1 , 2 , 5 } ) ) );
290
+ QVERIFY ( QgsMesh::compareFaces ( mesh.face ( 3 ), QgsMeshFace ( {2 , 4 , 3 } ) ) );
291
+ QVERIFY ( QgsMesh::compareFaces ( mesh.face ( 4 ), QgsMeshFace ( {4 , 6 , 3 } ) ) );
292
+ QVERIFY ( QgsMesh::compareFaces ( mesh.face ( 5 ), QgsMeshFace ( {4 , 7 , 6 } ) ) );
293
+ }
294
+
242
295
QGSTEST_MAIN ( TestQgsTriangulation )
243
296
#include " testqgstriangulation.moc"
0 commit comments