private static bool Legalize(DTSweepContext tcx, DelaunayTriangle t) { bool result; for (int i = 0; i < 3; i++) { bool flag = t.EdgeIsDelaunay[i]; if (!flag) { DelaunayTriangle delaunayTriangle = t.Neighbors[i]; bool flag2 = delaunayTriangle != null; if (flag2) { TriangulationPoint triangulationPoint = t.Points[i]; TriangulationPoint triangulationPoint2 = delaunayTriangle.OppositePoint(t, triangulationPoint); int index = delaunayTriangle.IndexOf(triangulationPoint2); bool flag3 = delaunayTriangle.EdgeIsConstrained[index] || delaunayTriangle.EdgeIsDelaunay[index]; if (flag3) { t.EdgeIsConstrained[i] = delaunayTriangle.EdgeIsConstrained[index]; } else { bool flag4 = TriangulationUtil.SmartIncircle(triangulationPoint, t.PointCCW(triangulationPoint), t.PointCW(triangulationPoint), triangulationPoint2); bool flag5 = flag4; if (flag5) { t.EdgeIsDelaunay[i] = true; delaunayTriangle.EdgeIsDelaunay[index] = true; DTSweep.RotateTrianglePair(t, triangulationPoint, delaunayTriangle, triangulationPoint2); bool flag6 = !DTSweep.Legalize(tcx, t); bool flag7 = flag6; if (flag7) { tcx.MapTriangleToNodes(t); } flag6 = !DTSweep.Legalize(tcx, delaunayTriangle); bool flag8 = flag6; if (flag8) { tcx.MapTriangleToNodes(delaunayTriangle); } t.EdgeIsDelaunay[i] = false; delaunayTriangle.EdgeIsDelaunay[index] = false; result = true; return(result); } } } } } result = false; return(result); }
private static void Fill(DTSweepContext tcx, AdvancingFrontNode node) { DelaunayTriangle delaunayTriangle = new DelaunayTriangle(node.Prev.Point, node.Point, node.Next.Point); delaunayTriangle.MarkNeighbor(node.Prev.Triangle); delaunayTriangle.MarkNeighbor(node.Triangle); tcx.Triangles.Add(delaunayTriangle); node.Prev.Next = node.Next; node.Next.Prev = node.Prev; tcx.RemoveNode(node); bool flag = !DTSweep.Legalize(tcx, delaunayTriangle); if (flag) { tcx.MapTriangleToNodes(delaunayTriangle); } }
private static AdvancingFrontNode NewFrontTriangle(DTSweepContext tcx, TriangulationPoint point, AdvancingFrontNode node) { DelaunayTriangle delaunayTriangle = new DelaunayTriangle(point, node.Point, node.Next.Point); delaunayTriangle.MarkNeighbor(node.Triangle); tcx.Triangles.Add(delaunayTriangle); AdvancingFrontNode advancingFrontNode = new AdvancingFrontNode(point); advancingFrontNode.Next = node.Next; advancingFrontNode.Prev = node; node.Next.Prev = advancingFrontNode; node.Next = advancingFrontNode; tcx.AddNode(advancingFrontNode); bool flag = !DTSweep.Legalize(tcx, delaunayTriangle); if (flag) { tcx.MapTriangleToNodes(delaunayTriangle); } return(advancingFrontNode); }
private static DelaunayTriangle NextFlipTriangle(DTSweepContext tcx, Orientation o, DelaunayTriangle t, DelaunayTriangle ot, TriangulationPoint p, TriangulationPoint op) { bool flag = o == Orientation.CCW; DelaunayTriangle result; if (flag) { int index = ot.EdgeIndex(p, op); ot.EdgeIsDelaunay[index] = true; DTSweep.Legalize(tcx, ot); ot.EdgeIsDelaunay.Clear(); result = t; } else { int index = t.EdgeIndex(p, op); t.EdgeIsDelaunay[index] = true; DTSweep.Legalize(tcx, t); t.EdgeIsDelaunay.Clear(); result = ot; } return(result); }
private static void FlipEdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle t, TriangulationPoint p) { DelaunayTriangle delaunayTriangle = t.NeighborAcross(p); TriangulationPoint triangulationPoint = delaunayTriangle.OppositePoint(t, p); bool flag = delaunayTriangle == null; if (flag) { throw new InvalidOperationException("[BUG:FIXME] FLIP failed due to missing triangle"); } bool constrainedEdgeAcross = t.GetConstrainedEdgeAcross(p); if (constrainedEdgeAcross) { throw new Exception("Intersecting Constraints"); } bool flag2 = TriangulationUtil.InScanArea(p, t.PointCCW(p), t.PointCW(p), triangulationPoint); bool flag3 = flag2; if (flag3) { DTSweep.RotateTrianglePair(t, p, delaunayTriangle, triangulationPoint); tcx.MapTriangleToNodes(t); tcx.MapTriangleToNodes(delaunayTriangle); bool flag4 = p == eq && triangulationPoint == ep; if (flag4) { bool flag5 = eq == tcx.EdgeEvent.ConstrainedEdge.Q && ep == tcx.EdgeEvent.ConstrainedEdge.P; if (flag5) { bool isDebugEnabled = tcx.IsDebugEnabled; if (isDebugEnabled) { Console.WriteLine("[FLIP] - constrained edge done"); } t.MarkConstrainedEdge(ep, eq); delaunayTriangle.MarkConstrainedEdge(ep, eq); DTSweep.Legalize(tcx, t); DTSweep.Legalize(tcx, delaunayTriangle); } else { bool isDebugEnabled2 = tcx.IsDebugEnabled; if (isDebugEnabled2) { Console.WriteLine("[FLIP] - subedge done"); } } } else { bool isDebugEnabled3 = tcx.IsDebugEnabled; if (isDebugEnabled3) { Console.WriteLine("[FLIP] - flipping and continuing with triangle still crossing edge"); } Orientation o = TriangulationUtil.Orient2d(eq, triangulationPoint, ep); t = DTSweep.NextFlipTriangle(tcx, o, t, delaunayTriangle, p, triangulationPoint); DTSweep.FlipEdgeEvent(tcx, ep, eq, t, p); } } else { TriangulationPoint p2 = DTSweep.NextFlipPoint(ep, eq, delaunayTriangle, triangulationPoint); DTSweep.FlipScanEdgeEvent(tcx, ep, eq, t, delaunayTriangle, p2); DTSweep.EdgeEvent(tcx, ep, eq, t, p); } }