Exemplo n.º 1
0
        /// <summary> 按标高将边坡对象进行分割,以实现同一级边坡中分别设置不同的防护形式 </summary>
        private void CutSlopes(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 = eZcad.SubgradeQuantity.Utility.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;
            int     cutCount = 0;

            docMdf.WriteLineIntoDebuger("被分割的边坡对象:");
            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);
                    slp.XData.Waterlines.Add(line.Handle);

                    // 将刷新后的数据保存到 AutoCAD 文档与界面中
                    slp.Pline.UpgradeOpen();
                    SlopeConstructor.SetSlopeUI(slp);
                    slp.PrintProtectionMethod(es.CurrentBTR, protLayers);
                    slp.FlushXData();
                    slp.Pline.DowngradeOpen();
                    //
                    cutCount += 1;
                    docMdf.WriteLineIntoDebuger(slp);
                }
            }
            es.CurrentBTR.DowngradeOpen();
            docMdf.WriteLineIntoDebuger($"总计:{cutCount} 个");
        }
Exemplo n.º 2
0
        /// <summary> 将一侧边坡中的所有子边坡进行缝合 </summary>
        /// <param name="slpDt"></param>
        /// <param name="dir"></param>
        /// <returns>如果成功缝合,则返回 true,如果此侧边坡中原来就没有被分割,则返回 false</returns>
        private bool MergeSlope(SlopeData slpDt, MergeProtectionDirection dir)
        {
            bool merged           = false;
            var  newSlopes        = new List <Slope>();
            var  lastSubSlopeSegs = new List <Slope>();

            if (slpDt.Slopes.Count > 0)
            {
                int lastMainLevel = slpDt.Slopes[0].GetMainLevel();
                foreach (var s in slpDt.Slopes)
                {
                    if (s.GetMainLevel() != lastMainLevel)
                    {
                        // 先处理上一级子边坡中的所有更细子边坡
                        if (lastSubSlopeSegs.Count > 0)
                        {
                            var mergedSlope = MergeSubSlopes(lastSubSlopeSegs, slpDt.FillCut, dir);
                            merged = true;
                            newSlopes.Add(mergedSlope);
                            lastSubSlopeSegs = new List <Slope>();
                        }
                        //
                        lastMainLevel = s.GetMainLevel();
                    }
                    if (s.GetSubLevel() != 0)
                    {
                        SlopeLine.EraseText(s, _docMdf.acDataBase);
                        lastSubSlopeSegs.Add(s);
                    }
                    else
                    {
                        // 将本级子边坡添加进来
                        newSlopes.Add(s);
                    }
                }
                // 处理最后一级的多个细子边坡
                if (lastSubSlopeSegs.Count > 0)
                {
                    var mergedSlope = MergeSubSlopes(lastSubSlopeSegs, slpDt.FillCut, dir);
                    merged = true;
                    newSlopes.Add(mergedSlope);
                }
            }
            slpDt.Slopes = newSlopes;
            return(merged);
        }