zoukankan      html  css  js  c++  java
  • ArcEngine将线符号化为立方体状

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

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

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

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

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

    C#代码  收藏代码
    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.             //定义走向线段  
    12.             ILine extrusionLine = new LineClass();  
    13.             extrusionLine.FromPoint = fPoint;  
    14.             extrusionLine.ToPoint = tPoint;  
    15.             double myToZ = extrusionLine.Length;        //线段长度  
    16.   
    17.   
    18.             //初始化截面形状  
    19.             IPointCollection polygonPointCollection = new PolygonClass();  
    20.             polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), (width / 2)),ref _missing, ref _missing);  
    21.             polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), (width / 2)), ref _missing, ref _missing);  
    22.             polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D((height / 2), -(width / 2)), ref _missing, ref _missing);  
    23.             polygonPointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-(height / 2), -(width / 2)), ref _missing, ref _missing);  
    24.   
    25.             IPolygon polygon = polygonPointCollection as IPolygon;  
    26.             polygon.Close();  
    27.   
    28.             IGeometry polygonGeometry = polygonPointCollection as IGeometry;  
    29.   
    30.             ITopologicalOperator topologicalOperator = polygonGeometry as ITopologicalOperator;  
    31.             topologicalOperator.Simplify();  
    32.   
    33.   
    34.             //Perform Extrusion  
    35.             IConstructMultiPatch constructMultiPatch = new MultiPatchClass();  
    36.             constructMultiPatch.ConstructExtrudeFromTo(0, myToZ, polygonGeometry);  
    37.   
    38.             //旋转角度  
    39.             ITransform3D transform3D = constructMultiPatch as ITransform3D;  
    40.             transform3D.RotateVector3D(axisOfRotationVector3D_Y, tarPointV3D.Inclination);  
    41.             transform3D.RotateVector3D(axisOfRotationVector3D_Z, GeometryUtilities.GetRadians(90) - tarPointV3D.Azimuth);  
    42.   
    43.             //移动到起点  
    44.             transform3D.Move3D(fPoint.X, fPoint.Y, fPoint.Z);  
    45.   
    46.             return constructMultiPatch as IGeometry;  
    47.         } 
  • 相关阅读:
    el-checkbox-group设置每行固定数量(左对齐)
    jsonObject.toJSONString()将数
    aspose bookmark _GoBack
    HttpMessageNotReadableException: Required request body is missing:
    vs2019快捷键
    gitlab 汉化
    sql server in vs exists
    win10彻底解决时间同步不一致的问题
    how to cracked office2019
    直接从官网下载Windows 10 ISO文件
  • 原文地址:https://www.cnblogs.com/bobzhangfw/p/3815068.html
Copyright © 2011-2022 走看看