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) + }; + } + } +}