Beispiel #1
0
        /// <summary>
        /// Prostok�t ma wype�ni� dan� dziur�.
        /// </summary>
        /// <param name="outsRight">lista prostok�t�w na brzegu z prawej strony</param>
        /// <param name="outsDown">lista prostok�t�w na brzegu z do�u</param>
        /// <param name="holesRight">dziury z prawej strony</param>
        /// <param name="holesDown">dziury z do�u</param>
        /// <param name="rect">do��czany prostok�t</param>
        /// <param name="hole">dziura do wype�nienia</param>
        /// <param name="rightSide">czy dziura jest z prawej strony czy z do�u</param>
        private void fillHole(List<OutRect> outsRight, List<OutRect> outsDown,
                            List<Hole> holesRight, List<Hole> holesDown, Rectangle rect,
                            Hole hole, bool rightSide)
        {
            Hole newHole;
            OutRect outRect, or;
            List<OutRect> outRects;
            List<Hole> holes;
            int result, index;

            result = hole.filled(rect, out newHole);
            updateMaxValues(rect);

            if (rightSide)
            {
                outRects = outsRight;
                holes = holesRight;
            }
            else
            {
                outRects = outsDown;
                holes = holesDown;
            }

            or = hole.NeighbourOne;
            index = -1;
            if (or != null)
                index = outRects.IndexOf(or);
            outRect = new OutRect(rect.SideA, rect.SideB, new Point(rect.LeftTop.X,
                                                rect.LeftTop.Y));
            outRects.Insert(index + 1, outRect);
            hole.NeighbourOne = outRect;

            // dziura jest na rogu i prostok�t w ca�o�ci j� wepe�ni
            if (hole.OrientDown && hole.OrientRight && result == 0)
            {
                if(rect.RightDown.X > Min_X && !rightSide)
                    outsRight.Add(new OutRect(rect.RightDown.X - Min_X, rect.SideB,
                                    new Point(Min_X, rect.LeftTop.Y)));

                if (rect.RightDown.Y > Min_Y && rightSide)
                    outsDown.Add(new OutRect(rect.SideA, rect.RightDown.Y - Min_Y,
                                    new Point(rect.LeftTop.X, Min_Y)));

            }
            // dziura na rogu wype�niona cz�ciowo - powstaje nowa dziura
            if (hole.OrientDown && hole.OrientRight && result > 0 && newHole != null)
            {

                OutRect or2 = null;
                if (outsDown.Count > 0)
                   or2 = outsDown[outsDown.Count - 1];
                newHole.NeighbourOne = or2;

                if (newHole.Rect.LeftTop.Y >= Min_Y)
                    holesDown.Add(newHole);
            }

            if (result == 0)
                holes.Remove(hole);

            updateHoles(outsRight, outsDown, holesRight, holesDown);
        }