public static IPolygon Union(List <IPolygon> polygons) { if (polygons.Count == 0) { return(null); } if (polygons.Count == 1) { return(polygons[0]); } /* * if (polygons.Count > 100) * { * return polygons[0]; * } */ Clip_polygon union_polygon = new Clip_polygon(); Clip_polygon polygon1 = ClipWrapper.PolygonTo_Clip_polygon(polygons[0]); try { for (int i = 1; i < polygons.Count; i++) { union_polygon = new Clip_polygon(); Clip_polygon polygon2 = ClipWrapper.PolygonTo_Clip_polygon(polygons[i]); ClipPolygon(ref polygon1, ref polygon2, ClipOperation.Union, ref union_polygon); if (i == 1) { ClipWrapper.Free_Clip_polygon(polygon1); } else { ClipWrapper.FreePolygon(ref polygon1); } ClipWrapper.Free_Clip_polygon(polygon2); polygon1 = union_polygon; } IPolygon polygon = ClipWrapper.Clip_polygon_ToPolygon(union_polygon); return(polygon); } finally { ClipWrapper.FreePolygon(ref union_polygon); } }
public static IPolygon BufferPath(IPath path, double distance) { Clip_vertex_list vtx_lst = PathTo_Clip_vertex_list(path); Clip_polygon buffer_polygon = new Clip_polygon(); try { BufferVertextList(ref vtx_lst, distance, BufferOperation.Buffer_LINES, ref buffer_polygon); IPolygon polygon = ClipWrapper.Clip_polygon_ToPolygon(buffer_polygon); return(polygon); } finally { ClipWrapper.Free_Clip_polygon(buffer_polygon); ClipWrapper.Free_Clip_vertex_list(vtx_lst); } }
public static IPolygon Clip(ClipOperation operation, IPolygon subject_polygon, IPolygon clip_polygon) { Clip_polygon Clip_polygon = new Clip_polygon(); Clip_polygon Clip_subject_polygon = ClipWrapper.PolygonTo_Clip_polygon(subject_polygon); Clip_polygon Clip_clip_polygon = ClipWrapper.PolygonTo_Clip_polygon(clip_polygon); try { ClipPolygon(ref Clip_subject_polygon, ref Clip_clip_polygon, operation, ref Clip_polygon); IPolygon polygon = ClipWrapper.Clip_polygon_ToPolygon(Clip_polygon); return(polygon); } finally { ClipWrapper.Free_Clip_polygon(Clip_subject_polygon); ClipWrapper.Free_Clip_polygon(Clip_clip_polygon); ClipWrapper.FreePolygon(ref Clip_polygon); } }