private void btnOk_Click(object sender, EventArgs e) { string errMsg; var succ = CheckData(out errMsg); if (!succ) { MessageBox.Show(errMsg, @"数据不符合规范", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // 设置边坡的岩土性质 var allSlopes = SQUtils.GetAllExistingSlopeLines(_docMdf, sort: true); SetSlopeSoilRock(allSlopes); // 设置Block的连接桩号 var allSortedStations = Options_Collections.AllSortedStations.ToArray(); foreach (var b in Options_Collections.RangeBlocks) { b.CalculateConnetedStations(allSortedStations); } // DialogResult = DialogResult.OK; Close(); }
private void RunCommand(object sender, EventArgs e) { // Utils.FocusOnMainUIWindow(); var selectedSlopes = SQUtils.SelecteExistingSlopeLines(DocMdf, left: null, sort: true); if (selectedSlopes == null || selectedSlopes.Count == 0) { return; } var handledSlopes = selectedSlopes.ToArray(); // 区分填挖 if (radioButton_cut.Checked) { handledSlopes = selectedSlopes.Where(r => !r.XData.FillCut).ToArray(); } else if (radioButton_fill.Checked) { handledSlopes = selectedSlopes.Where(r => r.XData.FillCut).ToArray(); } if (handledSlopes.Length == 0) { return; } // 剪切方法 var method = (CutMethod)comboBox_cutMethods.SelectedItem; // 执行操作 UISeperateByElev(DocMdf, handledSlopes, method, textBoxNum_cutElev.ValueNumber, textBoxNum_waterLineLength.ValueNumber); CommitCommand(); }
/// <summary> 将所有表格中记录的数据导出到指定Excel工作簿的多个工作表中 </summary> /// <param name="sheet_Infos"></param> /// <returns></returns> private static bool ExportDataToExcel(List <WorkSheetData> sheet_Infos, out string errMsg) { Application excelApp = null; errMsg = null; bool succ = true; try { Workbook wkbk; succ = GetExcelWorkbook(out wkbk); if (wkbk != null) { excelApp = wkbk.Application; excelApp.ScreenUpdating = false; // foreach (var tpInfo in sheet_Infos) { var sht = SQUtils.GetOrCreateWorkSheet(wkbk, tpInfo.SheetName); if (sht != null) { RangeValueConverter.FillRange(sht, startRow: 1, startCol: 1, arr: tpInfo.Data, colPrior: false); sht.UsedRange.EntireColumn.AutoFit(); sht.Activate(); var w = excelApp.ActiveWindow as Window; w.SplitColumn = 0; w.SplitRow = 1; w.FreezePanes = true; } else { errMsg = $"未找到工作表:{tpInfo.SheetName}"; succ = false; } wkbk.Save(); } } else { errMsg = $"未能打开或者创建 Excel 工作簿"; } } catch (Exception ex) { errMsg = ex.Message; } finally { if (excelApp != null) { excelApp.Visible = true; excelApp.ScreenUpdating = true; } } return(succ); }
/// <summary> 提取所有的横断面的相关信息 </summary> public ExternalCmdResult AllSectionsInfo(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; var allSections = SQUtils.GetAllSections(docMdf, sort: true); _docMdf.WriteNow($"\n找到{allSections.Length}个横断面对象!\n"); ExportSectionInfoToText(allSections); return(ExternalCmdResult.Commit); }
/// <summary> 将分割开的多个子边坡进行合并 </summary> public ExternalCmdResult MergeSlopeSegs(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); // var selectedSlopes = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: true); if (selectedSlopes == null || selectedSlopes.Count == 0) { return(ExternalCmdResult.Cancel); } // MergeProtectionDirection dir; var succ = GetProtectionDirection(docMdf, out dir); if (!succ) { return(ExternalCmdResult.Cancel); } // //var layer_Slope = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope); //var layer_WaterLine = Utils.GetOrCreateLayer_WaterLine(_docMdf); //var layer_Platform = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform); var es = EditStateIdentifier.GetCurrentEditState(_docMdf); es.CurrentBTR.UpgradeOpen(); bool haveSegsMerged = false; int mergedCount = 0; docMdf.WriteLineIntoDebuger("合并的边坡对象:"); var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, selectedSlopes); foreach (var slp in selectedSlopes) { haveSegsMerged = MergeSlope(slp.XData, dir); if (haveSegsMerged) { // 将刷新后的数据保存到 AutoCAD 文档与界面中 slp.Pline.UpgradeOpen(); // slp.ClearAllWaterlines(_docMdf.acDataBase); SlopeConstructor.SetSlopeUI(slp); slp.PrintProtectionMethod(es.CurrentBTR, protLayers); slp.FlushXData(); // slp.Pline.DowngradeOpen(); mergedCount += 1; docMdf.WriteLineIntoDebuger(slp); } } docMdf.WriteLineIntoDebuger($"总计:{mergedCount} 个"); // return(ExternalCmdResult.Commit); }
/// <summary> 根据 AutoCAD 中的几何图形构造出完整的路基横断面信息系统 </summary> public ExternalCmdResult ConstructSections(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); // 方法一:在界面中选择指定的断面 // var axisLines = SQUtils.SelecteSectionLines(docMdf.acEditor); // 方法二:直接提取整个文档中所有的断面 var axisLines = SQUtils.GetAllSectionLines(docMdf.acEditor); if (axisLines != null && axisLines.Count > 0) { // 先检查以前是否进行过横断面构造,免得由于误点击而将原来的数据删除 bool hasConstructed = true; // if (hasConstructed) { var res = MessageBox.Show("是否要重新构造横断面系统?\r\n此操作会覆盖以前的横断面系统数据!", "提示", MessageBoxButton.YesNo, MessageBoxImage.Information); if (res == MessageBoxResult.No) { return(ExternalCmdResult.Cancel); } } var f = new SectionsConstructorForm(docMdf, axisLines); f.ShowDialog(); // var stations = f.SectionAxes.Select(r => r.XData.Station).ToArray(); //检查是否有重复的桩号出现 var duplicated = stations.GroupBy(x => x).Where(g => g.Count() > 1).ToArray(); if (duplicated.Length > 0) { MessageBox.Show("路基系统中出现重复的桩号,请核对后再操作!\r\n重复的桩号见命令行提示。", "提示", MessageBoxButton.OK, MessageBoxImage.Error); docMdf.WriteLineIntoDebuger("重复的桩号,重复的次数"); foreach (var d in duplicated) { docMdf.WriteLineIntoDebuger(d.Key, d.Count()); } } else { // 将桩号从小到大排序 Array.Sort(stations); Options_Collections.AllSortedStations = stations; DbXdata.FlushXData(docMdf, DbXdata.DatabaseXdataType.AllSortedStations); } } else { MessageBox.Show("未找到有效的横断面轴线,请核对后再操作!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } return(ExternalCmdResult.Commit); }
/// <summary> 创建边坡并设置每一个边坡的数据 </summary> public ExternalCmdResult ConstructSlopes(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); var justModifyCalculatedSlopes = ModifyOrAdd(docMdf.acEditor); var slopeLines = SQUtils.SelecteSlopeLines(docMdf.acEditor, left: null); if (slopeLines != null && slopeLines.Count > 0) { ConfigerSlopes(slopeLines, justModifyCalculatedSlopes); } return(ExternalCmdResult.Commit); }
/// <summary> 在 AutoCAD 界面中快速导航到指定的桩号 </summary> public ExternalCmdResult NavigateStation(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SubgradeSection matchedSection = null; bool? start; var wantedStation = SetStation(docMdf.acEditor, out start); // 所有的断面 var allSections = SQUtils.GetAllSections(docMdf, sort: true); if (allSections != null && allSections.Length > 0) { if (start.HasValue) { // 匹配起始或者结尾桩号 if (start.Value) { matchedSection = allSections[0]; } else { matchedSection = allSections[allSections.Length - 1]; } } else { // 匹配指定数值最近的桩号 if (wantedStation.HasValue) { var allStations = new AllStations(allSections.Select(r => r.XData.Station).ToArray()); var closestStation = allStations.MatchClosest(wantedStation.Value); matchedSection = allSections.FirstOrDefault(r => r.XData.Station == closestStation); } } // if (matchedSection != null) { var ext = matchedSection.GetExtends(); ext.TransformBy(Matrix3d.Scaling( scaleAll: 1.2, center: ext.MinPoint.Add((ext.MaxPoint - ext.MinPoint) / 2))); eZcad.Utility.Utils.ShowExtentsInView(docMdf.acEditor, ext); } } return(ExternalCmdResult.Commit); }
/// <summary> 构造函数 </summary> /// <param name="docMdf"></param> /// <param name="line"></param> /// <param name="infoBlock"></param> /// <param name="station"></param> private SubgradeSection(DocumentModifier docMdf, Line line, BlockReference infoBlock, string station) : this(line) { DocMdf = docMdf; CenterLine = line; _infoBlock = infoBlock.Handle; _station = SQUtils.GetStationFromString(station).Value; // var blr = FindCenterAxisElevation(docMdf.acEditor); if (blr != null) { _centerY = blr.Position.Y; _centerEle = double.Parse( (blr.AttributeCollection[0].GetObject(OpenMode.ForRead) as AttributeReference).TextString); } }
/// <summary> 按标高将边坡对象进行分割,以实现同一级边坡中分别设置不同的防护形式 </summary> private void UISeperateByElev(DocumentModifier docMdf, SlopeLine[] selectedSlopes, CutMethod method, double elev, double waterLineLength) { // ProtectionUtils.SubgradeEnvironmentConfiguration(docMdf); // //var layer_Slope = Utils.GetOrCreateLayer(docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope); var layer_WaterLine = SQUtils.GetOrCreateLayer_WaterLine(docMdf); //var layer_Platform = Utils.GetOrCreateLayer(docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform); var es = EditStateIdentifier.GetCurrentEditState(docMdf); es.CurrentBTR.UpgradeOpen(); // Point2d intersPt; Slope intersSlopeSeg; var protLayers = ProtectionTags.MapProtectionLayers(docMdf, selectedSlopes); foreach (var slp in selectedSlopes) { var inters = ValidateElevation(slp, method, elev, out intersPt, out intersSlopeSeg); if (inters) { // 将子边坡按指定的交点进行剪切 var newSegs = CutSlopeSegment(slp.XData, intersSlopeSeg, new Point3d(intersPt.X, intersPt.Y, 0)); slp.XData.Slopes = newSegs; // 将被剪切掉的子边坡所绑定的文字删除 SlopeLine.EraseText(intersSlopeSeg, docMdf.acDataBase); // 绘制水位线 var line = new Line(new Point3d(intersPt.X - waterLineLength / 2, intersPt.Y, 0), new Point3d(intersPt.X + waterLineLength / 2, intersPt.Y, 0)); line.LayerId = layer_WaterLine.Id; es.CurrentBTR.AppendEntity(line); docMdf.acTransaction.AddNewlyCreatedDBObject(line, true); // 将刷新后的数据保存到 AutoCAD 文档与界面中 slp.Pline.UpgradeOpen(); SlopeConstructor.SetSlopeUI(slp); slp.PrintProtectionMethod(es.CurrentBTR, protLayers); slp.FlushXData(); slp.Pline.DowngradeOpen(); } } es.CurrentBTR.DowngradeOpen(); }
protected override void OnCmdRun(bool closeWindow) { base.OnCmdRun(closeWindowWhenFinished: true); List <SlopeLine> selectedSlopes; // 左右侧 if (radioButton_left.Checked) { selectedSlopes = SQUtils.SelecteExistingSlopeLines(_docMdf, left: true, sort: true); } else if (radioButton_right.Checked) { selectedSlopes = SQUtils.SelecteExistingSlopeLines(_docMdf, left: false, sort: true); } else { selectedSlopes = SQUtils.SelecteExistingSlopeLines(_docMdf, left: null, sort: true); } if (selectedSlopes == null || selectedSlopes.Count == 0) { return; } var handledSlopes = selectedSlopes.ToArray(); // 区分填挖 if (radioButton_cut.Checked) { handledSlopes = selectedSlopes.Where(r => !r.XData.FillCut).ToArray(); } else if (radioButton_fill.Checked) { handledSlopes = selectedSlopes.Where(r => r.XData.FillCut).ToArray(); } if (handledSlopes.Length == 0) { return; } // 剪切方法 var method = (CutMethod)comboBox_cutMethods.SelectedItem; // 执行操作 CutSlopes(_docMdf, handledSlopes, method, textBoxNum_cutElev.ValueNumber, textBoxNum_waterLineLength.ValueNumber); }
/// <summary> 将边坡对象清理为一般的边坡线,并删除其中所有与边坡相关的数据 </summary> public ExternalCmdResult EraseSlope(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); // 所有的断面 // var allSections = ProtectionUtils.GetAllSections(docMdf,sort:true); var slopes = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: false); var es = EditStateIdentifier.GetCurrentEditState(_docMdf); es.CurrentBTR.UpgradeOpen(); foreach (var slp in slopes) { slp.ClearXData(); } es.CurrentBTR.DowngradeOpen(); return(ExternalCmdResult.Commit); }
/// <summary> 将所有的边坡信息提取出来并制成相应表格 </summary> public ExternalCmdResult ThinFillShallowCut(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); var centerLines = SQUtils.SelecteSectionLines(docMdf.acEditor); if (centerLines == null || centerLines.Count == 0) { return(ExternalCmdResult.Cancel); } // // 所有的断面 var allSections = SQUtils.GetAllSections(docMdf, sort: true); // var allStations = allSections.Select(r => r.XData.Station).ToArray(); // 要处理的断面 var handledSections = new List <SubgradeSection>(); string errMsg = null; foreach (var sl in centerLines) { var info = SectionInfo.FromCenterLine(sl); // 方式一:重新构造 // var axis = new CenterAxis(docMdf, sl, info); // 方式二:从总集合中索引 var axis = allSections.FirstOrDefault(r => r.XData.Station == info.Station); if (axis != null) { handledSections.Add(axis); } } // // 过滤 // 将边坡防护数据导出 var exporter = new Exporter_ThinFillShallowCut(docMdf, handledSections, allSections); exporter.ExportThinFillShallowCut(); return(ExternalCmdResult.Commit); }
/// <summary> 让用户在界面中选择一个 Excel 工作簿路径,用来保存对应的数据 </summary> /// <param name="wkbk"></param> /// <returns>true 表示操作成功,此时的<paramref name="wkbk"/>的值也有可能为null,即用户成功取消了操作。</returns> private static bool GetExcelWorkbook(out Workbook wkbk) { var filePath = Utils.ChooseSaveFile(title: "将数据保存到Excel中", filter: "Excel文件(*.xls)| *.xls"); // Excel工作簿(*.xlsx)|*.xlsx| Excel二进制工作簿(*.xlsb) |*.xlsb| Excel 97-2003 工作簿(*.xls)|*.xls wkbk = null; if (filePath != null) { Application excelApp = null; bool fileExists = File.Exists(filePath); try { if (fileExists) { wkbk = Interaction.GetObjectFromFile <Workbook>(filePath); excelApp = wkbk.Application; excelApp.Visible = false; } else { excelApp = SQUtils.GetExcelApp(visible: false); // excelApp = new Application() { Visible = false }; wkbk = excelApp.Workbooks.Add(); wkbk.SaveAs(Filename: filePath, FileFormat: XlFileFormat.xlAddIn8); } } catch (Exception) { return(false); // ignored } if (wkbk != null) { wkbk.Application.Windows[wkbk.Name].Visible = true; return(true); } } else { return(true); } return(false); }
/// <summary> 将所有的边坡信息提取出来并制成相应表格 </summary> public ExternalCmdResult ExportSlopeInfos(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); // 所有的断面 var allSections = SQUtils.GetAllSections(docMdf, sort: true); var slopeLines = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: true); // 过滤掉没有实际边坡或者平台的对象(比如边坡与挡墙重合的) slopeLines = slopeLines.Where(r => r.XData.Slopes.Count + r.XData.Platforms.Count > 0).ToList(); if (slopeLines.Count == 0) { return(ExternalCmdResult.Cancel); } // 将边坡防护数据导出 var exporter = new Exporter_SlopeProtection(docMdf, allSections, slopeLines); exporter.ExportData(); return(ExternalCmdResult.Commit); }
/// <summary> 从边坡线所绑定的防护方式的文字对象来设置防护 </summary> public ExternalCmdResult FlushProtection(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); // var allSections = ProtectionUtils.GetAllSections(docMdf); var slopeLines = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: true); // 从文字中提取边坡防护方式的数据 foreach (var slp in slopeLines) { var xdata = slp.XData; var slpSegs = SlopeData.Combine(xdata.Slopes, xdata.Platforms, sort: false); foreach (var s in slpSegs) { SlopeLine.ExtractProtectionFromText(s, _docMdf.acDataBase); } // 将数据保存下来 slp.Pline.UpgradeOpen(); slp.FlushXData(); slp.Pline.DowngradeOpen(); } return(ExternalCmdResult.Commit); }
/// <summary> 除陡坡路堤外需要挖台阶处理的范围 </summary> public void ExportStairCut() { var stairsCut = new List <CrossSectionRange <StairsExcav> >(); // 断面的判断与计算 double treatedWidth; double stairArea; SectionSide treatedSide; foreach (var sec in _handledSections) { var fillSlopeType = GetFillSlopeType(sec, out treatedSide, out treatedWidth, out stairArea); if (fillSlopeType == FillSlopeType.StairExcav) { var hfdc = _sortedRanges[sec.XData.Station]; hfdc.BackValue.AverageTreatedWidth = treatedWidth; hfdc.BackValue.StairCutSide = treatedSide; hfdc.BackValue.AverageStairArea = stairArea; // hfdc.FrontValue.AverageTreatedWidth = treatedWidth; hfdc.FrontValue.StairCutSide = treatedSide; hfdc.FrontValue.AverageStairArea = stairArea; // stairsCut.Add(hfdc); } } var countAll = stairsCut.Count; if (countAll == 0) { _docMdf.WriteNow($"需要挖台阶的横断面数量:{countAll}"); return; } // 对桥梁隧道结构进行处理:截断对应的区间 CutWithBlocks(stairsCut, Options_Collections.RangeBlocks); // 将位于桥梁隧道区间之内的断面移除 stairsCut = stairsCut.Where(r => !r.IsNull).ToList(); // 对于区间进行合并 // steepSlopes = MergeLinkedSections(steepSlopes); stairsCut = MergeLinkedSections <StairsExcav>(stairsCut); countAll = stairsCut.Count; _docMdf.WriteNow($"需要挖台阶的横断面数量:{countAll}"); if (countAll == 0) { return; } // 将结果整理为二维数组,用来进行表格输出 var rows = new List <object[]>(); var header = new string[] { "起始桩号", "结束桩号", "桩号区间", "段落长度", "左", "右", "挖台阶平均处理宽度", "挖台阶土方量" }; rows.Add(header); // 输出数据 for (int i = 0; i < stairsCut.Count; i++) { var rg = stairsCut[i]; rg.UnionBackFront(); // var rangeLength = rg.FrontValue.EdgeStation - rg.BackValue.EdgeStation; rows.Add(new object[] { rg.BackValue.EdgeStation, rg.FrontValue.EdgeStation, SQUtils.GetStationString(rg.BackValue.EdgeStation, rg.FrontValue.EdgeStation, 0), rangeLength, (int)(rg.BackValue.StairCutSide & SectionSide.左) > 0 ? ACadConstants.CheckMark : null, (int)(rg.BackValue.StairCutSide & SectionSide.右) > 0 ? ACadConstants.CheckMark : null, rg.BackValue.AverageTreatedWidth, rg.BackValue.AverageStairArea * rangeLength, }); // } var sheetArr = ArrayConstructor.FromList2D(listOfRows: rows); // 输出到表格 var sheet_Infos = new List <WorkSheetData> { new WorkSheetData(WorkSheetDataType.StairsExcavCross, "挖台阶_横断面", sheetArr) }; ExportWorkSheetDatas(sheet_Infos); }
/// <summary> 低填浅挖 </summary> public void ExportThinFillShallowCut() { var cutFillSections = new List <CrossSectionRange <ThinFillShallowCut> >(); // 断面的判断与计算 double width; double height; foreach (var sec in _sectionsToHandle) { var xdata = sec.XData; if (IsThinFill(_docMdf.acDataBase, sec, out width, out height)) { var thsc = _sortedRanges[xdata.Station]; // thsc.BackValue.Type = FillCutType.ThinFill; thsc.BackValue.AverageHeight = height; thsc.BackValue.AverageWidth = width; // thsc.FrontValue.Type = FillCutType.ThinFill; thsc.FrontValue.AverageHeight = height; thsc.FrontValue.AverageWidth = width; // cutFillSections.Add(thsc); } else if (IsShallowCut(_docMdf.acDataBase, sec, out width, out height)) { var thsc = _sortedRanges[xdata.Station]; // thsc.BackValue.Type = FillCutType.ShallowCut; thsc.BackValue.AverageHeight = height; thsc.BackValue.AverageWidth = width; // thsc.FrontValue.Type = FillCutType.ShallowCut; thsc.FrontValue.AverageHeight = height; thsc.FrontValue.AverageWidth = width; // cutFillSections.Add(thsc); } } var countAll = cutFillSections.Count; if (countAll == 0) { _docMdf.WriteNow($"低填浅挖断面数量:{countAll}"); return; } // 对桥梁隧道结构进行处理:截断对应的区间 CutWithBlocks(cutFillSections, Options_Collections.RangeBlocks); // 将位于桥梁隧道区间之内的断面移除 cutFillSections = cutFillSections.Where(r => !r.IsNull).ToList(); // 对于区间进行合并 cutFillSections = MergeLinkedSections(cutFillSections); countAll = cutFillSections.Count; _docMdf.WriteNow($"低填浅挖断面数量:{countAll}"); if (countAll == 0) { return; } // 将结果整理为二维数组,用来进行表格输出 var rows = new List <object[]>(); var header = new string[] { "起始桩号", "结束桩号", "桩号区间", "长度", "处理措施", "平均处理宽度", "平均处理高度" }; rows.Add(header); for (int i = 0; i < cutFillSections.Count; i++) { var thsc = cutFillSections[i]; thsc.UnionBackFront(); // rows.Add(new object[] { thsc.BackValue.EdgeStation, thsc.FrontValue.EdgeStation, SQUtils.GetStationString(thsc.BackValue.EdgeStation, thsc.FrontValue.EdgeStation, maxDigits: 0), thsc.FrontValue.EdgeStation - thsc.BackValue.EdgeStation, thsc.BackValue.GetDescription(), thsc.BackValue.AverageWidth, thsc.BackValue.AverageHeight, }); } var sheetArr = ArrayConstructor.FromList2D(listOfRows: rows); // sheetArr = sheetArr.InsertVector<object, string, object>(true, new[] { header }, new[] { -1.5f, }); var sheet_Infos = new List <WorkSheetData> { new WorkSheetData(WorkSheetDataType.ThinFillShallowCut, "低填浅挖", sheetArr) }; ExportWorkSheetDatas(sheet_Infos); }
/// <summary> 陡坡路堤 </summary> public void ExportSteepSlope() { var steepSlopes = new List <CrossSectionRange <SteepSlope> >(); // 断面的判断与计算 double treatedWidth; double stairArea; SectionSide treatedSide; SectionSide reinforcementSide; foreach (var sec in _handledSections) { var isSteep = IsSteepSlope(sec, out treatedSide, out treatedWidth, out stairArea, out reinforcementSide); if (isSteep) { var hfdc = _sortedRanges[sec.XData.Station]; hfdc.BackValue.AverageTreatedWidth = treatedWidth; hfdc.BackValue.Treatment = treatedSide; hfdc.BackValue.Reinforcement = reinforcementSide; hfdc.BackValue.AverageStairArea = stairArea; // hfdc.FrontValue.AverageTreatedWidth = treatedWidth; hfdc.FrontValue.Treatment = treatedSide; hfdc.FrontValue.Reinforcement = reinforcementSide; hfdc.FrontValue.AverageStairArea = stairArea; // steepSlopes.Add(hfdc); } } var countAll = steepSlopes.Count; if (countAll == 0) { _docMdf.WriteNow($"陡坡路堤断面数量:{countAll}"); return; } // 对桥梁隧道结构进行处理:截断对应的区间 CutWithBlocks(steepSlopes, Options_Collections.RangeBlocks); // 将位于桥梁隧道区间之内的断面移除 steepSlopes = steepSlopes.Where(r => !r.IsNull).ToList(); // 对于区间进行合并 // steepSlopes = MergeLinkedSections(steepSlopes); steepSlopes = MergeLinkedSections <SteepSlope>(steepSlopes); countAll = steepSlopes.Count; _docMdf.WriteNow($"陡坡路堤断面数量:{countAll}"); if (countAll == 0) { return; } // 将结果整理为二维数组,用来进行表格输出 var rows = new List <object[]>(); var header = new object[] { "起始桩号", "结束桩号", "桩号区间", "左侧挖台阶", "右侧挖台阶", "左侧土工格栅", "右侧土工格栅", "段落长度", "挖台阶平均处理宽度", "挖台阶土方量", "土工格栅数量" }; rows.Add(header); for (int i = 0; i < steepSlopes.Count; i++) { var rg = steepSlopes[i]; rg.UnionBackFront(); // var reinfCount = 0; // 土工格栅数量 if (rg.BackValue.Reinforcement == SectionSide.左 || rg.BackValue.Reinforcement == SectionSide.右) { reinfCount = 1; } else if (rg.BackValue.Reinforcement == SectionSide.全幅) { reinfCount = 2; } var rangeLength = rg.FrontValue.EdgeStation - rg.BackValue.EdgeStation; rows.Add(new object[] { rg.BackValue.EdgeStation, rg.FrontValue.EdgeStation, SQUtils.GetStationString(rg.BackValue.EdgeStation, rg.FrontValue.EdgeStation, maxDigits: 0), // 挖台阶位置 (rg.BackValue.Treatment & SectionSide.左) > 0 ? SQConstants.CheckMark: null, (rg.BackValue.Treatment & SectionSide.右) > 0 ? SQConstants.CheckMark:null, // Enum.GetName(typeof (SectionSide), rg.BackValue.Treatment), // 土工格栅位置 (rg.BackValue.Reinforcement & SectionSide.左) > 0 ? SQConstants.CheckMark: null, (rg.BackValue.Reinforcement & SectionSide.右) > 0 ? SQConstants.CheckMark:null, // Enum.GetName(typeof (SectionSide), rg.BackValue.Reinforcement), rangeLength, // rg.BackValue.AverageTreatedWidth, rg.BackValue.AverageStairArea * rangeLength, // reinfCount, }); } var sheetArr = ArrayConstructor.FromList2D(listOfRows: rows); // sheetArr = sheetArr.InsertVector<object, string, object>(true, new[] { header }, new[] { -1.5f, }); // 输出到表格 var sheet_Infos = new List <WorkSheetData> { new WorkSheetData(WorkSheetDataType.SteepSlope, "陡坡路堤", sheetArr) }; ExportWorkSheetDatas(sheet_Infos); }
private List <SlopeLine> FilterSlopeLines() { // 左右侧 bool?leftOnly = null; if (radioButton_right.Checked) { leftOnly = false; } else if (radioButton_left.Checked) { leftOnly = true; } // 设置区间 var slps = new List <SlopeLine>(); if (checkBox_ChooseRangeOnUI.Checked) { // 通过界面选择边坡 slps = SQUtils.SelecteExistingSlopeLines(_docMdf, left: leftOnly, sort: true); } else { // 通过指定的桩号区间选择边坡 var startStation = textBoxNum_RangeStart.ValueNumber; var endStation = textBoxNum_RangeEnd.ValueNumber; if (startStation >= endStation) { MessageBox.Show(@"起始桩号必须小于结尾桩号"); return(null); } var secs = SQUtils.GetAllSections(_docMdf, sort: true); SectionInfo data; SlopeLine slp = null; foreach (var sec in secs) { data = sec.XData; if (data.Station >= startStation && data.Station <= endStation) { if (leftOnly.HasValue) { slp = sec.GetSlopeLine(leftOnly.Value); if (slp != null) { slps.Add(slp); } } else { slp = sec.GetSlopeLine(left: true); if (slp != null) { slps.Add(slp); } slp = sec.GetSlopeLine(left: false); if (slp != null) { slps.Add(slp); } } } } } // 检查填挖方 if (radioButton_fill.Checked) { slps = slps.Where(r => r.XData.FillCut).ToList(); } else if (radioButton_cut.Checked) { slps = slps.Where(r => !r.XData.FillCut).ToList(); } // return(slps); }
/// <summary> 纵向挖台阶处理 </summary> public void ExportLongitudinalStairExcav() { var stairs = new List <LongitudinalStairExcav>(); List <LongitudinalStairExcav> stairsInOneFillZone; var inters = _longitudinalSection.Intersects; if (inters.NumberOfIntersectionPoints == 0) { var middleFillHeight = _longitudinalSection.GetFillHeight((_longitudinalSection.RoadCurve2d.StartPoint.X + _longitudinalSection.RoadCurve2d.EndPoint.X) / 2); if (middleFillHeight < 0) { _docMdf.WriteNow("整个路段都为挖方"); return; } else { // 整个路段都为填方 stairsInOneFillZone = CalculateFillRange(_longitudinalSection.RoadCurve2d.StartPoint.X, _longitudinalSection.RoadCurve2d.EndPoint.X); stairs = stairsInOneFillZone; } } else { // 对填挖交界点进行处理 var lastIntersX = _longitudinalSection.RoadCurve2d.StartPoint.X; bool fillToCut = false; // 1. [道路起点 ~ 最后一个交点]之间的区段 for (int i = 0; i < inters.NumberOfIntersectionPoints; i++) { var ptRoad = inters.GetPointOnCurve1(i); var ptGround = inters.GetPointOnCurve2(i); var intersX = ptRoad.Point.X; // fillToCut = _longitudinalSection.FilltoCut(ptRoad, ptGround); if (fillToCut) { // 此交点与其前面一个交点之间为填方区 stairsInOneFillZone = CalculateFillRange(lastIntersX, intersX); if (stairsInOneFillZone != null) { stairs.AddRange(stairsInOneFillZone); } } lastIntersX = intersX; // } // 2. [最后一个交点 ~ 道路终点]之间的区段 if (!fillToCut) { stairsInOneFillZone = CalculateFillRange(lastIntersX, _longitudinalSection.RoadCurve2d.EndPoint.X); if (stairsInOneFillZone != null) { stairs.AddRange(stairsInOneFillZone); } } } // 排除桥梁等区间阻隔:删除所有与桥隧相交的台阶 var structs = Options_Collections.RangeBlocks; stairs = stairs.Where(st => !st.IntersectStructureBlocks(structs)).ToList(); // 区间合并 stairs = MergeLinkedStairs(stairs); _docMdf.WriteNow($"纵向挖台阶数量:{stairs.Count}"); // // 将结果整理为二维数组,用来进行表格输出 var rows = new List <object[]>(); var header = new object[] { "起点", "终点", "区间", "段落长度", "纵向挖台阶面积" }; rows.Add(header); foreach (var stair in stairs) { rows.Add(new object[] { stair.StartStation, stair.EndStation, SQUtils.GetStationString(stair.StartStation, stair.EndStation, 0), stair.EndStation - stair.StartStation, stair.StairArea, }); } var sheetArr = ArrayConstructor.FromList2D(listOfRows: rows); // sheetArr = sheetArr.InsertVector<object, string, object>(true, new[] { header }, new[] { -1.5f, }); // 输出到表格 var sheet_Infos = new List <WorkSheetData> { new WorkSheetData(WorkSheetDataType.StairsExcavLong, "纵向挖台阶", sheetArr) }; DataExporter.ExportWorkSheetDatas(sheet_Infos); }
/// <summary> 沿着道路纵向绘制边坡线 </summary> public ExternalCmdResult LongitudinalSection(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); var allSections = SQUtils.GetAllSections(docMdf, sort: true); if (allSections == null || allSections.Length <= 2) { return(ExternalCmdResult.Cancel); } if (allSections.Length > 1) { // var allStations = allSections.Select(r => r.XData.Station).ToArray(); var minStation = allStations.First(); // // 每一个桩号所对应的某一侧的挡墙顶与挡墙底相对于道路中线的高度,如果某桩号中没有挡墙,则其值为 null var leftRetainingWalls = new Dictionary <double, double[]>(); var rightRetainingWalls = new Dictionary <double, double[]>(); var leftSlps = ConstructLeftSlope(allSections, true, out leftRetainingWalls); var rightSlps = ConstructLeftSlope(allSections, false, out rightRetainingWalls); // 选择绘图的基点 Point3d p3; var succ = GetBasePt(_docMdf, out p3); if (!succ) { return(ExternalCmdResult.Cancel); } var basePt2D = new Point2d(p3.X, p3.Y); // double rx = 0.25; double ry = 2; // var ss = EditStateIdentifier.GetCurrentEditState(_docMdf); ss.CurrentBTR.UpgradeOpen(); var layer_Slope = SymbolTableUtils.GetOrCreateLayer(_docMdf.acTransaction, _docMdf.acDataBase, SQConstants.LayerName_LongitudinalSlopes); var originalLayer = docMdf.acDataBase.Clayer; docMdf.acDataBase.Clayer = layer_Slope.Id; // 绘制中轴线 var roadCenterPl = CreatePolyline(allStations, new double[allStations.Length], basePt2D, minStation, rx, ry); ss.CurrentBTR.AppendEntity(roadCenterPl); _docMdf.acTransaction.AddNewlyCreatedDBObject(roadCenterPl, true); // 绘制桩号 var txts = CreateDbTexts(allStations, new double[allStations.Length], basePt2D, minStation, rx, ry); foreach (var txt in txts) { ss.CurrentBTR.AppendEntity(txt); _docMdf.acTransaction.AddNewlyCreatedDBObject(txt, true); } // 绘制左边坡线 var leftPl = CreatePolyline(leftSlps.Keys.ToArray(), leftSlps.Values.ToArray(), basePt2D, minStation, rx, ry); leftPl.LineWeight = LineWeight.LineWeight013; leftPl.Color = Color.FromColor(System.Drawing.Color.Green); ss.CurrentBTR.AppendEntity(leftPl); _docMdf.acTransaction.AddNewlyCreatedDBObject(leftPl, true); // 绘制右边坡线 var rightPl = CreatePolyline(rightSlps.Keys.ToArray(), rightSlps.Values.ToArray(), basePt2D, minStation, rx, ry); rightPl.LineWeight = LineWeight.LineWeight013; rightPl.Color = Color.FromColor(System.Drawing.Color.Red); ss.CurrentBTR.AppendEntity(rightPl); _docMdf.acTransaction.AddNewlyCreatedDBObject(rightPl, true); // 绘制左边挡墙 var leftRetainingWallRanges = GetRetainingWallRanges(leftRetainingWalls); foreach (var rwr in leftRetainingWallRanges) { var pl = CreatePolyline(ArrayConstructor.GetColumn(rwr, 0), ArrayConstructor.GetColumn(rwr, 1), basePt2D, minStation, rx, ry); pl.Closed = true; pl.Color = Color.FromColor(System.Drawing.Color.LightGreen); pl.LineWeight = LineWeight.LineWeight050; ss.CurrentBTR.AppendEntity(pl); _docMdf.acTransaction.AddNewlyCreatedDBObject(pl, true); } // 绘制右边挡墙 var rightRetainingWallRanges = GetRetainingWallRanges(rightRetainingWalls); foreach (var rwr in rightRetainingWallRanges) { var pl = CreatePolyline(ArrayConstructor.GetColumn(rwr, 0), ArrayConstructor.GetColumn(rwr, 1), basePt2D, minStation, rx, ry); pl.Closed = true; pl.Color = Color.FromColor(System.Drawing.Color.DeepPink); pl.LineWeight = LineWeight.LineWeight050; ss.CurrentBTR.AppendEntity(pl); _docMdf.acTransaction.AddNewlyCreatedDBObject(pl, true); } // docMdf.acDataBase.Clayer = originalLayer; ss.CurrentBTR.DowngradeOpen(); } return(ExternalCmdResult.Commit); }
private object[] GetRow() { return(new object[] { StartStation, EndStation, SQUtils.GetStationString(StartStation, EndStation, maxDigits: 0), EndStation - StartStation, Area, ProtectionName, GetDescription() }); }
/// <summary> 软基换填 </summary> public void ExportSubstitutionSoil() { var softSubSections = new List <CrossSectionRange <SubstitutedSoil> >(); // 断面的判断与计算 double treatedGroundLength; foreach (var sec in _sectionsToHandle) { var xdata = sec.XData; if (IsSoftSub(_docMdf.acDataBase, sec, out treatedGroundLength)) { var thsc = _sortedRanges[xdata.Station]; // thsc.BackValue.TreatedSurfaceArea = treatedGroundLength * Math.Abs(thsc.BackValue.EdgeStation - thsc.BackValue.ParentStation); thsc.FrontValue.TreatedSurfaceArea = treatedGroundLength * Math.Abs(thsc.FrontValue.EdgeStation - thsc.FrontValue.ParentStation); // softSubSections.Add(thsc); } } var countAll = softSubSections.Count; if (countAll == 0) { _docMdf.WriteNow($"软基换填断面的数量:{countAll}"); return; } // 对桥梁隧道结构进行处理:截断对应的区间 CutWithBlocks(softSubSections, Options_Collections.RangeBlocks); // 将位于桥梁隧道区间之内的断面移除 softSubSections = softSubSections.Where(r => !r.IsNull).ToList(); // 对于区间进行合并 softSubSections = MergeLinkedSections(softSubSections); countAll = softSubSections.Count; _docMdf.WriteNow($"软基换填断面的数量:{countAll}"); if (countAll == 0) { return; } // 将结果整理为二维数组,用来进行表格输出 var rows = new List <object[]>(); var header = new string[] { "起始桩号", "结束桩号", "桩号区间", "长度", "处理措施", "换填表面积", }; rows.Add(header); for (int i = 0; i < softSubSections.Count; i++) { var thsc = softSubSections[i]; thsc.UnionBackFront(); // rows.Add(new object[] { thsc.BackValue.EdgeStation, thsc.FrontValue.EdgeStation, SQUtils.GetStationString(thsc.BackValue.EdgeStation, thsc.FrontValue.EdgeStation, maxDigits: 0), thsc.FrontValue.EdgeStation - thsc.BackValue.EdgeStation, thsc.BackValue.GetDescription(), thsc.BackValue.TreatedSurfaceArea, }); } var sheetArr = ArrayConstructor.FromList2D(listOfRows: rows); // sheetArr = sheetArr.InsertVector<object, string, object>(true, new[] { header }, new[] { -1.5f, }); var sheet_Infos = new List <WorkSheetData> { new WorkSheetData(WorkSheetDataType.ThinFillShallowCut, "路基换填", sheetArr) }; ExportWorkSheetDatas(sheet_Infos); }