/// <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); }