Пример #1
0
        /// <summary> 将子边坡按指定的交点进行剪切,并返回剪切后的新的子边坡集合 </summary>
        /// <param name="data"></param>
        /// <param name="intersSeg"></param>
        /// <param name="intersPt"></param>
        public List <Slope> CutSlopeSegment(SlopeData data, Slope intersSeg, Point3d intersPt)
        {
            var slopeSegs = data.Slopes;
            var newSegs   = new List <Slope>();
            int mainLevel = intersSeg.GetMainLevel();
            // 1. 先添加交叉边坡之前的子边坡
            int sumBefore = 0;

            for (int id = 0; id < slopeSegs.Count; id++)
            {
                var slp = slopeSegs[id];
                if (slp.GetMainLevel() != mainLevel)
                {
                    newSegs.Add(slp);
                    sumBefore += 1;
                }
                else
                {
                    break;
                }
            }
            // 2. 对交叉处的子边坡进行处理
            var sumMainLevel   = slopeSegs.Count(r => r.GetMainLevel() == mainLevel); // 此子边坡中已经有多少个更细的子边坡
            int subLevelInters = intersSeg.GetSubLevel();
            // 分割后,最内侧的子边坡的Index为 n.1,最外侧的子边坡的Index为 n.9,
            int subL = 1;

            for (int i = 0; i < sumMainLevel; i++)
            {
                // 此循环的过程中改写有一个子边坡与指定的相交边坡是同一个边坡
                var seg = slopeSegs[sumBefore + i];
                if (seg.GetSubLevel() == subLevelInters)
                {
                    var seg1 = new Slope(Slope.GetIndex(mainLevel, subL), intersSeg.InnerPoint, intersPt);
                    var seg9 = new Slope(Slope.GetIndex(mainLevel, subL + 1), intersPt, intersSeg.OuterPoint);
                    SetProtectionMethod(intersSeg, seg1, seg9);
                    //
                    newSegs.Add(seg1);
                    newSegs.Add(seg9);
                    subL += 2;
                }
                else
                {
                    seg.SetIndex(mainLevel, subL);
                    newSegs.Add(seg);
                    subL += 1;
                }
            }
            // 修改最后一个的Index
            // newSegs[sumBefore + sumMainLevel].SetIndex(mainLevel, 9);

            // 3. 接着添加交叉边坡之后的子边坡
            for (int i = sumBefore + sumMainLevel; i < slopeSegs.Count; i++)
            {
                newSegs.Add(slopeSegs[i]);
            }
            return(newSegs);
        }
Пример #2
0
        private List <DBText> FilterDeletedTexts(List <DBText> selectedTexts)
        {
            // 子边坡等级
            int[] slopeLevels = null;
            if (checkBox_AllSlopeLevels.Checked)
            {
                slopeLevels = null;
            }
            else
            {
                try
                {
                    var levelStr = textBox_SlopeLevels.Text.Split(',');
                    slopeLevels = levelStr.Select(r => Convert.ToInt32(r)).ToArray();
                }
                catch (Exception)
                {
                    MessageBox.Show($"不同坡级之间请通过“,”进行分隔");
                    return(null);
                }
            }
            // 边坡还是平台
            var slopePlatform = IsSlopeOrPlatform();

            var filterd2 = new List <DBText>();

            foreach (var txt in selectedTexts)
            {
                var buff = txt.GetXDataForApplication(ProtTextData.RegAppName_SlopeText);
                if (buff != null)
                {
                    // 过滤
                    var protData = ProtTextData.FromResultBuffer(buff);
                    if (protData != null)
                    {
                        // 桩号区间
                        // if (!anyStation && !(protData.Station >= startStation && protData.Station <= endStation)) { continue; }

                        // 子边坡等级
                        if (slopeLevels != null && !slopeLevels.Contains(Slope.GetMainLevel(protData.Index)))
                        {
                            continue;
                        }
                        // 满足所有过滤条件
                        filterd2.Add(txt);
                    }
                }
            }

            return(filterd2);
        }