Exemplo n.º 1
0
        public void CanComputeDelaunay()
        {
            var maxX   = 100;
            var maxY   = 100;
            var point0 = new DelaunayPoint(0, 0);
            var point1 = new DelaunayPoint(0, maxY);
            var point2 = new DelaunayPoint(maxX, maxY);
            var point3 = new DelaunayPoint(maxX, 0);
            var point4 = new DelaunayPoint(maxX / 2.0, maxY / 2.0);

            var triangle1 = new DelaunayTriangle(point0, point1, point2);
            var triangle2 = new DelaunayTriangle(point0, point2, point3);
            var border    = new List <DelaunayTriangle> {
                triangle1, triangle2
            };

            var delaunay = Delaunay.Compute(
                new List <DelaunayPoint>
            {
                point0, point1, point2, point3, point4
            },
                border
                )
                           .ToList();

            Assert.True(delaunay.Count == 4);

            var voronoi = Delaunay.Voronoi(delaunay);

            // TODO: We expect 8 because it currently outputs the lines repeated twice.
            Assert.True(voronoi.ToList().Count == 8);
        }