public void MarkNeighbor(DelaunayTriangle t) { bool flag = t.Contains(this.Points[1], this.Points[2]); if (flag) { this.Neighbors[0] = t; t.MarkNeighbor(this.Points[1], this.Points[2], this); } else { bool flag2 = t.Contains(this.Points[0], this.Points[2]); if (flag2) { this.Neighbors[1] = t; t.MarkNeighbor(this.Points[0], this.Points[2], this); } else { bool flag3 = t.Contains(this.Points[0], this.Points[1]); if (flag3) { this.Neighbors[2] = t; t.MarkNeighbor(this.Points[0], this.Points[1], this); } else { Debug.WriteLine("markNeighbor failed"); } } } }
/// <summary> /// Exhaustive search to update neighbor pointers /// </summary> public void MarkNeighbor(DelaunayTriangle t) { if (t.Contains(Points[1], Points[2])) { Neighbors[0] = t; t.MarkNeighbor(Points[1], Points[2], this); } else if (t.Contains(Points[0], Points[2])) { Neighbors[1] = t; t.MarkNeighbor(Points[0], Points[2], this); } else if (t.Contains(Points[0], Points[1])) { Neighbors[2] = t; t.MarkNeighbor(Points[0], Points[1], this); } else { Debug.WriteLine("markNeighbor failed"); } }
private static void EdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point) { if (IsEdgeSideOfTriangle(triangle, ep, eq)) { return; } TriangulationPoint p1 = triangle.PointCCW(point); Orientation o1 = TriangulationUtil.Orient2d(eq, p1, ep); if (o1 == Orientation.Collinear) { if (triangle.Contains(eq, p1)) { triangle.MarkConstrainedEdge(eq, p1); // We are modifying the constraint maybe it would be better to // not change the given constraint and just keep a variable for the new constraint tcx.EdgeEvent.ConstrainedEdge.Q = p1; triangle = triangle.NeighborAcross(point); EdgeEvent(tcx, ep, p1, triangle, p1); } else { throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet"); } if (tcx.IsDebugEnabled) { Debug.WriteLine("EdgeEvent - Point on constrained edge"); } return; } TriangulationPoint p2 = triangle.PointCW(point); Orientation o2 = TriangulationUtil.Orient2d(eq, p2, ep); if (o2 == Orientation.Collinear) { if (triangle.Contains(eq, p2)) { triangle.MarkConstrainedEdge(eq, p2); // We are modifying the constraint maybe it would be better to // not change the given constraint and just keep a variable for the new constraint tcx.EdgeEvent.ConstrainedEdge.Q = p2; triangle = triangle.NeighborAcross(point); EdgeEvent(tcx, ep, p2, triangle, p2); } else { throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet"); } if (tcx.IsDebugEnabled) { Debug.WriteLine("EdgeEvent - Point on constrained edge"); } return; } if (o1 == o2) { // Need to decide if we are rotating CW or CCW to get to a triangle // that will cross edge if (o1 == Orientation.CW) { triangle = triangle.NeighborCCW(point); } else { triangle = triangle.NeighborCW(point); } EdgeEvent(tcx, ep, eq, triangle, point); } else { // This triangle crosses constraint so lets flippin start! FlipEdgeEvent(tcx, ep, eq, triangle, point); } }
private static void EdgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point) { bool flag = DTSweep.IsEdgeSideOfTriangle(triangle, ep, eq); if (!flag) { TriangulationPoint triangulationPoint = triangle.PointCCW(point); Orientation orientation = TriangulationUtil.Orient2d(eq, triangulationPoint, ep); bool flag2 = orientation == Orientation.Collinear; if (flag2) { bool flag3 = triangle.Contains(eq, triangulationPoint); if (!flag3) { throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet"); } triangle.MarkConstrainedEdge(eq, triangulationPoint); tcx.EdgeEvent.ConstrainedEdge.Q = triangulationPoint; triangle = triangle.NeighborAcross(point); DTSweep.EdgeEvent(tcx, ep, triangulationPoint, triangle, triangulationPoint); bool isDebugEnabled = tcx.IsDebugEnabled; if (isDebugEnabled) { Debug.WriteLine("EdgeEvent - Point on constrained edge"); } } else { TriangulationPoint triangulationPoint2 = triangle.PointCW(point); Orientation orientation2 = TriangulationUtil.Orient2d(eq, triangulationPoint2, ep); bool flag4 = orientation2 == Orientation.Collinear; if (flag4) { bool flag5 = triangle.Contains(eq, triangulationPoint2); if (!flag5) { throw new PointOnEdgeException("EdgeEvent - Point on constrained edge not supported yet"); } triangle.MarkConstrainedEdge(eq, triangulationPoint2); tcx.EdgeEvent.ConstrainedEdge.Q = triangulationPoint2; triangle = triangle.NeighborAcross(point); DTSweep.EdgeEvent(tcx, ep, triangulationPoint2, triangle, triangulationPoint2); bool isDebugEnabled2 = tcx.IsDebugEnabled; if (isDebugEnabled2) { Debug.WriteLine("EdgeEvent - Point on constrained edge"); } } else { bool flag6 = orientation == orientation2; if (flag6) { bool flag7 = orientation == Orientation.CW; if (flag7) { triangle = triangle.NeighborCCW(point); } else { triangle = triangle.NeighborCW(point); } DTSweep.EdgeEvent(tcx, ep, eq, triangle, point); } else { DTSweep.FlipEdgeEvent(tcx, ep, eq, triangle, point); } } } } }