public bool IsConnectedTo(Wire Other) { return(PointOnSegment(Other.A, A, B) || PointOnSegment(Other.B, A, B) || PointOnSegment(A, Other.A, Other.B) || PointOnSegment(B, Other.A, Other.B)); }
// Wires was a single node but it is now two. Break it into two sets of nodes // and return the one containing Target. private IEnumerable<Wire> ConnectedTo(IEnumerable<Wire> Wires, Wire Target) { // Repeatedly search for connections with the target. IEnumerable<Wire> connected = new Wire[] { Target }; int count = connected.Count(); while (true) { connected = Wires.Where(i => connected.Any(j => i.IsConnectedTo(j))).ToArray(); if (connected.Count() == count) break; count = connected.Count(); } return connected; }
public bool IsConnectedTo(Wire Other) { return PointOnSegment(Other.A, A, B) || PointOnSegment(Other.B, A, B) || PointOnSegment(A, Other.A, Other.B) || PointOnSegment(B, Other.A, Other.B); }
/// <summary> /// Find the node at point x. /// </summary> /// <param name="x"></param> /// <param name="Self"></param> /// <returns></returns> public Node NodeAt(Coord x, Wire Self) { IEnumerable<Wire> wires = Wires; if (Self != null) wires = wires.Except(Self); Wire w = wires.FirstOrDefault(i => i.IsConnectedTo(x)); return w != null ? w.Node : null; }