private static Tristrip gpc_strip_ToTristrip(gpc_tristrip gpc_strip) { Tristrip tristrip = new Tristrip(); tristrip.NofStrips = gpc_strip.num_strips; tristrip.Strip = new VertexList[tristrip.NofStrips]; IntPtr ptr = gpc_strip.strip; for (int i = 0; i < tristrip.NofStrips; i++) { tristrip.Strip[i] = new VertexList(); gpc_vertex_list gpc_vtx_list = (gpc_vertex_list)Marshal.PtrToStructure(ptr, typeof(gpc_vertex_list)); tristrip.Strip[i].NofVertices = gpc_vtx_list.num_vertices; tristrip.Strip[i].Vertex = new Vertex[tristrip.Strip[i].NofVertices]; IntPtr ptr2 = gpc_vtx_list.vertex; for (int j = 0; j < tristrip.Strip[i].NofVertices; j++) { gpc_vertex gpc_vtx = (gpc_vertex)Marshal.PtrToStructure(ptr2, typeof(gpc_vertex)); tristrip.Strip[i].Vertex[j].X = gpc_vtx.x; tristrip.Strip[i].Vertex[j].Y = gpc_vtx.y; ptr2 = (IntPtr)(((int)ptr2) + Marshal.SizeOf(gpc_vtx)); } ptr = (IntPtr)(((int)ptr) + Marshal.SizeOf(gpc_vtx_list)); } return(tristrip); }
public static Tristrip PolygonToTristrip(GpcPolygon polygon) { gpc_tristrip gpc_strip = new gpc_tristrip(); gpc_polygon gpc_pol = GpcWrapper.PolygonTo_gpc_polygon(polygon); gpc_polygon_to_tristrip(ref gpc_pol, ref gpc_strip); Tristrip tristrip = GpcWrapper.gpc_strip_ToTristrip(gpc_strip); GpcWrapper.Free_gpc_polygon(gpc_pol); GpcWrapper.gpc_free_tristrip(ref gpc_strip); return(tristrip); }
public static Tristrip ClipToTristrip(GpcOperation operation, GpcPolygon subject_polygon, GpcPolygon clip_polygon) { gpc_tristrip gpc_strip = new gpc_tristrip(); gpc_polygon gpc_subject_polygon = GpcWrapper.PolygonTo_gpc_polygon(subject_polygon); gpc_polygon gpc_clip_polygon = GpcWrapper.PolygonTo_gpc_polygon(clip_polygon); gpc_tristrip_clip(operation, ref gpc_subject_polygon, ref gpc_clip_polygon, ref gpc_strip); Tristrip tristrip = GpcWrapper.gpc_strip_ToTristrip(gpc_strip); GpcWrapper.Free_gpc_polygon(gpc_subject_polygon); GpcWrapper.Free_gpc_polygon(gpc_clip_polygon); GpcWrapper.gpc_free_tristrip(ref gpc_strip); return(tristrip); }