示例#1
0
        private void BuildBranch()
        {
            branchList = new List <Branch>();
            nodeList   = new List <Node>();
            Node          node;
            EletronicUnit unit = source;
            Branch        branch;

            node = source.GetNegativePole();
            Stack <Node>   nodes    = new Stack <Node>();
            Stack <Branch> branches = new Stack <Branch>();

            branch     = new Branch(node);
            node.index = nodeList.Count;
            bool IN = true;

            do
            {
                if (node.Count == 0)
                {
                    if (nodes.Count == 0)
                    {
                        break;
                    }
                    else
                    {
                        node   = nodes.Pop();
                        branch = branches.Pop();
                        IN     = false;
                        continue;
                    }
                }
                else if (node.IsForking())
                {
                    if (nodeList.Contains(node))
                    {
                        SaveBranch(node, branch);
                        if (nodes.Count == 0)
                        {
                            break;
                        }
                        else
                        {
                            node   = nodes.Pop();
                            branch = branches.Pop();
                            IN     = true;
                            continue;
                        }
                    }
                    else if (!IN)
                    {
                        SaveBranchAndNode(node, branch);
                        int count = node.Count;
                        for (int i = 0; i < count; i++)
                        {
                            nodes.Push(node.GetNode(i));
                            branches.Push(new Branch(node));
                        }
                        node   = nodes.Pop();
                        branch = branches.Pop();
                        IN     = true;
                        continue;
                    }
                    else if (IN)
                    {
                        SaveBranchAndNode(node, branch);
                        unit   = node.GetUnit();
                        branch = new Branch(node);
                        node   = unit.GetOutNode(node);
                        branch.Append(unit);
                    }
                }
                else if (!IN && !node.IsForking())
                {
                    node = node.GetNode(0);
                    if (nodeList.Contains(node))
                    {
                        SaveBranch(node, branch);
                        if (nodes.Count == 0)
                        {
                            break;
                        }
                        else
                        {
                            node   = nodes.Pop();
                            branch = branches.Pop();
                            IN     = true;
                            continue;
                        }
                    }
                }
                else
                {
                    unit = node.GetUnit();
                    branch.Append(unit);
                    node = unit.GetOutNode(node);
                }
                IN = !IN;
            } while (true);
        }
示例#2
0
 public void Insert(int index, EletronicUnit unit)
 {
     Units.Insert(index, unit);
 }
示例#3
0
文件: Node.cs 项目: puro2xz/LabTime
 public Node(EletronicUnit unit)
 {
     this.unit = unit;
     feet      = new List <Node>();
 }
示例#4
0
 public void Append(EletronicUnit unit)
 {
     Units.Add(unit);
     R = R + unit.R;
 }