public void TestFindCircleEventAbove() { var beachLine = new BeachLine(0); var site1 = new Point { X = 130, Y = 160 }; var site2 = new Point { X = 110, Y = 150 }; var site3 = new Point { X = 170, Y = 140 }; var site4 = new Point { X = 140, Y = 120 }; beachLine.InsertSite(site1); //beachLine.GenerateCircleEvent(site1); beachLine.InsertSite(site2); //beachLine.GenerateCircleEvent(site2); var insert = beachLine.InsertSite(site3); var circleEvents = beachLine.GenerateCircleEvent(insert.Leaves, site3.Y); var result = beachLine.FindCircleEventAbove(site4); Assert.IsNotNull(result); Assert.AreEqual(circleEvents.Single().Point, result.Point); }
public ICollection <IGeometry> HandleEvent(SiteEvent sweepEvent, EventQueue eventQueue, BeachLine beachLine) { var circleEvent = beachLine.FindCircleEventAbove(sweepEvent.Point); if (circleEvent != null) { Logger.Instance.Log($"SiteEvent: {sweepEvent.Point.ToString()}: Remove CircleEvent {circleEvent.Point} from queue."); eventQueue.Remove(circleEvent); } Logger.Instance.Log($"SiteEvent: {sweepEvent.Point.ToString()}: Insert site into beach line"); var result = beachLine.InsertSite(sweepEvent.Point); var circleEvents = beachLine.GenerateCircleEvent(result?.Leaves, sweepEvent.Point.Y); eventQueue.Insert(circleEvents); if (result != null) { return new List <IGeometry> { result.HalfEdge } } ; return(new List <IGeometry>()); } }