Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        public static GeomTristrip PolygonToTristip(IPolygon polygon)
        {
            Clip_tristrip clip_strip = new Clip_tristrip();
            Clip_polygon  clip_pol   = ClipWrapper.PolygonTo_Clip_polygon(polygon);

            try
            {
                Polygon2Tristrip(ref clip_pol, ref clip_strip);
                GeomTristrip tristrip = ClipWrapper.Clip_strip_ToTristrip(clip_strip);

                return(tristrip);
            }
            finally
            {
                ClipWrapper.Free_Clip_polygon(clip_pol);
                ClipWrapper.FreeTristrip(ref clip_strip);
            }
        }
Esempio n. 4
0
        public static GeomTristrip GeomPolygonToTristrip(GeomPolygon polygon)
        {
            Clip_tristrip Clip_strip = new Clip_tristrip();
            Clip_polygon  Clip_pol   = ClipWrapper.GeomPolygonTo_Clip_polygon(polygon);

            try
            {
                Polygon2Tristrip(ref Clip_pol, ref Clip_strip);
                GeomTristrip tristrip = ClipWrapper.Clip_strip_ToTristrip(Clip_strip);

                return(tristrip);
            }
            finally
            {
                ClipWrapper.Free_Clip_polygon(Clip_pol);
                ClipWrapper.FreeTristrip(ref Clip_strip);
            }
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        public static GeomTristrip ClipToTristrip(ClipOperation operation, GeomPolygon subject_polygon, GeomPolygon clip_polygon)
        {
            Clip_tristrip Clip_strip           = new Clip_tristrip();
            Clip_polygon  Clip_subject_polygon = ClipWrapper.GeomPolygonTo_Clip_polygon(subject_polygon);
            Clip_polygon  Clip_clip_polygon    = ClipWrapper.GeomPolygonTo_Clip_polygon(clip_polygon);

            try
            {
                ClipTristrip(ref Clip_subject_polygon, ref Clip_clip_polygon, operation, ref Clip_strip);
                GeomTristrip tristrip = ClipWrapper.Clip_strip_ToTristrip(Clip_strip);

                return(tristrip);
            }
            finally
            {
                ClipWrapper.Free_Clip_polygon(Clip_subject_polygon);
                ClipWrapper.Free_Clip_polygon(Clip_clip_polygon);
                ClipWrapper.FreeTristrip(ref Clip_strip);
            }
        }