예제 #1
0
            public List <PipeGroup> GetPipeGroups(double lengthBetweenPipe_Inch)
            {
                PipeGroupCollection pipeGroups = new PipeGroupCollection();

                foreach (var slopePipes in this)
                {
                    pipeGroups.AddRange(slopePipes.GetPipeGroups(lengthBetweenPipe_Inch));
                }
                return(pipeGroups);
            }
예제 #2
0
                /// <summary>
                /// 清空
                /// </summary>
                public PipeGroupCollection Clear()
                {
                    PipeGroupCollection collection = new PipeGroupCollection();

                    foreach (var branch in Branches)
                    {
                        collection.Add(branch.ToPipeGroup());
                    }
                    Branches.Clear();
                    LatestSkewPipe = null;
                    return(collection);
                }
예제 #3
0
            public List <PipeGroup> GetPipeGroups(double lengthBetweenPipe_Inch)
            {
                PipeGroupCollection pipeGroups = new PipeGroupCollection();
                SkewPipe            start;
                SkewPipe            pre, cur;

                start = pre = cur = SkewPipes[0];
                OverlapChecker overlap = new OverlapChecker(cur, lengthBetweenPipe_Inch);

                for (int i = 1; i < SkewPipes.Count(); i++)
                {
                    var result = overlap.Push(SkewPipes[i]);
                    if (result != null && result.Count != 0)
                    {
                        pipeGroups.AddRange(result);
                    }
                }
                pipeGroups.AddRange(overlap.Clear());
                return(pipeGroups);
            }
예제 #4
0
                /// <summary>
                /// 加入队列
                /// </summary>
                /// <param name="skewPipe"></param>
                public PipeGroupCollection Push(SkewPipe skewPipe)
                {
                    var skewPipeId = skewPipe.pipe.Id.IntegerValue;

                    if (LatestSkewPipe == null)
                    {
                        LatestSkewPipe = skewPipe;
                        Branches.Add(new OverlapBranch(skewPipe));
                        return(null);
                    }
                    //如果和最近一次添加项的间距超出限制,则所有的都超出限制,直接做全部结算
                    if (!IsValidInterval(LatestSkewPipe, skewPipe))
                    {
                        var result = Clear();
                        Push(skewPipe);
                        return(result);
                    }

                    PipeGroupCollection collection = new PipeGroupCollection();

                    LatestSkewPipe = skewPipe;
                    //对于每一个分支,最近添加项都有可能是不同的,需重新计算间距
                    bool isExist = false;

                    if (Branches.Count > 100000)
                    {
                        throw new NotImplementedException("超出了十万的分支限制");
                    }
                    for (int i = Branches.Count() - 1; i >= 0; i--)
                    {
                        var branch = Branches[i];
                        if (branch.SkewPipes.Count == AnnotationConstaints.PipeCountMax - 1)//如果分组个数超出了规定 则不予生成
                        {
                            throw new NotImplementedException("管道超出了并排6个的上限");
                            branch.Push(skewPipe);
                            collection.Add(branch.ToPipeGroup());
                            Branches.Remove(branch);
                        }
                        else if (!IsValidInterval(branch.LatestSkewPipe, skewPipe))//如果间距超出了限制,则做一波结算
                        {
                            collection.Add(branch.ToPipeGroup());
                            Branches.Remove(branch);
                        }
                        else
                        {
                            branch.Push(skewPipe);
                            if (branch.IsOverlapped)
                            {
                                Branches.Add(branch.Clone());
                            }
                            else
                            {
                                //TODO 如果已有该项的单项
                                if (!isExist)
                                {
                                    foreach (var b in Branches)
                                    {
                                        if (b.SkewPipes.Count() == 1 && b.SkewPipes[0] == skewPipe)
                                        {
                                            isExist = true;
                                            break;
                                        }
                                    }
                                    if (!isExist)
                                    {
                                        Branches.Add(new OverlapBranch(skewPipe));
                                    }
                                }
                            }
                            branch.PopLast();
                        }
                    }
                    //本来想要在这里做消重处理 比如 A-B A-B-D但是后续可能出现A-B-E
                    //目前没有很好的办法检测后续是否会出现E
                    return(collection);
                }