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(Polygon 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, Polygon subject_polygon, Polygon 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);
        }
        public static Tristrip ClipToTristrip( GpcOperation operation, Polygon subject_polygon, Polygon 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;
        }
        private static TriStrip gpc_strip_ToTristrip(gpc_tristrip gpc_strip)
        {
            int      numStrips = gpc_strip.num_strips;
            TriStrip tristrip  = new TriStrip(numStrips);
            IntPtr   ptr       = gpc_strip.strip;

            for (int i = 0; i < numStrips; ++i)
            {
                gpc_vertex_list gpc_vtx_list = (gpc_vertex_list)Marshal.PtrToStructure(ptr, typeof(gpc_vertex_list));
                int             numVertices  = gpc_vtx_list.num_vertices;
                tristrip[i].Capacity = numVertices;
                IntPtr ptr2 = gpc_vtx_list.vertex;
                for (int j = 0; j < numVertices; ++j)
                {
                    gpc_vertex gpc_vtx = (gpc_vertex)Marshal.PtrToStructure(ptr2, typeof(gpc_vertex));
                    tristrip[i].Add(new Vec2d(gpc_vtx.x, gpc_vtx.y));
                    ptr2 = (IntPtr)(((int)ptr2) + Marshal.SizeOf(gpc_vtx));
                }
                ptr = (IntPtr)(((int)ptr) + Marshal.SizeOf(gpc_vtx_list));
            }
            return(tristrip);
        }
 private static extern void gpc_free_tristrip([In] ref gpc_tristrip tristrip);
 private static extern void gpc_tristrip_clip([In]     GpcOperation set_operation,
                                              [In]     ref gpc_polygon subject_polygon,
                                              [In]     ref gpc_polygon clip_polygon,
                                              [In, Out] ref gpc_tristrip result_tristrip);
 private static extern void gpc_polygon_to_tristrip([In]     ref gpc_polygon polygon,
                                                    [In, Out] ref gpc_tristrip tristrip);
        private static GpcTristrip gpc_strip_ToTristrip(gpc_tristrip gpc_strip)
        {
            GpcTristrip tristrip = new GpcTristrip();
            tristrip.NofStrips = gpc_strip.num_strips;
            tristrip.Strip = new GpcVertexList[tristrip.NofStrips];
            IntPtr ptr = gpc_strip.strip;
            for (int i = 0; i < tristrip.NofStrips; i++)
            {
                tristrip.Strip[i] = new GpcVertexList();
                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 GpcVertex[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 GpcTristrip 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);
            GpcTristrip tristrip = GpcWrapper.gpc_strip_ToTristrip(gpc_strip);

            GpcWrapper.Free_gpc_polygon(gpc_pol);
            GpcWrapper.gpc_free_tristrip(ref gpc_strip);

            return tristrip;
        }
Example #11
0
 public static extern void gpc_free_tristrip([In] ref gpc_tristrip tristrip);