//var max = Math.max; //var min = Math.min; /** * @param {Array<Number>} s1 * @param {Array<Number>} s2 * @param {Boolean} isSubject * @param {Queue} eventQueue * @param {Array<Number>} bbox */ internal static void processSegment(Point s1, Point s2, bool isSubject, int depth, TinyQueue eventQueue, double[] bbox, bool isExteriorRing) { // Possible degenerate condition. // if (equals(s1, s2)) return; var e1 = new SweepEvent(s1, false, null, isSubject); var e2 = new SweepEvent(s2, false, e1, isSubject); e1.otherEvent = e2; e1.contourId = e2.contourId = depth; if (!isExteriorRing) { e1.isExteriorRing = false; e2.isExteriorRing = false; } if (compareEvents(e1, e2) > 0) { e2.left = true; } else { e1.left = true; } bbox[0] = Math.Min(bbox[0], s1.X); bbox[1] = Math.Min(bbox[1], s1.Y); bbox[2] = Math.Max(bbox[2], s1.X); bbox[3] = Math.Max(bbox[3], s1.Y); // Pushing it so the queue is sorted from left to right, with object on the left having the highest priority. eventQueue.push(e1); eventQueue.push(e2); }
internal static TinyQueue divideSegment(SweepEvent se, Point p, TinyQueue queue) { var r = new SweepEvent(p, false, se, se.isSubject); var l = new SweepEvent(p, true, se.otherEvent, se.isSubject); if (equals(se.point, se.otherEvent.point)) { MessageBox.Show("what is that?" + se.ToString()); } r.contourId = l.contourId = se.contourId; // avoid a rounding error. The left _event would be processed after the right _event if (compareEvents(l, se.otherEvent) > 0) { se.otherEvent.left = true; l.left = false; } // avoid a rounding error. The left _event would be processed after the right _event // if (compareEvents(se, r) > 0) {} se.otherEvent.otherEvent = l; se.otherEvent = r; queue.push(l); queue.push(r); return(queue); }