Skip to content

Commit

Permalink
Update Voronoi tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
wo80 committed Jan 8, 2024
1 parent b35680e commit 3654aeb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Triangle.Tests/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public static Polygon SplitRectangle(double left, double top,
poly.Add(new Contour(points, mark, true));
poly.Add(new Segment(midTop, midBottom));

poly.Regions.Add(new RegionPointer(left + midX / 2, bottom + midY / 2, 1));
poly.Regions.Add(new RegionPointer(right - midX / 2, bottom + midY / 2, 2));
poly.Regions.Add(new RegionPointer(left + midX / 2, bottom + midY, 1));
poly.Regions.Add(new RegionPointer(right - midX / 2, bottom + midY, 2));

return poly;
}
Expand Down
6 changes: 6 additions & 0 deletions src/Triangle.Tests/Voronoi/BoundedVoronoiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ public void TestBoundedVoronoi()
// 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));

// All Voronoi cells should have a generator vertex.
Assert.That(voronoi.Faces.All(f => f.Generator is not null));

// Check DCEL topology (all Voronoi cells should be closed).
Assert.That(voronoi.IsConsistent());
}
}
}
6 changes: 6 additions & 0 deletions src/Triangle.Tests/Voronoi/StandardVoronoiTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ public void TestStandardVoronoi()
// 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));

// All Voronoi cells should have a generator vertex.
Assert.That(voronoi.Faces.All(f => f.Generator is not null));

// Check DCEL topology (account for unbounded Voronoi cells).
Assert.That(voronoi.IsConsistent(false));
}
}
}

0 comments on commit 3654aeb

Please sign in to comment.