From 2264b4d7fdb0e591aaf19e1697e0d4a72071bc56 Mon Sep 17 00:00:00 2001 From: wo80 Date: Thu, 17 Feb 2022 11:29:36 +0100 Subject: [PATCH] Add more tests (2). --- .../Meshing/Algorithm/TriangulatorTest.cs | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/Triangle.Tests/Meshing/Algorithm/TriangulatorTest.cs diff --git a/src/Triangle.Tests/Meshing/Algorithm/TriangulatorTest.cs b/src/Triangle.Tests/Meshing/Algorithm/TriangulatorTest.cs new file mode 100644 index 0000000..fa7f762 --- /dev/null +++ b/src/Triangle.Tests/Meshing/Algorithm/TriangulatorTest.cs @@ -0,0 +1,72 @@ +using NUnit.Framework; +using System.Collections.Generic; +using System.Linq; +using TriangleNet.Geometry; +using TriangleNet.Meshing.Algorithm; + +namespace TriangleNet.Tests.Meshing.Algorithm +{ + public class TriangulatorTest + { + [Test] + public void TestTriangulateIncremental() + { + var t = new Incremental(); + + var vertices = GetVertices(); + + var mesh = t.Triangulate(vertices, new Configuration()); + + Assert.AreEqual(6, vertices.Count); + Assert.AreEqual(6, mesh.Vertices.Count); + Assert.AreEqual(1, mesh.Vertices + .Where(v => v.Type == VertexType.UndeadVertex) + .Count()); + } + + [Test] + public void TestTriangulateSweepLine() + { + var t = new SweepLine(); + + var vertices = GetVertices(); + + var mesh = t.Triangulate(vertices, new Configuration()); + + Assert.AreEqual(6, vertices.Count); + Assert.AreEqual(6, mesh.Vertices.Count); + Assert.AreEqual(1, mesh.Vertices + .Where(v => v.Type == VertexType.UndeadVertex) + .Count()); + } + + [Test] + public void TestTriangulateDwyer() + { + var t = new Dwyer(); + + var vertices = GetVertices(); + + var mesh = t.Triangulate(vertices, new Configuration()); + + Assert.AreEqual(6, vertices.Count); + Assert.AreEqual(6, mesh.Vertices.Count); + Assert.AreEqual(1, mesh.Vertices + .Where(v => v.Type == VertexType.UndeadVertex) + .Count()); + } + + private List GetVertices() + { + return new List() + { + new Vertex(0.0, 0.0), + new Vertex(1.0, 0.0), + new Vertex(1.0, 1.0), + new Vertex(1.0, 1.0), // duplicate + new Vertex(0.0, 1.0), + new Vertex(0.5, 0.5) + }; + } + } +}