/// <summary> /// Exhaustive search to update neighbor pointers /// </summary> /// <param name="t">triangle</param> 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 { logger.Error("markNeighbor failed"); } }
private static void edgeEvent(DTSweepContext tcx, TriangulationPoint ep, TriangulationPoint eq, DelaunayTriangle triangle, TriangulationPoint point) { TriangulationPoint p1, p2; if (tcx.isDebugEnabled()) { tcx.getDebugContext().setPrimaryTriangle(triangle); } if (isEdgeSideOfTriangle(triangle, ep, eq)) { return; } p1 = triangle.pointCCW(point); Orientation o1 = 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.setQ(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()) { logger.Info("EdgeEvent - Point on constrained edge"); } return; } p2 = triangle.pointCW(point); Orientation o2 = 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.setQ(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()) { logger.Info("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); } }