using System; namespace GisSharpBlog.NetTopologySuite.GeometriesGraph.Index { /// /// /// public class SweepLineEvent : IComparable { /// /// /// public const int Insert = 1; /// /// /// public const int Delete = 2; private object edgeSet; // used for red-blue intersection detection private double xValue; private int eventType; private SweepLineEvent insertEvent; // null if this is an Insert event private int deleteEventIndex; private object obj; /// /// /// /// /// /// /// public SweepLineEvent(object edgeSet, double x, SweepLineEvent insertEvent, object obj) { this.edgeSet = edgeSet; xValue = x; this.insertEvent = insertEvent; this.eventType = Insert; if (insertEvent != null) eventType = Delete; this.obj = obj; } /// /// /// public object EdgeSet { get { return this.edgeSet; } set { this.edgeSet = value; } } /// /// /// public bool IsInsert { get { return insertEvent == null; } } /// /// /// public bool IsDelete { get { return insertEvent != null; } } /// /// /// public SweepLineEvent InsertEvent { get { return insertEvent; } } /// /// /// public int DeleteEventIndex { get { return deleteEventIndex; } set { this.deleteEventIndex = value; } } /// /// /// public object Object { get { return obj; } } /// /// 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; } } }