对于二三维同步中的三维视图肯定是需要通过二维元素来符号化成三维元素的,之前项目测试临时采用这个自代的圆管状:

esriSimple3DLineStyle AxisStyle = esriSimple3DLineStyle.esriS3DLSTube; 进行符号化,但是这个自带样式不能做更多的扩展,仍然需要对它进行手动 graphic,今天花了半天时间看了下官方的例子,总算是捣鼓出了将指定坐标的两个点连成的线符号化成正方体状,中间也碰到一些问题。本以为 arcengine提供了相当好的API,我只用传入两个点或是一根线,再给它一个Polygon,它就能帮我沿着这个线的方向画成正方体了,可是弄来弄 去,不是位置不对,就是角度有问题,官方的例子过于简单,拿到我的应用中根本不能使用,于是分析了一下原因,采用以下三步:

第一步: 空间有根线,起点和终点肯定可以得到,我要沿这个线符号化成立方体,那么两点的长度肯定要用到。我们就在坐标原点沿Z坐标画一个立方体,高就是上面提到的线长。

第二步: 我们假定这根线的起点为(0,0,0),即我自定义的原点,通过IVector3D接口很容易得到这根线的偏移角度。这样就在原点把上面那个立方体给进行两次旋转得到正确的线段走向。

第三步: 将第二步的立方体平移到起点位置,完工。

  1. public static IGeometry getCubeTubeByLinePoint(IPoint fPoint, IPoint tPoint, double width, double height)
  2. {
  3. //IPoint fPoint = GeometryUtilities.ConstructPoint3D(5, 6, 3);
  4. //IPoint tPoint = GeometryUtilities.ConstructPoint3D(15, 13, 13);
  5. //计算走向-->移动坐标原点
  6. IVector3D tarPointV3D = GeometryUtilities.ConstructVector3D(tPoint.X - fPoint.X, tPoint.Y - fPoint.Y, tPoint.Z - fPoint.Z);
  7. //定义两次旋转的轴线
  8. IVector3D axisOfRotationVector3D_Y = GeometryUtilities.ConstructVector3D(0, 10, 0);
  9. IVector3D axisOfRotationVector3D_Z = GeometryUtilities.ConstructVector3D(0, 0, 10);
  10. //定义走向线段
  11. ILine extrusionLine = new LineClass();
  12. extrusionLine.FromPoint = fPoint;
  13. extrusionLine.ToPoint = tPoint;
  14. double myToZ = extrusionLine.Length;        //线段长度
  15. //初始化截面形状
  16. IPointCollection polygonPointCollection = new PolygonClass();
  17. polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), (width / 2)),ref _missing, ref _missing);
  18. polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), (width / 2)), ref _missing, ref _missing);
  19. polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), -(width / 2)), ref _missing, ref _missing);
  20. polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), -(width / 2)), ref _missing, ref _missing);
  21. IPolygon polygon = polygonPointCollection as IPolygon;
  22. polygon.Close();
  23. IGeometry polygonGeometry = polygonPointCollection as IGeometry;
  24. ITopologicalOperator topologicalOperator = polygonGeometry as ITopologicalOperator;
  25. topologicalOperator.Simplify();
  26. //Perform Extrusion
  27. IConstructMultiPatch constructMultiPatch = new MultiPatchClass();
  28. constructMultiPatch.ConstructExtrudeFromTo(0, myToZ, polygonGeometry);
  29. //旋转角度
  30. ITransform3D transform3D = constructMultiPatch as ITransform3D;
  31. transform3D.RotateVector3D(axisOfRotationVector3D_Y, tarPointV3D.Inclination);
  32. transform3D.RotateVector3D(axisOfRotationVector3D_Z, GeometryUtilities.GetRadians(90) - tarPointV3D.Azimuth);
  33. //移动到起点
  34. transform3D.Move3D(fPoint.X, fPoint.Y, fPoint.Z);
  35. return constructMultiPatch as IGeometry;
  36. }

ArcEngine将线符号化为立方体状的更多相关文章

  1. ArcEngine 创建线要素图层

    在创建要素图层的时候,默认的几何类型是Polygon: Dim objectClassDescription As IObjectClassDescription = New FeatureClass ...

  2. ArcEngine 9.3 学习笔记(六):图层符号化(COlorRamp,MarkerSymbol,LineSymbol,FillSymbol,TextSymbol,3DChartSymbol,使用ServerStyle符号库,FeatureRender,RasterRender)

    第四章 图层符号化 AE9.3 提供了SymbologyControl控件,用于显示ARCGIS符号库中的符号. 组件库中的组件对象分为Color(颜色),Symbol(符号),Render(渲染)三 ...

  3. 【ESRI论坛6周年征文】ArcEngine注记(Anno/ Label/Element等)处理专题 -入门篇

    原发表于ESRI中国社区,转过来.我的社区帐号:jhlong http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=122097 ----------- ...

  4. ArcGIS制图表达Representation实战篇2-河流渐变与符号旋转

    ArcGIS制图表达Representation实战篇2-河流渐变与符号旋转 by 李远祥 上一章节主要是从实战中使用规则和几何效果,如何分解制图规则.本章主要还是通过一些特殊要求如河流线宽渐变和符号 ...

  5. 创建线注记LineElement

    1.根据2点创建一条线 /// <summary> /// 创建线 /// </summary> /// <param name="pnt1"> ...

  6. ArcEngine开发:IElement.Geometry 值不在预期范围内 + 元素绘制代码

    IElement pEle = pLineEle as IElement; pEle.Geometry = pLn; pLn为一个ILine对象,想当然的以为它是IGeometry对象,可以赋值,结果 ...

  7. 基于ArcEngine与C#的鹰眼地图实现

    鹰眼图是对全局地图的一种概略表达,具有与全局地图的空间参考和空间范围.为了更好起到空间提示和导航作用,有些还具备全局地图中重要地理要素,如主要河流.道路等的概略表达.通过两个axMapControl控 ...

  8. 《ArcGIS Engine+C#实例开发教程》第七讲 图层符号选择器的实现2

    原文:<ArcGIS Engine+C#实例开发教程>第七讲 图层符号选择器的实现2 摘要:在第七讲 图层符号选择器的实现的第一阶段中,我们完成了符号选择器窗体的创建与调用.在第二阶段中, ...

  9. 符号化Symbol(符号)体系

    http://apps.hi.baidu.com/share/detail/23143648# 符号化Symbol(符号)体系 ArcGIS Engine9.3为开发人员提供了32种符号,主要分为三大 ...

随机推荐

  1. 烂泥:linux文件同步之rsync学习(一)

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 这几天刚好有空就打算开始学习linux下的文件同步软件rsync,在学习rsync时,我们可以分以下几个步骤进行: 1. rsync是什么 2. rsy ...

  2. iOS UIAlertView添加输入框

    这玩意有时不用就忘,还是记录一下吧 添加: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"新建文件夹" mes ...

  3. linux系统的任务计划crontab使用详解

    linux系统的任务计划crontab使用详解 其实大部分系统管理工作都是通过定期自动执行某一个脚本来完成的,那么如何定期执行某一个脚本呢?这就要借助linux的cron功能了. 关于cron任务计划 ...

  4. LeetCode#227.Basic Calculator II

    题目 Implement a basic calculator to evaluate a simple expression string. The expression string contai ...

  5. 10、WGET

    这个我看过比较好的  http://www.cnblogs.com/peida/archive/2013/03/18/2965369.html WGET 支持HTTP和FTP协议,断点续传功能,自动递 ...

  6. arc如何破循环或交叉引用

    IOS两种常见的循环引用: 1,两个类之间互相定义对方的引用 如下: //ARC code @interface A : NSObject @property (nonatomic,strong) B ...

  7. C# 中 SQLite 使用介绍

    关于SQLite SQLite是一款轻型的嵌入式的遵守ACID的关系型数据库管理系统,诞生已有15个年头了.随着移动互联的发展,现在得到了更广泛的使用. 在使用SQLite之前,我们势必要先了解它一些 ...

  8. [麦先生]Laravel框架实现发送短信验证

    今天在做到用户注册和个人中心的安全管理时,我借助实现第三方短信平台在Laravel框架中进行手机验证的设置;  由于我们做的是一个为客户提供医疗咨询和保健品网站,所以对客户个人隐私的保护显得尤为重要, ...

  9. windows 10 & Office 2016 安装

    Office 2016 VOL版    http://blog.sina.com.cn/s/blog_470614a90102vtmc.html 专业版合集: magnet:?xt=urn:btih: ...

  10. Objective-C if语句处理 BOOL值不为1和0的情况

    BOOL ,布尔值,在Objective-C ,BOOL类型被typedef为signed char(有符号的整型),YES被#define为1,NO被#define为0. 事实上,xcode的编译器 ...