/// <summary> /// Exhaustive search to update neighbor pointers /// </summary> /// <param name="t"></param> public void MarkNeighbor(Triangle t) { if (t.Contains(Points[1], Points[2])) { _neighbours[0] = t; t.MarkNeighbor(Points[1], Points[2], this); } else if (t.Contains(Points[0], Points[2])) { _neighbours[1] = t; t.MarkNeighbor(Points[0], Points[2], this); } else if (t.Contains(Points[0], Points[1])) { _neighbours[2] = t; t.MarkNeighbor(Points[0], Points[1], this); } }
private void EdgeEvent(SweepContext tcx, TriPoint ep, TriPoint eq, Triangle triangle, TriPoint point) { if (IsEdgeSideOfTriangle(triangle, ep, eq)) { return; } TriPoint p1 = triangle.PointCCW(point); Winding o1 = TriUtil.Orient2d(eq, p1, ep); if (o1 == Winding.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 NotSupportedException("EdgeEvent - collinear points not supported"); } return; } TriPoint p2 = triangle.PointCW(point); Winding o2 = TriUtil.Orient2d(eq, p2, ep); if (o2 == Winding.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 NotSupportedException("EdgeEvent - collinear points not supported"); } 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 == Winding.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); } }