/// <summary> /// Both edges must be directed from right to left (this is the canonical /// direction for the upper edge of each region). /// /// The strategy is to evaluate a "t" value for each edge at the /// current sweep line position, given by tess->event. The calculations /// are designed to be very stable, but of course they are not perfect. /// /// Special case: if both edge destinations are at the sweep event, /// we sort the edges by slope (they would otherwise compare equally). /// </summary> private bool EdgeLeq(ActiveRegion reg1, ActiveRegion reg2) { MeshUtils.Edge e1 = reg1._eUp; MeshUtils.Edge e2 = reg2._eUp; if (e1._Dst == _event) { if (e2._Dst != _event) { return(Geom.EdgeSign(e2._Dst, _event, e2._Org) <= 0.0f); } // Two edges right of the sweep line which meet at the sweep event. // Sort them by slope. if (Geom.VertLeq(e1._Org, e2._Org)) { return(Geom.EdgeSign(e2._Dst, e1._Org, e2._Org) <= 0.0f); } return(Geom.EdgeSign(e1._Dst, e2._Org, e1._Org) >= 0.0f); } if (e2._Dst == _event) { return(Geom.EdgeSign(e1._Dst, _event, e1._Org) >= 0.0f); } // General case - compute signed distance *from* e1, e2 to event double t1 = Geom.EdgeEval(e1._Dst, _event, e1._Org); double t2 = Geom.EdgeEval(e2._Dst, _event, e2._Org); return(t1 >= t2); }