Esempio n. 1
0
        /// <summary>
        /// Unites two given polygons into one and returns it. The two polygons
        /// are deleted. Optionally applies a cleanup to the new polygon.
        /// </summary>
        /// <param name="unionEdges">the edges of the new united polygon</param>
        /// <param name="polygon1">the first of the polygons that are to be united</param>
        /// <param name="polygon2">the second of the polygons that are to be united</param>
        /// <param name="allowCleanUp">if the edges of the united polygon should
        ///  be cleaned up</param>
        /// <returns>the new united polygon</returns>
        private Polygon ApplyPolygonUnion(List<Edge> unionEdges, Polygon polygon1, Polygon polygon2, bool allowCleanUp)
        {
            Debug.Assert(! polygon1.CanBeCleanedUp(), "Cannot unite with a dirty polygon!");
            Debug.Assert(!polygon2.CanBeCleanedUp(), "Cannot unite with a dirty polygon!");
            Polygon unionPolygon = new Polygon(unionEdges);
            unionPolygon.ImposeOwnership();

            polygon1.Delete(true);
            RemovePolygon(polygon1);

            polygon2.Delete(true);
            RemovePolygon(polygon2);

            AddPolygon(unionPolygon);

            if (allowCleanUp) unionPolygon.CleanUp(true);
            return unionPolygon;
        }