using System; namespace GisSharpBlog.NetTopologySuite.GeometriesGraph.Index { /// /// /// public class SweepLineEvent : IComparable { /// /// /// public const int Insert = 1; /// /// /// public const int Delete = 2; private readonly double xValue; private readonly int eventType; /// /// /// /// /// /// /// public SweepLineEvent(object edgeSet, double x, SweepLineEvent insertEvent, object obj) { EdgeSet = edgeSet; xValue = x; InsertEvent = insertEvent; eventType = Insert; if (insertEvent != null) { eventType = Delete; } Object = obj; } /// /// /// public object EdgeSet { get; set; } /// /// /// public bool IsInsert { get { return InsertEvent == null; } } /// /// /// public bool IsDelete { get { return InsertEvent != null; } } /// /// /// public SweepLineEvent InsertEvent { get; private set; } /// /// /// public int DeleteEventIndex { get; set; } /// /// /// public object Object { get; private set; } /// /// ProjectionEvents are ordered first by their x-value, and then by their eventType. /// It is important that Insert events are sorted before Delete events, so that /// items whose Insert and Delete events occur at the same x-value will be /// correctly handled. /// /// public int CompareTo(object o) { SweepLineEvent pe = (SweepLineEvent) o; if (xValue < pe.xValue) { return -1; } if (xValue > pe.xValue) { return 1; } if (eventType < pe.eventType) { return -1; } if (eventType > pe.eventType) { return 1; } return 0; } } }