private static IPolygon Clip_polygon_ToPolygon(Clip_polygon Clip_polygon) { Polygon polygon = new Polygon(); if (Clip_polygon.num_contours == 0) { return(new Polygon()); } short[] holeShort = new short[Clip_polygon.num_contours]; Marshal.Copy(Clip_polygon.hole, holeShort, 0, Clip_polygon.num_contours); IntPtr ptr = Clip_polygon.contour; for (int i = 0; i < Clip_polygon.num_contours; i++) { Clip_vertex_list Clip_vtx_lst = (Clip_vertex_list)Marshal.PtrToStructure(ptr, typeof(Clip_vertex_list)); IRing ring = ((holeShort[i] == 0) ? new Ring() : new Hole()); IntPtr ptr2 = Clip_vtx_lst.vertex; for (int j = 0; j < Clip_vtx_lst.num_vertices; j++) { Clip_vertex Clip_vtx = (Clip_vertex)Marshal.PtrToStructure(ptr2, typeof(Clip_vertex)); ring.AddPoint(new gView.Framework.Geometry.Point( Clip_vtx.x, Clip_vtx.y)); ptr2 = IntPtrPlus(ptr2, Marshal.SizeOf(Clip_vtx)); //(IntPtr)(((int)ptr2) + Marshal.SizeOf(Clip_vtx)); } polygon.AddRing(ring); ptr = IntPtrPlus(ptr, Marshal.SizeOf(Clip_vtx_lst)); //(IntPtr)(((int)ptr) + Marshal.SizeOf(Clip_vtx_lst)); } return(polygon); }