Exemplo n.º 1
0
 public DigraphBuilder()
 {
     routes      = new List <TestBranch>();
     endNode     = new List <TNode>();
     remainNodes = new List <TNode>();
     elements    = new List <TNodeUI>();
     h_lines     = new List <Tuple <Point, Point> >();
     v_lines     = new List <Tuple <Point, Point> >();
     poly_lines  = new List <Tuple <Point, Point> >();
     nodePos     = new Dictionary <TNode, Point>();
     observer    = new ComponentVMObserver();
 }
Exemplo n.º 2
0
 public BranchView(IDictionary <string, ShortBranchNode> labelToBranch, ISet <ShortBranchNode> nodes, ComponentVMObserver observer)
 {
     this.nodes         = nodes;
     this.observer      = observer;
     this.labelToBranch = labelToBranch;
 }
Exemplo n.º 3
0
        /// <summary>
        /// 获得从总正出发,总负截止的所有拼接支路
        /// </summary>
        private BranchView getNodes(string headEqual, Func <string, bool> filter)
        {
            ComponentVMObserver _observer = new ComponentVMObserver();
            AppProject          pro       = AppProject.GetInstance();

            ((List <ShortBranch>)pro.Shorts).ForEach(p => p.HasIncluded = false);
            LinkedList <string> labels = new LinkedList <string>();
            IDictionary <string, ShortBranchNode> allLabels = new Dictionary <string, ShortBranchNode>();

            labels.AddLast(headEqual);

            ShortBranchNode head = new ShortBranchNode(null, null, headEqual);

            allLabels.Add(headEqual, head);

            #region 广度遍历得到短支路的树结构
            while (labels.First != null)
            {
                string label = labels.First.Value;
                labels.RemoveFirst();
                if (filter(label))
                {
                    continue;
                }
                TNodeUI item1 = null, item2 = null;
                foreach (ShortBranch br in pro.Shorts)
                {
                    if (!br.HasIncluded)
                    {
                        if (br.HeadEqualNum == label || br.TailEqualNum == label)
                        {
//                             if (br.HeadEqualNum == "Net203" || br.TailEqualNum == "Net203")
//                             {
//
//                             }
                            List <TNodeUI> uis     = new List <TNodeUI>();
                            List <TNode>   brNodes = br.Branch;
                            if (br.TailEqualNum == label)
                            {
                                brNodes.Reverse();
                            }
                            int i = 0;
                            while (i < brNodes.Count)
                            {
                                TNodeUI ui = null;
                                if (i + 1 < brNodes.Count && brNodes[i].Brother == brNodes[i + 1])
                                {
                                    ui = BranchFactory.convert(brNodes[i], brNodes[i + 1], _observer);
                                    if (i == 0)
                                    {
                                        item2 = ui;
                                    }
                                    uis.Add(ui);
                                    i += 2;
                                }
                                else
                                {
                                    ui = BranchFactory.convert(brNodes[i], null, _observer);
                                    if (i == 0)
                                    {
                                        item2 = ui;
                                    }
                                    uis.Add(ui);
                                    i++;
                                }
                                if (ui != null && item1 == null)
                                {
                                    item1 = ui;
                                }
                            }
                            ShortBranchNode bnode = new ShortBranchNode(uis, allLabels[label], brNodes[brNodes.Count - 1].Equal);
                            allLabels[label].Nodes.Add(bnode);
                            if (!allLabels.ContainsKey(brNodes[brNodes.Count - 1].Equal))
                            {
                                allLabels.Add(brNodes[brNodes.Count - 1].Equal, bnode);
                                labels.AddLast(brNodes[brNodes.Count - 1].Equal);
                            }
                            br.HasIncluded = true;
                        }
                    }
                }
            }
            #endregion

            #region 返回顶节点
//             ISet<ShortBranchNode> branchNodes = new HashSet<ShortBranchNode>();
//             foreach (ShortBranchNode brNode in allLabels.Values)
//             {
//                 if (brNode.Parent == head)
//                     branchNodes.Add(brNode);
//             }
            return(new BranchView(allLabels, head.Nodes, _observer));

            #endregion
        }