Example #1
0
        public bool HasIntersections()
        {
            while (!events.IsEmpty)
            {
                var currentEvent = events.DeleteMin();

                switch (currentEvent.Type)
                {
                case EventType.SegmentStart:
                    sweepline.Add(currentEvent.Segment);
                    int i = sweepline.IndexOf(currentEvent.Segment);
                    if (i > 0 && currentEvent.Segment.IntersectsWith(sweepline[0]))
                    {
                        return(true);
                    }
                    if (i < sweepline.Count - 1 && currentEvent.Segment.IntersectsWith(sweepline[i + 1]))
                    {
                        return(true);
                    }
                    break;

                case EventType.SegmentEnd:
                    int j = sweepline.IndexOf(currentEvent.Segment);
                    if (j > 0 && j < sweepline.Count - 1 && sweepline[j - 1].IntersectsWith(sweepline[j + 1]))
                    {
                        return(true);
                    }
                    sweepline.Remove(currentEvent.Segment);
                    break;
                }
            }
            return(false);
        }