Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
        // 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;
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
        /// <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;
        }