• AE开发中ICircularArc接口的图形要素保存与形状简化--原创


    在AE开发中,开发编辑 shapefile功能 时需要有时候需要绘制椭圆和圆弧功能。

    绘制椭圆使用的时接口IEllipticArc的 PutcoordsByAngle方法,其参数见下图

    绘制圆弧功能使用的是 ICircularArc 的 PutCoords()方法

    使用上面两个方法生成形状如何保存到Feature呢? 具体代码见下

    1 ICircularArc circularArc = new CircularArcClass();
    2 circularArc.PutCoords(输入参数);
    3 IPolyline circularFeatPolyline = new PolylineClass();
    4 ISegmentCollection segementColl = (ISegmentCollection)circularFeatPolyline;
    5 ISegment segment = (ISegment)circularArc ;
    6 segementColl.AddSegment(segment);

    之后再将Polyline的Goemetry赋给Feature即可。IEllipticArc的形状保存方法类似

    这样生成的Polyline的点在编辑状态是非常多的,但是在代码获得Polyline节点的时候只有FromPoint和ToPoint两个点。 如果要继续由Polyline转成TIN效率非常慢。于是需要简化形状。算法主要使用的是IPolyline接口的QueryPoint方法

     1         /// <summary>
     2         /// 查询曲线上离起点固定距离的点位坐标
     3         /// </summary>
     4         /// <param name="polyline"></param>
     5         /// <param name="distance"></param>
     6         /// <returns></returns>
     7         private IPoint queryPointByDistance(IPolyline polyline, double distance)
     8         {
     9             IPoint outPoint = new PointClass();
    10             polyline.QueryPoint(esriSegmentExtension.esriNoExtension, distance, false, outPoint);
    11             return outPoint;
    12         }        
    13        /// <summary>
    14         /// 简化系统CiurlarArc曲线上的点个数,提高生成TIN的效率
    15         /// </summary>
    16         /// <param name="inputPolyline">输入的Poyline</param>
    17         /// <param name="pointCount">加上线两个断点在内的一共平分成的端点的个数</param>
    18         /// <returns>新生成的Polyline</returns>
    19         private IPolyline simplifyPolyline(IPolyline inputPolyline, int pointCount)
    20         {
    21             IPolyline outPolyline = new PolylineClass();
    22             IPointCollection pointCollection = (IPointCollection)outPolyline;
    23             double distance = inputPolyline.Length / (pointCount - 1);
    24             for (int i = 0; i < pointCount; i++)
    25             {
    26                 IPoint point = queryPointByDistance(inputPolyline, distance * i);
    27                 pointCollection.AddPoint(point);
    28             }
    29             return outPolyline;
    30         }        
  • 相关阅读:
    Python+Selenium自动化总结
    Python+Selenium自动化-定位一组元素,单选框、复选框的选中方法
    Python+Selenium自动化-模拟键盘操作
    【leetcode】1053. Previous Permutation With One Swap
    【leetcode】1052. Grumpy Bookstore Owner
    【leetcode】1034. Coloring A Border
    【leetcode】1042. Flower Planting With No Adjacent
    【leetcode】1035. Uncrossed Lines
    【leetcode】1048. Longest String Chain
    【leetcode】1047. Remove All Adjacent Duplicates In String
  • 原文地址:https://www.cnblogs.com/niudieyi/p/8891391.html
Copyright © 2020-2023  润新知