public BentleyOttmann(int precision = 5) { this.precision = precision; pointComparer = new PointComparer(); Tolerance = Math.Round(Math.Pow(0.1, precision), precision); }
private void initialize(IEnumerable <Line> lineSegments) { SweepLine = new Line(new Point(0, 0), new Point(0, int.MaxValue), Tolerance); var pointComparer = new PointComparer(Tolerance); currentlyTracked = new RedBlackTree <Event>(true, pointComparer); intersectionEvents = new Dictionary <Point, HashSet <Tuple <Event, Event> > >(pointComparer); specialLines = new HashSet <Event>(); normalLines = new HashSet <Event>(); rightLeftEventLookUp = lineSegments .Select(x => { return(new KeyValuePair <Event, Event>( new Event(x.Left, EventType.Start, x, this), new Event(x.Right, EventType.End, x, this) )); }).ToDictionary(x => x.Value, x => x.Key); eventQueueLookUp = new HashSet <Event>(rightLeftEventLookUp.SelectMany(x => new[] { x.Key, x.Value }), new PointComparer(Tolerance)); eventQueue = new BMinHeap <Event>(eventQueueLookUp, new EventQueueComparer(Tolerance)); }
internal Event(Point eventPoint, PointComparer pointComparer, EventType eventType, Line lineSegment, BentleyOttmann algorithm) : base(eventPoint.X, eventPoint.Y) { tolerance = algorithm.Tolerance; this.pointComparer = pointComparer; Type = eventType; Segment = lineSegment; Algorithm = algorithm; }