示例#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);
        }
示例#2
0
        /// <summary>
        /// Prostok�t do��czany do boku budowanego prostak�ta z prawej strony.
        /// </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">lista dziur z prawej strony</param>
        /// <param name="holesDown">lista dziur z do�u</param>
        /// <param name="rect">do��czany prostok�t</param>        
        private void stickRectangleRight(List<OutRect> outsRight, List<OutRect> outsDown, 
                            List<Hole> holesRight, List<Hole> holesDown, Rectangle rect)
        {
            OutRect outRect;
            Hole hole;

            rect.Move(new Point(Min_X, 0));
            updateMaxValues(rect);

            if (rect.SideB < Min_Y)
            {
                outRect = new OutRect(rect.SideA, rect.SideB, new Point(rect.LeftTop.X,
                                                rect.LeftTop.Y));
                outsRight.Add(outRect);

                hole = new Hole(rect.SideA, Max_Y - rect.SideB, new Point(Min_X,
                                    rect.RightDown.Y));
                hole.NeighbourOne = outRect;
                hole.OrientDown = true;
                hole.OrientRight = true;

                if (isCornerHole(holesDown))
                    hole.saveResize(rect.SideA, Min_Y - rect.SideB);
                else
                {
                    hole.Corner = true;
                    if (outsDown.Count > 0)
                        hole.NeighbourSecond = outsDown[outsDown.Count - 1];
                }

                holesRight.Add(hole);
            }
            else
            {
                if (Max_Y > Min_Y && !isCornerHole(holesDown) && outsDown.Count > 0)
                {
                    hole = new Hole(Max_X - Min_X, Max_Y - Min_Y, new Point(Min_X, Min_Y));
                    hole.NeighbourOne = outsDown[outsDown.Count - 1];
                    hole.OrientDown = true;
                    hole.OrientRight = true;
                    hole.Corner = true;
                    holesDown.Add(hole);
                }

                Min_X = rect.RightDown.X;
            }
        }
示例#3
0
 /// <summary>
 /// Konstruktor 3-parametrowy
 /// </summary>
 /// <param name="sideA">szeroko��</param>
 /// <param name="sideB">wysoko��</param>
 /// <param name="pt">puntk lewy-g�rny</param>
 public Hole(int sideA, int sideB, Point pt)
 {
     _rect = new Rectangle(sideA, sideB, pt);
     _orientDown = _orientRight = _corner = false;
     _neighbourOne = _neighbourSecond = null;
 }