private static void flipEdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle t, TriangulationPoint p) { TriangulationPoint op, newP; DelaunayTriangle ot; bool _inScanArea; ot = t.neighborAcross(p); op = ot.oppositePoint(t, p); if (ot == null) { // If we want to integrate the fillEdgeEvent do it here // With current implementation we should never get here throw new Exception("[BUG:FIXME] FLIP failed due to missing triangle"); } if (t.getConstrainedEdgeAcross(p)) { throw new Exception("Intersecting Constraints"); } if (tcx.isDebugEnabled()) { tcx.getDebugContext().setPrimaryTriangle(t); tcx.getDebugContext().setSecondaryTriangle(ot); } // TODO: remove _inScanArea = inScanArea(p, t.pointCCW(p), t.pointCW(p), op); if (_inScanArea) { // Lets rotate shared edge one vertex CW rotateTrianglePair(t, p, ot, op); tcx.mapTriangleToNodes(t); tcx.mapTriangleToNodes(ot); if (p == eq && op == ep) { if (eq == tcx.edgeEvent.constrainedEdge.getQ() && ep == tcx.edgeEvent.constrainedEdge.getP()) { if (tcx.isDebugEnabled()) { Console.Out.WriteLine("[FLIP] - constrained edge done"); } // TODO: remove t.markConstrainedEdge(ep, eq); ot.markConstrainedEdge(ep, eq); legalize(tcx, t); legalize(tcx, ot); } else { if (tcx.isDebugEnabled()) { Console.Out.WriteLine("[FLIP] - subedge done"); } // TODO: remove // XXX: I think one of the triangles should be legalized here? } } else { if (tcx.isDebugEnabled()) { Console.Out.WriteLine("[FLIP] - flipping and continuing with triangle still crossing edge"); } // TODO: remove Orientation o = orient2d(eq, op, ep); t = nextFlipTriangle(tcx, o, t, ot, p, op); flipEdgeEvent(tcx, ep, eq, t, p); } } else { newP = nextFlipPoint(ep, eq, ot, op); flipScanEdgeEvent(tcx, ep, eq, t, ot, newP); edgeEvent(tcx, ep, eq, t, p); } }