From bc3b12cdfadd525b284b58baaf294629a4050e9c Mon Sep 17 00:00:00 2001 From: Bert Temme Date: Mon, 3 Oct 2022 14:17:59 +0200 Subject: [PATCH] add cube sample --- README.md | 14 ++++++++++++++ src/triangulator.tests/MultipolygonZTest.cs | 3 ++- src/triangulator.tests/WkbTests.cs | 12 ++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d503fc7..c2bec80 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,20 @@ var triangulatedGeometry = (PolyhedralSurface)Geometry.Deserialize(wkt); @@ -14,6 +14,7 @@ public void TriangulateMulitpolygonZ() var triangulatedPolyhedral = Triangulator.Triangulate(polyhedral); var s = triangulatedPolyhedral.GetBoundingBox(); Assert.IsTrue(triangulatedPolyhedral.Geometries.Count == 86); + GltfCreator.CreateGltf(triangulatedPolyhedral, @"d:\aaa\multipolygonz.gltf"); } } diff --git a/src/triangulator.tests/WkbTests.cs b/src/triangulator.tests/WkbTests.cs index ca84b0d..921c707 100644 --- a/src/triangulator.tests/WkbTests.cs +++ b/src/triangulator.tests/WkbTests.cs @@ -19,5 +19,17 @@ public void TriangulateWkbTest() GltfCreator.CreateGltf(polyhedral, @"wkb.gltf"); } + + + [Test] + public void TraingulateCubeTest() + { + var cubeWkt = "POLYHEDRALSURFACE Z (((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)),((0 0 0, 0 1 0, 0 1 1, 0 0 1, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 1, 1 0 1, 0 0 1, 0 1 1, 1 1 1)),((1 1 1, 1 0 1, 1 0 0, 1 1 0, 1 1 1)),((1 1 1, 1 1 0, 0 1 0, 0 1 1, 1 1 1)))"; + var expectedResult = "POLYHEDRALSURFACE Z (((0 0 0,0 1 0,1 0 0,0 0 0)),((1 1 0,1 0 0,0 1 0,1 1 0)),((0 1 1,0 0 1,0 0 0,0 1 1)),((0 0 0,0 1 0,0 1 1,0 0 0)),((1 0 1,0 0 1,0 0 0,1 0 1)),((0 0 0,1 0 0,1 0 1,0 0 0)),((1 1 1,1 0 1,0 1 1,1 1 1)),((0 0 1,0 1 1,1 0 1,0 0 1)),((1 0 0,1 1 0,1 1 1,1 0 0)),((1 1 1,1 0 1,1 0 0,1 1 1)),((1 1 1,1 1 0,0 1 1,1 1 1)),((0 1 0,0 1 1,1 1 0,0 1 0)))"; + var polyhedralsurface = (PolyhedralSurface)Wkx.Geometry.Deserialize(cubeWkt); + var wkbTriangulated = Triangulator.Triangulate(polyhedralsurface); + var polyhedralsurface_after_wkt = wkbTriangulated.AsText(); + Assert.IsTrue(expectedResult == polyhedralsurface_after_wkt); + } } } \ No newline at end of file