Esempio n. 1
0
        public void GrahamScan(PdfPoint[] points, PdfPoint[] expected)
        {
            expected = expected.OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();
            var convexHull = GeometryExtensions.GrahamScan(points).OrderBy(p => p.X).ThenBy(p => p.Y).ToArray();

            for (var i = 0; i < expected.Length; i++)
            {
                Assert.Equal(expected[i], convexHull[i], PointComparer);
            }
        }
Esempio n. 2
0
        public void Issue458(PdfPoint[] points, PdfPoint[] expected)
        {
            /*
             * https://github.com/UglyToad/PdfPig/issues/458
             * An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in System.Linq.dll: 'Specified argument was out of the range of valid values.'
             *  at System.Linq.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
             *  at System.Linq.Enumerable.ElementAt[TSource](IEnumerable`1 source, Int32 index)
             */

            var result = GeometryExtensions.GrahamScan(points);

            // Data is noisy so we just check it does not throw an exception
            // and that key points are present (other points might be present,
            // e.g. 'not enough equal dupplicates' or 'not collinear enough' points)
            foreach (var point in expected)
            {
                Assert.Contains(point, result);
            }
        }