页面载入中....
页面载入中....

将Polygon 分成多个三角形

by - 2008-4-18 13:50:00

   下面这段函数主要是为了将Polygon分成多个三角形,这样进一步处理就能得到

这个Polygon里面的任意多个点(这些点一定落在这个Polygon里面)

public static IGeometryCollection GetTrianglesFromPolygon(IPolygon ipPg)
        {
           
            ILinePolygonHelper ipLPgHelper = new LinePolygonHelperClass();
            IMultiPatch ipMultiPatch = new MultiPatchClass();
          
            ipLPgHelper.Triangulate(ipPg, ref ipMultiPatch);

            if (ipMultiPatch != null)
            {
                IGeometryCollection ipGeoColl = new GeometryBagClass();

                IPointCollection ipPtColl = (IPointCollection)ipMultiPatch;
                int nCount = ipPtColl.PointCount;

                int nNum = nCount / 3;

                object o = Type.Missing;

                for (int i = 0; i < nNum; i++)
                {
                    IPolygon ipPgTemp = new PolygonClass();

                    IPointCollection ipPgPtCol = (IPointCollection)ipPgTemp;

                    ipPgPtCol.AddPoint(ipPtColl.get_Point(i * 3), ref o, ref o);
                    ipPgPtCol.AddPoint(ipPtColl.get_Point(i * 3 + 1), ref o, ref o);
                    ipPgPtCol.AddPoint(ipPtColl.get_Point(i * 3 + 2), ref o, ref o);
                    //处理成简单多边形,使之符合ESRI 规范
                    ipPgTemp.SimplifyPreserveFromTo();
                    ipPgTemp.Close();

                    ipGeoColl.AddGeometry((IGeometry)ipPgTemp, ref o, ref o);

                }

                return ipGeoColl;

            }
            else
            {
                return null;
            }
           
        }

阅读全文 | 回复(0) | 引用通告 | 编辑

  • 标签:AO Polygon Triangles 
  • 发表评论:
    页面载入中....
    Powered by Oblog.