private static void FillLeftAboveEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node) { while (node.Prev.Point.X > edge.P.X) { // Check if next node is below the edge Orientation o1 = TriangulationUtil.Orient2D(edge.Q, node.Prev.Point, edge.P); if (o1 == Orientation.CW) { FillLeftBelowEdgeEvent(tcx, edge, node); } else { node = node.Prev; } } }
private static void FillLeftBelowEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node) { if (node.Point.X > edge.P.X) { if (TriangulationUtil.Orient2D(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.CW) { // Concave FillLeftConcaveEdgeEvent(tcx, edge, node); } else { // Convex FillLeftConvexEdgeEvent(tcx, edge, node); // Retry this one FillLeftBelowEdgeEvent(tcx, edge, node); } } }
private static void FillRightConvexEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node) { // Next concave or convex? if (TriangulationUtil.Orient2D(node.Next.Point, node.Next.Next.Point, node.Next.Next.Next.Point) == Orientation.CCW) { // Concave FillRightConcaveEdgeEvent(tcx, edge, node.Next); } else { // Convex // Next above or below edge? if (TriangulationUtil.Orient2D(edge.Q, node.Next.Next.Point, edge.P) == Orientation.CCW) { // Below FillRightConvexEdgeEvent(tcx, edge, node.Next); } else { // Above } } }
private static void FillLeftConcaveEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node) { Fill(tcx, node.Prev); if (node.Prev.Point != edge.P) { // Next above or below edge? if (TriangulationUtil.Orient2D(edge.Q, node.Prev.Point, edge.P) == Orientation.CW) { // Below if (TriangulationUtil.Orient2D(node.Point, node.Prev.Point, node.Prev.Prev.Point) == Orientation.CW) { // Next is concave FillLeftConcaveEdgeEvent(tcx, edge, node); } else { // Next is convex } } } }
private static void FillEdgeEvent(DTSweepContext tcx, DTSweepConstraint edge, AdvancingFrontNode node) { if (tcx.EdgeEvent.Right) { FillRightAboveEdgeEvent(tcx, edge, node); } else { FillLeftAboveEdgeEvent(tcx, edge, node); } }