-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Linq; | ||
using TriangleNet.Meshing; | ||
using TriangleNet.Voronoi; | ||
|
||
namespace TriangleNet.Tests.Voronoi | ||
{ | ||
public class BoundedVoronoiTest | ||
{ | ||
[Test] | ||
public void TestBoundedVoronoi() | ||
{ | ||
var p = Helper.SplitRectangle(-1, 1, 1, -1, 3); | ||
|
||
var mesher = new GenericMesher(); | ||
var mesh = (Mesh)mesher.Triangulate(p); | ||
|
||
var voronoi = new BoundedVoronoi(mesh); | ||
|
||
// The "split rectangle" polygon has two region pointer set. | ||
Assert.That(voronoi.Vertices.Count(v => v.Label == 1), Is.EqualTo(2)); | ||
Assert.That(voronoi.Vertices.Count(v => v.Label == 2), Is.EqualTo(2)); | ||
|
||
// The polygon has 6 boundary segments, so the Voronoi diagram | ||
// should have 6 infinite edges (which are projected onto the | ||
// boundary). Additionally, the 6 boundary vertices are part of | ||
// the Voronoi diagram. | ||
Assert.That(voronoi.Vertices.Count(v => v.Label == 0), Is.EqualTo(12)); | ||
Assert.That(voronoi.Vertices.Count(v => v.ID >= mesh.Triangles.Count), Is.EqualTo(12)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Linq; | ||
using TriangleNet.Meshing; | ||
using TriangleNet.Voronoi; | ||
|
||
namespace TriangleNet.Tests.Voronoi | ||
{ | ||
public class StandardVoronoiTest | ||
{ | ||
[Test] | ||
public void TestStandardVoronoi() | ||
{ | ||
var p = Helper.SplitRectangle(-1, 1, 1, -1, 3); | ||
|
||
var mesher = new GenericMesher(); | ||
var mesh = (Mesh)mesher.Triangulate(p); | ||
|
||
var voronoi = new StandardVoronoi(mesh); | ||
|
||
// The "split rectangle" polygon has two region pointer set. | ||
Assert.That(voronoi.Vertices.Count(v => v.Label == 1), Is.EqualTo(2)); | ||
Assert.That(voronoi.Vertices.Count(v => v.Label == 2), Is.EqualTo(2)); | ||
|
||
// The polygon has 6 boundary segments, so the Voronoi diagram | ||
// should have 6 infinite edges. | ||
Assert.That(voronoi.Vertices.Count(v => v.Label == 0), Is.EqualTo(6)); | ||
Assert.That(voronoi.Vertices.Count(v => v.ID >= mesh.Triangles.Count), Is.EqualTo(6)); | ||
} | ||
} | ||
} |