现在的位置: 首页 > 综合 > 正文

polyline转polygon AE(转)

2014年03月27日 ⁄ 综合 ⁄ 共 1095字 ⁄ 字号 评论关闭

 

转一个c#的线转面的程序
  private IPolygon PolylineToPolygon(IPolyline ipPline)

{ try { ISegmentCollection ipSegColl; IPolygon ipPolygon = new PolygonClass(); IGeometryCollection ipPolylineToPolygon = new PolygonClass(); IClone ipClone1, ipClone2; ipClone1 = ipPline as IClone; ipClone2 = ipClone1.Clone(); IGeometryCollection ipGeosPolyline = ipClone2 as IGeometryCollection; int iCount = ipGeosPolyline.GeometryCount; object before = Type.Missing; object after = Type.Missing; for (int i = 0; i < iCount; i++) { IGeometry ipSRing; ipSegColl = new RingClass(); ipSRing = ipGeosPolyline.get_Geometry(i); ipSegColl.AddSegmentCollection(ipSRing as ISegmentCollection); IRing ring = ipSegColl as IRing; IGeometry geo = ring; ipPolylineToPolygon.AddGeometry(geo, ref before, ref after); Marshal.ReleaseComObject(ipSRing); Marshal.ReleaseComObject(ring); Marshal.ReleaseComObject(geo); } ipPolygon = ipPolylineToPolygon as IPolygon; ipPolygon.SimplifyPreserveFromTo(); //Marshal.ReleaseComObject(ipPolylineToPolygon); Marshal.ReleaseComObject(ipClone1); Marshal.ReleaseComObject(ipClone2); Marshal.ReleaseComObject(ipGeosPolyline); return ipPolygon; } catch (Exception ee) { MessageBoxEx.Show(ee.Message); return null; } }

抱歉!评论已关闭.