Exemplo n.º 1
0
        void PropagateNodeSet(IndexSet nodeSet, bool forward = true, IEnumerable <Identifier> initialWavefront = null)
        {
            m_Wavefront.Clear();
            if (initialWavefront != null)
            {
                foreach (var id in initialWavefront)
                {
                    m_Wavefront.Push(id);
                }
            }
            else
            {
                foreach (var index in nodeSet)
                {
                    m_Wavefront.Push(m_Identifiers[index]);
                }
            }
            while (m_Wavefront.Count > 0)
            {
                var index = m_Wavefront.Pop();
                var node  = m_Graph.GetNodeFromTempId(index);
                if (node == null)
                {
                    continue;
                }

                // Loop through all nodes that the node feeds into.
                m_Slots.Clear();
                if (forward)
                {
                    node.GetOutputSlots(m_Slots);
                }
                else
                {
                    node.GetInputSlots(m_Slots);
                }
                foreach (var slot in m_Slots)
                {
                    m_Edges.Clear();
                    m_Graph.GetEdges(slot.slotReference, m_Edges);
                    foreach (var edge in m_Edges)
                    {
                        // We look at each node we feed into.
                        var connectedSlot     = forward ? edge.inputSlot : edge.outputSlot;
                        var connectedNodeGuid = connectedSlot.nodeGuid;
                        var connectedNode     = m_Graph.GetNodeFromGuid(connectedNodeGuid);

                        // If the input node is already in the set of time-dependent nodes, we don't need to process it.
                        if (nodeSet.Contains(connectedNode.tempId.index))
                        {
                            continue;
                        }

                        // Add the node to the set of time-dependent nodes, and to the wavefront such that we can process the nodes that it feeds into.
                        nodeSet.Add(connectedNode.tempId.index);
                        m_Wavefront.Push(connectedNode.tempId);
                    }
                }
            }
        }
Exemplo n.º 2
0
        void PropagateNodeList(ICollection <INode> nodes, bool forward)
        {
            m_NodeWave.Clear();
            foreach (var node in nodes)
            {
                m_NodeWave.Push(node);
            }

            while (m_NodeWave.Count > 0)
            {
                var node = m_NodeWave.Pop();
                if (node == null)
                {
                    continue;
                }

                // Loop through all nodes that the node feeds into.
                m_Slots.Clear();
                if (forward)
                {
                    node.GetOutputSlots(m_Slots);
                }
                else
                {
                    node.GetInputSlots(m_Slots);
                }
                foreach (var slot in m_Slots)
                {
                    m_Edges.Clear();
                    m_Graph.GetEdges(slot.slotReference, m_Edges);
                    foreach (var edge in m_Edges)
                    {
                        // We look at each node we feed into.
                        var connectedSlot     = forward ? edge.inputSlot : edge.outputSlot;
                        var connectedNodeGuid = connectedSlot.nodeGuid;
                        var connectedNode     = m_Graph.GetNodeFromGuid(connectedNodeGuid);

                        // If the input node is already in the set, we don't need to process it.
                        if (nodes.Contains(connectedNode))
                        {
                            continue;
                        }

                        // Add the node to the set, and to the wavefront such that we can process the nodes that it feeds into.
                        nodes.Add(connectedNode);
                        m_NodeWave.Push(connectedNode);
                    }
                }
            }
        }