예제 #1
0
        private void AppendToStart(LineStripElement <T, TK> newElement, TK edge = null)
        {
            if (edge != null)
            {
                Edges.Add(edge);
            }

            if (InternalEquals(Start, newElement.Position))
            {
                return;
            }

            var firstVertex = Elements.First;

            if (edge != null)
            {
                if (firstVertex.Value.Elements.Count == 2)
                {
                    throw new Exception();
                }

                firstVertex.Value.Elements.Add(edge);
            }

            // ReSharper disable once PossibleNullReferenceException
            if (Collinear(
                    newElement.Position,
                    firstVertex.Value.Position,
                    firstVertex.Next.Value.Position))
            {
                firstVertex.Value = newElement;
            }
            else
            {
                Elements.AddFirst(newElement);
            }
        }
예제 #2
0
        public void AppendToEnd(LineStripElement <T, TK> newElement, TK edge = null)
        {
            if (edge != null)
            {
                Edges.Add(edge);
            }

            if (InternalEquals(End, newElement.Position))
            {
                return;
            }

            var lastVertex = Elements.Last;

            if (edge != null)
            {
                if (lastVertex.Value.Elements.Count == 2)
                {
                    throw new Exception();
                }

                lastVertex.Value.Elements.Add(edge);
            }

            // ReSharper disable once PossibleNullReferenceException
            if (Collinear(
                    lastVertex.Previous.Value.Position,
                    lastVertex.Value.Position,
                    newElement.Position))
            {
                lastVertex.Value = newElement;
            }
            else
            {
                Elements.AddLast(newElement);
            }
        }
예제 #3
0
        public void AppendToStart(T vertex, TK edge = null)
        {
            var newElement = new LineStripElement <T, TK>(vertex, edge);

            AppendToStart(newElement, edge);
        }