/// <summary> /// 添加直线,不做其他动作,只是添加数据到数组 /// </summary> /// <param name="line"></param> public void AddLine(PartitionLine line) { if (line.IsRow) { HPartionLines.Add(line); } else { VPartionLines.Add(line); } }
public void AddLine(int start, int end, int position, bool isRow) { PartitionLine line = new PartitionLine(start, end, position, isRow); List <PartitionLine> resultLines; ///找到与给定直线正交之分割线的结果集 List <PartitionLine> overLapLine; ///被重叠的直线 ///找到所有被line切割的分割线 FindLineByLine findLinePartion = new FindLineByLine(line); if (line.IsRow) { resultLines = VPartionLines.FindAll(findLinePartion.PredicatePartedLine); if (resultLines.Count >= 1) { ///处理被其切割了其他的直线,同时处理自己也被切割了的情形 for (int i = 0; i < resultLines.Count; i++) { resultLines[i].PartitionByLine(line); line.PartitionByLine(resultLines[i]); } } ///添加新绘之直线,先判断是否有重叠直线 FindLineByLine findByLine = new FindLineByLine(line); overLapLine = HPartionLines.FindAll(findByLine.PredicateOverlap); if (overLapLine.Count == 0) { HPartionLines.Add(line); } else if (overLapLine.Count == 1) { overLapLine[0].MergeOverlapLine(line); } else { PartitionLine removedLine = line.MergeOverlapLine(overLapLine[0], overLapLine[1]); HPartionLines.Remove(removedLine); } } else { resultLines = HPartionLines.FindAll(findLinePartion.PredicatePartedLine); if (resultLines.Count >= 1) { ///处理被其切割了其他的直线,同时处理自己也被切割了的情形 for (int i = 0; i < resultLines.Count; i++) { resultLines[i].PartitionByLine(line); line.PartitionByLine(resultLines[i]); } } ///添加新绘之直线,先判断是否有重叠直线 FindLineByLine findByLine = new FindLineByLine(line); overLapLine = VPartionLines.FindAll(findByLine.PredicateOverlap); if (overLapLine.Count == 0) { VPartionLines.Add(line); } else if (overLapLine.Count == 1) { overLapLine[0].MergeOverlapLine(line); } else { PartitionLine removedLine = line.MergeOverlapLine(overLapLine[0], overLapLine[1]); VPartionLines.Remove(removedLine); } } }