Ejemplo n.º 1
0
        private List <Point> GetVertices(Path path, RenderMode renderMode, ref Rectangle2d rect)
        {
            // do not split path for overview mode
            var  points     = _objectPool.NewList <Point>(path.Count);
            bool isOverview = renderMode == RenderMode.Overview;

            // split path for scene mode
            var lastItemIndex = path.Count - 1;

            for (int i = 0; i <= lastItemIndex; i++)
            {
                var start = path[i];
                var end   = path[i == lastItemIndex ? 0 : i + 1];

                var p1 = new Point(Math.Round(start.X / Scale, MathUtils.RoundDigitCount),
                                   Math.Round(start.Y / Scale, MathUtils.RoundDigitCount));

                var p2 = new Point(Math.Round(end.X / Scale, MathUtils.RoundDigitCount),
                                   Math.Round(end.Y / Scale, MathUtils.RoundDigitCount));

                if (isOverview &&
                    (!rect.IsOnBorder(new Vector2d(p1.X, p1.Y)) ||
                     !rect.IsOnBorder(new Vector2d(p2.X, p2.Y))))
                {
                    points.Add(p1);
                    continue;
                }

                _lineGridSplitter.Split(p1, p2, _objectPool, points);
            }

            return(points);
        }
        public void CanSplit45Angle()
        {
            // ARRANGE
            var start    = new Point(0, 0);
            var end      = new Point(-10, 10);
            var splitter = new LineGridSplitter();
            var result   = new List <Point>();

            // ACT
            splitter.Split(start, end, TestHelper.GetObjectPool(), result);

            // ASSERT
            for (int i = 0; i <= 10; i++)
            {
                Assert.AreEqual(new Point(-i, i), result[i]);
            }
        }