对于二三维同步中的三维视图肯定是需要通过二维元素来符号化成三维元素的,之前项目测试临时采用这个自代的圆管状:
esriSimple3DLineStyle AxisStyle = esriSimple3DLineStyle.esriS3DLSTube; 进行符号化,但是这个自带样式不能做更多的扩展,仍然需要对它进行手动graphic,今天花了半天时间看了下官方的例子,总算是捣鼓出了将指定坐标的两个点连成的线符号化成正方体状,中间也碰到一些问题。本以为arcengine提供了相当好的API,我只用传入两个点或是一根线,再给它一个Polygon,它就能帮我沿着这个线的方向画成正方体了,可是弄来弄去,不是位置不对,就是角度有问题,官方的例子过于简单,拿到我的应用中根本不能使用,于是分析了一下原因,采用以下三步:
第一步: 空间有根线,起点和终点肯定可以得到,我要沿这个线符号化成立方体,那么两点的长度肯定要用到。我们就在坐标原点沿Z坐标画一个立方体,高就是上面提到的线长。
第二步: 我们假定这根线的起点为(0,0,0),即我自定义的原点,通过IVector3D接口很容易得到这根线的偏移角度。这样就在原点把上面那个立方体给进行两次旋转得到正确的线段走向。
第三步: 将第二步的立方体平移到起点位置,完工。
public static IGeometry getCubeTubeByLinePoint(IPoint fPoint, IPoint tPoint, double width, double height)
{
//IPoint fPoint = GeometryUtilities.ConstructPoint3D(5, 6, 3);
//IPoint tPoint = GeometryUtilities.ConstructPoint3D(15, 13, 13);
//计算走向-->移动坐标原点
IVector3D tarPointV3D = GeometryUtilities.ConstructVector3D(tPoint.X - fPoint.X, tPoint.Y - fPoint.Y, tPoint.Z - fPoint.Z);
//定义两次旋转的轴线
IVector3D axisOfRotationVector3D_Y = GeometryUtilities.ConstructVector3D(0, 10, 0);
IVector3D axisOfRotationVector3D_Z = GeometryUtilities.ConstructVector3D(0, 0, 10);
//定义走向线段
ILine extrusionLine = new LineClass();
extrusionLine.FromPoint = fPoint;
extrusionLine.ToPoint = tPoint;
double myToZ = extrusionLine.Length; //线段长度
//初始化截面形状
IPointCollection polygonPointCollection = new PolygonClass();
polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), (width / 2)),ref _missing, ref _missing);
polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), (width / 2)), ref _missing, ref _missing);
polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), -(width / 2)), ref _missing, ref _missing);
polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), -(width / 2)), ref _missing, ref _missing);
IPolygon polygon = polygonPointCollection as IPolygon;
polygon.Close();
IGeometry polygonGeometry = polygonPointCollection as IGeometry;
ITopologicalOperator topologicalOperator = polygonGeometry as ITopologicalOperator;
topologicalOperator.Simplify();
//Perform Extrusion
IConstructMultiPatch constructMultiPatch = new MultiPatchClass();
constructMultiPatch.ConstructExtrudeFromTo(0, myToZ, polygonGeometry);
//旋转角度
ITransform3D transform3D = constructMultiPatch as ITransform3D;
transform3D.RotateVector3D(axisOfRotationVector3D_Y, tarPointV3D.Inclination);
transform3D.RotateVector3D(axisOfRotationVector3D_Z, GeometryUtilities.GetRadians(90) - tarPointV3D.Azimuth);
//移动到起点
transform3D.Move3D(fPoint.X, fPoint.Y, fPoint.Z);
return constructMultiPatch as IGeometry;
}
分享到:
相关推荐
ARCENGINE地图符号编程
ArcEngine开发,用线裁切面,能实现对多边形的批量裁切
程序是基于ArcEngine9.3开发的,开发平台为Visual Studio 2008,开发语言为c#,数据为china文件夹下的数据,使用的符号为ArcGIS自带的符号库ESRI.ServerStyle中的符号。 所以安装了ArcEngine9.3和vs2008的可以直接...
该代码实现了根据指定的符号名称获取ArcGIS,serverstyle中的符号,并使得图层以该符号显示
ArcEngine 地图符号化总结 是否新手入门
ArcEngine+C#右键符号选择器完美实现! 可以直接调用ArcMap中的符号选择器,也可以使用自定义的符号选择器。
包含矢量和栅格的符号化渲染,语言C# ArcEngine,栅格包括拉伸和分级渲染,矢量包括简单、唯一值、分级、比例渲染
将arcmap的符号文件style转换成arcengine下的serverstyle文件
刚学AE的人肯定想知道怎么用ArcEngine生成点线面,附上自编的生成点线面的程序,环境是visual studio2010
基于ArcEngine符号系统的实现与扩展
介绍在ArcEngine中实现地图的符号。
韩鹏的ARCENGINE 源韩鹏的ARCENGINE 源代码韩鹏的ARCENGINE 源代码代码
arcengine 唯一值渲染符号化源码 工具Vs +arcgis +devexpress
ArcEngine基于C#的开发 ,修改地图路径后就能完整的显示地图的操作功能。
ArcEngine环境下的地图符号化 实现各种地图符号的显示绘制 仅供学习
ArcEngine开发实现将地图视图导出成图片
ArcEngine+C#实现ArcGIS的Swipe卷帘功能
arcengine9.2点生成等高线程序,可能有些乱,但还是很有参考意义的
arcengine 批量符号化mxd,保存mxd文档
ArcEngine符号