private List <List <LINE> > TakeOffSubBeams(List <List <LINE> > Result, List <LINE> nonSelected, double SHIFTs) { SHIFTs = SHIFTs * 2; /// 拿掉第一輪subBeam List <FloorEdges> result = new List <FloorEdges>(); foreach (List <LINE> item in Result) { FloorEdges fe = new FloorEdges(item, nonSelected, SHIFTs); List <LINE> subBeam = fe.GetSubBeam(); result.Add(fe); } /// 拿掉第二輪subBeam List <List <LINE> > Res = new List <List <LINE> >(); foreach (FloorEdges item in result) { foreach (List <LINE> floors in item.GetSubFloors()) { Res.Add(floors); } } return(Res); }
private List <FloorEdges> SplitFloorBySubBeam(List <LINE> floor, LINE subbeam) { List <FloorEdges> Floors = new List <FloorEdges>(); /////// 檢查subBeam與板邊界是否有兩個交點 List <int> CrossPo = new List <int>(); for (int i = 0; i < floor.Count; i++) { LINE floorEdge = floor[i]; if (Math.Abs(Math.Round(floorEdge.GetSlope(), 3)) == Math.Abs(Math.Round(subbeam.GetSlope(), 3))) { continue; } XYZ crossPoint = floorEdge.GetCrossPoint(subbeam); if (IsCloseEndsPoint(subbeam, crossPoint) && floorEdge.IsPointInLine(crossPoint)) { CrossPo.Add(i); } } /////// 沒有兩個交點則不處理直接回傳 if (CrossPo.Count != 2) { FloorEdges Floor = new FloorEdges(floor); Floors.Add(Floor); return(Floors); } /////// 有兩個交點則開始處理梁的分離 /// 將板轉換成節點 List <XYZ> nodes = new List <XYZ>(); foreach (LINE item in floor) { nodes.Add(item.GetStartPoint()); } nodes.Add(floor[floor.Count - 1].GetEndPoint()); /// 取的偏移後的交點 XYZ targetPoint = floor[CrossPo[0]].GetStartPoint(); LINE offSetLine_1 = subbeam.GetShiftLines(floor[CrossPo[0]].GetStartPoint(), subbeam.Width / 2, "IN")[0]; LINE offSetLine_2 = subbeam.GetShiftLines(floor[CrossPo[0]].GetEndPoint(), subbeam.Width / 2, "IN")[0]; XYZ crossPoint1 = offSetLine_1.GetCrossPoint(floor[CrossPo[0]]); XYZ crossPoint2 = offSetLine_1.GetCrossPoint(floor[CrossPo[1]]); XYZ crossPoint3 = offSetLine_2.GetCrossPoint(floor[CrossPo[0]]); XYZ crossPoint4 = offSetLine_2.GetCrossPoint(floor[CrossPo[1]]); List <XYZ> crossPoint_1 = new List <XYZ>() { crossPoint1, crossPoint2 }; List <XYZ> crossPoint_2 = new List <XYZ>() { crossPoint3, crossPoint4 }; /// Part 1 int kk = 0; List <XYZ> part_1 = new List <XYZ>(); for (int i = 0; i < nodes.Count; i++) { if (i > CrossPo[0] && i <= CrossPo[1] && kk < 2) { part_1.Add(crossPoint_1[kk]); kk = kk + 1; } else if (i <= CrossPo[0] || i > CrossPo[1]) { part_1.Add(nodes[i]); } } /// Part 2 kk = 0; List <XYZ> part_2 = new List <XYZ>(); for (int i = 0; i < nodes.Count; i++) { if (i > CrossPo[0] && i <= CrossPo[1]) { part_2.Add(nodes[i]); } else if ((i == CrossPo[0] || i == CrossPo[1] + 1) && kk < 2) { part_2.Add(crossPoint_2[kk]); kk = kk + 1; } } part_2.Add(crossPoint_2[0]); try { /// 將節點轉換成LINE List <LINE> newFloor_1 = new List <LINE>(); for (int i = 0; i < part_1.Count() - 1; i++) { newFloor_1.Add(new LINE(part_1[i], part_1[i + 1])); } List <LINE> newFloor_2 = new List <LINE>(); for (int i = 0; i < part_2.Count() - 1; i++) { newFloor_2.Add(new LINE(part_2[i], part_2[i + 1])); } Floors.Add(new FloorEdges(newFloor_1)); Floors.Add(new FloorEdges(newFloor_2)); } catch (Exception) { return(new List <FloorEdges>() { new FloorEdges(floor) }); } return(Floors); }