示例#1
0
        private IEnumerable <Segment> ProcessPointInFunnel(Poped poped)
        {
            // report all diagonals and remove points
            var diagonals = new List <Segment>();

            var stop = false;

            do
            {
                var middle = _stack.Pop();
                var first  = _stack.Pop();

                var candidate      = new Segment(poped.Point, first);
                var middlePosition = candidate.PositionOf(middle);

                if (middlePosition == poped.Branch)
                {
                    diagonals.Add(candidate);
                    _stack.Push(first);
                    // middle point omitted intetionaly
                }
                else
                {
                    _stack.Push(first);
                    _stack.Push(middle);
                    stop = true;
                }
            } while (!stop && _stack.Count > 1);

            _stack.Push(poped.Point);
            return(diagonals);
        }
示例#2
0
        private IEnumerable <Segment> ProcessPointOppositeToFunnel(Poped poped)
        {
            var diagonals = new List <Segment>();

            var lastFunnelPoint = _stack.Pop();

            diagonals.Add(new Segment(poped.Point, lastFunnelPoint));
            while (_stack.Count > 0)
            {
                var p = _stack.Pop();
                if (_stack.Count > 0) // ignore last point - it is neighbour or the diagonal has already been reported
                {
                    diagonals.Add(new Segment(poped.Point, p));
                }
            }

            _stack.Push(lastFunnelPoint);
            _stack.Push(poped.Point);

            return(diagonals);
        }