当前位置: 首页 > wzjs >正文

深圳自适应网站建设长沙网络公司营销推广

深圳自适应网站建设,长沙网络公司营销推广,深圳龙华 网站建设,网站建设新方式简单省时近日项目处理中,在遍历多义线的时候,发现客户的图纸有【二维多段线】这个类型,需要做兼容处理,因此总结记录一下。 在 AutoCAD 里,LWPOLYLINE(轻量级多段线,命令是PL,下图左&#x…

近日项目处理中,在遍历多义线的时候,发现客户的图纸有【二维多段线】这个类型,需要做兼容处理,因此总结记录一下。

在 AutoCAD 里,LWPOLYLINE(轻量级多段线,命令是PL,下图左)和POLYLINE(多段线,本次主要讲述二维多段线,下图右)都是用来表示由多个线段或圆弧连接而成的图形对象,通过属性可以简单查看两者的内容:

1. 数据结构与存储

  • LWPOLYLINE
    • 它属于轻量级对象,存储数据时更为紧凑。相较于POLYLINELWPOLYLINE占用的内存和磁盘空间更少,这使得在处理大量多段线对象时,能有效提升性能。
    • 其顶点信息以连续的坐标对形式存储,数据结构较为简单,这也进一步减少了存储空间。
  • POLYLINE
    • 这是一种传统的多段线对象,数据结构相对复杂。它不仅包含顶点信息,还包含更多的属性和扩展数据,因此占用的存储空间更多。

2. 图形特性

  • LWPOLYLINE
    • 只能是二维对象,仅存在于当前 UCS(用户坐标系)的 XY 平面上。
    • 各顶点间的连接方式只能是直线段或圆弧,不能包含其他复杂的曲线。
  • POLYLINE
    • 既可以是二维对象,也可以是三维对象,能在三维空间中表示多段线。
    • 除了直线段和圆弧,还可以包含其他类型的曲线,如样条曲线等,具有更强的图形表达能力。

通过插件,查看两者的组码,内容如下:

从上面的两个图可见,两者组码"0",即它们的类型是不一样的。组码"0"也是从图纸筛选过滤的类型条件。

笔者通过策略模式,封装了两种模式的顶点遍历方案,核心代码如下:

// 顶点处理策略接口public interface IVertexProcessingStrategy{void ProcessVertices(Entity entity, List<CPointInfo> list);}// 顶点处理策略基类public abstract class VertexProcessingStrategyBase : IVertexProcessingStrategy{public abstract void ProcessVertices(Entity entity, List<CPointInfo> list);public CPointInfo ProcessVertex(Point3d vertex3d){System.Globalization.CultureInfo cultures = new System.Globalization.CultureInfo("en-US");Point3d ptLocation = CommonDeal.TransToLayout_3d(m_vp, vertex3d);return (new CPointInfo(){Num = (listRailCar_RedPointInfo.Count + 1).ToString(),XPos = vertex3d.X.ToString("f1", cultures),YPos = vertex3d.Y.ToString("f1", cultures),location = MathKit.Trans2XYZPoint(vertex3d)});}}// LWPOLYLINE 顶点处理策略public class LwPolylineVertexProcessingStrategy : VertexProcessingStrategyBase{public override void ProcessVertices(Entity entity, List<CPointInfo> list){var lwPoly = entity as Autodesk.AutoCAD.DatabaseServices.Polyline;if (lwPoly != null){int iNumberOfVertices = lwPoly.NumberOfVertices;for (int j = 0; j < iNumberOfVertices; j++){Point2d pt2d = lwPoly.GetPoint2dAt(j);CPointInfo processedPoint = ProcessVertex(new Point3d(pt2d.X, pt2d.Y, 0.0));list.Add(processedPoint);}}}}// POLYLINE 顶点处理策略public class PolylineVertexProcessingStrategy : VertexProcessingStrategyBase{public override void ProcessVertices(Entity entity, List<CPointInfo> list){var poly = entity as Autodesk.AutoCAD.DatabaseServices.Polyline2d;if (poly != null){Point3dCollection aaa = new Point3dCollection();poly.GetStretchPoints(aaa);int nn = aaa.Count;for (int i = 0; i < nn; i++){CPointInfo processedPoint = ProcessVertex(aaa[i]);list.Add(processedPoint);}}}}// 顶点处理上下文public class VertexProcessingContext{private IVertexProcessingStrategy _strategy;public VertexProcessingContext(IVertexProcessingStrategy strategy){_strategy = strategy;}public void SetStrategy(IVertexProcessingStrategy strategy){_strategy = strategy;}public void Process(Entity entity, List<CPointInfo> list){_strategy.ProcessVertices(entity, list);}}public void DealTwoTypePolyline(string sPLineLayer, string sLayoutName = ""){Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;// 定义筛选条件TypedValue[] values = new TypedValue[]{// 图元类型为LWPOLYLINE或POLYLINEnew TypedValue((int)DxfCode.Start, "LWPOLYLINE,POLYLINE"),// 图层为sPLineLayernew TypedValue((int)DxfCode.LayerName, sPLineLayer),// 布局名称为sLayoutNamenew TypedValue((int)DxfCode.LayoutName, sLayoutName)};SelectionFilter filter = new SelectionFilter(values);PromptSelectionResult psr;{psr = ed.SelectAll(filter);}if (psr.Status != PromptStatus.OK){return ;}Document document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;Database db = document.Database;List<CPointInfo> listCPointInfo = new List<CPointInfo>();using (Transaction tr = db.TransactionManager.StartTransaction()){BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);var lwPolyStrategy = new LwPolylineVertexProcessingStrategy();var polyStrategy = new PolylineVertexProcessingStrategy();var context = new VertexProcessingContext(lwPolyStrategy);ObjectId[] ids = psr.Value.GetObjectIds();for (int i = 0; i < ids.Length; i++){Entity ent = (Entity)tr.GetObject(ids[i], OpenMode.ForRead);if (ent is Autodesk.AutoCAD.DatabaseServices.Polyline){context.SetStrategy(lwPolyStrategy);}else if (ent is Autodesk.AutoCAD.DatabaseServices.Polyline2d){context.SetStrategy(polyStrategy);}else{continue;}context.Process(ent, listCPointInfo);}tr.Commit();}}
http://www.dtcms.com/wzjs/65883.html

相关文章:

  • 微信群领券网站怎么做怎么开通网站平台
  • 企业是做app还是做网站网站维护工程师
  • 阿里巴巴网站上面产品描述一般怎么做的seo怎么做?
  • 做水果为主的b2c网站有哪些流量宝官网
  • 如何让单位网站做防护谷歌seo最好的公司
  • 英文版科技网站成都新闻最新消息
  • 那种漂亮的网站怎么做的百度电脑端入口
  • 上线了 做商务网站全球搜钻是什么公司
  • 石家庄的网站开发公司搜索引擎优化师工资
  • 怎么做娱乐电玩网站汕头seo优化
  • 小程序开发代码seo推广排名公司
  • 网站快速收录方法百度怎么免费推广自己的产品
  • 济宁北湖建设局网站网络搭建的基本流程
  • 三亚旅游攻略北京seo外包
  • 广州网站建设 企业关联词有哪些 全部
  • 凤翔做网站百度推广托管
  • 做家教需要什么哪个网站的会员seo优化网站快速排名
  • 电子设计工程期刊哪家公司做推广优化好
  • 青岛做网站报价台州seo公司
  • Hdi做指数网站网络舆情案例分析
  • 泰安可以做网站的公司线上销售怎么做推广
  • 湖州网站做等保费用百度seo快速
  • 上海外贸网站国内推广平台有哪些
  • 用自己照片做衣服_杯子的是哪个网站seo网站建设
  • 广告传媒公司名字取名搜狗优化排名
  • 做外贸网站代理商百度账号一键登录
  • 网站开发与设计 信科seo诊断的网络问题
  • 蚂蚁中国网站建设东莞市网站建设
  • 电子商务网站建设对毕业设计淘宝直通车
  • 浙江建设职业技术学校网站登录写文章免费的软件