Ejemplo n.º 1
0
        /// <summary>
        /// Forms the bounding rectangle.
        /// </summary>
        protected void MakeBoundingRect()
        {
            if (LineRects.Count == 0)
            {
                BoundingRect.Clear();
                return;
            }
            else
            {
                BoundingRect.Set(LineRects[0]);

                for (var i = 1; i < LineRects.Count; i++)
                {
                    BoundingRect.ExpandToInclude(LineRects[i]);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a random shape.
        /// </summary>
        /// <param name="cBoundary">The boundary.</param>
        /// <param name="nMinPoints">The minimum points.</param>
        /// <param name="nMaxPoints">The maximum points.</param>
        public bool CreateRandom(C2DRect cBoundary, int nMinPoints, int nMaxPoints)
        {
            C2DPolygon Poly = new C2DPolygon();

            if (!Poly.CreateRandom(cBoundary, nMinPoints, nMaxPoints))
            {
                return(false);
            }

            CRandomNumber rCenOnRight = new CRandomNumber(0, 1);

            this.Set(Poly);

            for (int i = 0; i < Lines.Count; i++)
            {
                C2DLineBase pLine = Lines[i];

                bool          bCenOnRight = (rCenOnRight.GetInt() > 0);
                double        dLength     = pLine.GetLength();
                CRandomNumber Radius      = new CRandomNumber(dLength, dLength * 3);


                C2DArc pNew = new C2DArc(pLine.GetPointFrom(), pLine.GetPointTo(),
                                         Radius.Get(), bCenOnRight, !bCenOnRight);

                if (!this.Crosses(pNew))
                {
                    Lines[i] = pNew;
                    pNew.GetBoundingRect(LineRects[i]);
                    BoundingRect.ExpandToInclude(LineRects[i]);
                }
            }

            //     this.MakeLineRects();
            //      this.MakeBoundingRect();

            return(true);
        }