public void Empty() { var search = new SubdivisionSearch(new Subdivision()); search.Validate(); for (int i = 0; i < 10; i++) { PointD q = GeoAlgorithms.RandomPoint(-100, -100, 200, 200); Assert.IsTrue(search.Find(q).IsUnboundedFace); Assert.IsTrue(search.Source.Find(q).IsUnboundedFace); } }
private SubdivisionSearch CheckSearch(params LineD[] lines) { Subdivision division = Subdivision.FromLines(lines); division.Validate(); SubdivisionSearch search = new SubdivisionSearch(division); search.Validate(); CheckVertices(search); CheckEdges(search); PointD[] points = new[] { new PointD(+1, +1), new PointD(+1, -1), new PointD(-1, +1), new PointD(-1, -1) }; if (division.Faces.Count == 1) { foreach (PointD point in points) { Assert.IsTrue(search.Find(point).IsUnboundedFace); Assert.IsTrue(division.Find(point).IsUnboundedFace); } } else { var element = new SubdivisionElement(division.Faces[1]); foreach (PointD point in points) { Assert.AreEqual(element, search.Find(point)); Assert.AreEqual(element, division.Find(point)); } } points = new[] { new PointD(+10, +10), new PointD(+10, -10), new PointD(-10, +10), new PointD(-10, -10) }; foreach (PointD point in points) { Assert.IsTrue(search.Find(point).IsUnboundedFace); Assert.IsTrue(division.Find(point).IsUnboundedFace); } return(search); }
private SubdivisionSearch CheckSearch(Subdivision division) { division.Validate(); SubdivisionSearch search = new SubdivisionSearch(division); search.Validate(); CheckVertices(search); CheckEdges(search); foreach (SubdivisionFace face in division.Faces.Values) { if (face.OuterEdge == null) { continue; } PointD centroid = face.OuterEdge.CycleCentroid; var element = new SubdivisionElement(face); Assert.AreEqual(element, search.Find(centroid)); Assert.AreEqual(element, division.Find(centroid)); } return(search); }