polyline转polygon AE(转)

来源:互联网 发布:linux下驱动会不会掉 编辑:程序博客网 时间:2024/05/29 15:45

 

转一个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; } }

原创粉丝点击