public void Add(SweepLineInterval sweepInt) { SweepLineEvent insertEvent = new SweepLineEvent(sweepInt.Min, null, sweepInt); _events.Add(insertEvent); _events.Add(new SweepLineEvent(sweepInt.Max, insertEvent, sweepInt)); }
/// <summary> /// Initializes a new instance of the SweepLineEvent class. /// </summary> public SweepLineEvent(double x, SweepLineEvent insertEvent, SweepLineInterval sweepInt) { _xValue = x; _insertEvent = insertEvent; _eventType = INSERT; if (insertEvent != null) { _eventType = DELETE; } _sweepInt = sweepInt; }
} // private void BuildIndex() /// <summary> /// /// </summary> /// <param name="action"></param> public void ComputeOverlaps(ISweepLineOverlapAction action) { _nOverlaps = 0; BuildIndex(); for (int i = 0; i < _events.Count; i++) { SweepLineEvent ev = (SweepLineEvent)_events[i]; SweepLineInterval sweepInt = ev.Interval; if (ev.IsInsert) { ProcessOverlaps(i, ev.DeleteEventIndex, sweepInt, action); } } // for ( int i = 0; i < _events.Count; i++ ) } // public void ComputeOverlaps( SweepLineOverlapAction action )
} // public void ComputeOverlaps( SweepLineOverlapAction action ) private void ProcessOverlaps(int start, int end, SweepLineInterval s0, ISweepLineOverlapAction action) { /** * Since we might need to test for self-intersections, * include current insert event object in list of event objects to test. * Last index can be skipped, because it must be a Delete event. */ for (int i = start; i < end; i++) { SweepLineEvent ev = (SweepLineEvent)_events[i]; if (ev.IsInsert) { SweepLineInterval s1 = ev.Interval; action.Overlap(s0, s1); _nOverlaps++; } } // for ( int i = start; i < end; i++ ) } // private void ProcessOverlaps( int start, int end, SweepLineInterval s0, SweepLineOverlapAction action )