Beispiel #1
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;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Aktualizacja dziur z prawej strony.
        /// </summary>
        /// <param name="outsRight">prostok�ty na brzegu z prawej strony</param>
        /// <param name="outsDown">prostok�ty na brzegu z do�u</param>
        /// <param name="holesRight">dziury z prawej strony</param>
        /// <param name="holesDown">dziury z do�u</param>
        private void updateHolesRight(List<OutRect> outsRight, List<OutRect> outsDown, List<Hole> holesRight,
                                    List<Hole> holesDown)
        {
            OutRect orOld = null;
            Hole hole;

            // tworzona nowa lista dziur
            holesRight.Clear();

            foreach (OutRect or in outsRight)
            {
                if (orOld == null)
                {
                    if (or.LeftTop.Y > 0)
                    {
                        hole = new Hole(or.SideA, or.LeftTop.Y, new Point(Min_X, 0));
                        hole.OrientRight = true;
                        hole.NeighbourSecond = or;
                        holesRight.Add(hole);
                    }
                }
                else if (or.LeftTop.Y > orOld.RightDown.Y)
                {
                    hole = new Hole(Math.Min(or.SideA, orOld.SideA), or.LeftTop.Y - orOld.RightDown.Y,
                                new Point(Min_X, orOld.RightDown.Y));
                    hole.OrientRight = true;
                    hole.NeighbourOne = orOld;
                    hole.NeighbourSecond = or;
                    holesRight.Add(hole);
                }

                orOld = or;
            }

            if (orOld != null && orOld.RightDown.Y < Max_Y)
            {
                hole = new Hole(orOld.SideA, Max_Y - orOld.RightDown.Y,
                            new Point(Min_X, orOld.RightDown.Y));
                hole.OrientDown = true;
                hole.OrientRight = true;
                hole.NeighbourOne = orOld;

                if (!isCornerHole(holesDown))
                {
                    hole.Corner = true;
                    if (outsDown.Count > 0)
                        hole.NeighbourSecond = outsDown[outsDown.Count - 1];
                }
                else
                {
                    if (holesDown.Count > 0)
                        hole.saveResize(hole.Rect.SideA,
                            holesDown[holesDown.Count -1 ].Rect.LeftTop.Y - orOld.RightDown.Y);
                }

                holesRight.Add(hole);
            }
        }