Exemplo n.º 1
0
        private int CountMaximalRectangleArea()
        {
            var rectangleCache = new RectangleCache();

            for (int i = 0; i < _height; ++i)
            {
                for (int j = 0; j < _width; ++j)
                {
                    // even if a point is in an added rectangle,
                    // it can be a top-left vertex of a bigger rectangle
                    if (true || !rectangleCache.ContainsPoint(i, j))
                    {
                        var point = new PointModel {
                            I = i, J = j
                        };
                        // iterrating through all "opposite" vertices for each point is too complex
                        var oppositeVertices = GetOppositeVertices(point)
                                               .ToArray();
                        foreach (var v in oppositeVertices)
                        {
                            rectangleCache.AddRectangle(new RectangleModel {
                                P1 = point, P2 = v
                            });
                        }
                    }
                }
            }

            return(rectangleCache.MaximalArea);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Clean the cache
 /// </summary>
 public void CleanCache()
 {
     CacheGetTexture.Clean();
     EEBlocks.Clean();
     EEBlockBitmaps.Clean();
     RectangleCache.Clean();
     Chat.Clear();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Get the rectangle of a block
        /// </summary>
        /// <param name="X">The X</param>
        /// <param name="Y">The Y</param>
        /// <param name="UsingSmiley"></param>
        /// <param name="customWidth"></param>
        /// <param name="customHeight"></param>
        /// <returns></returns>
        public Rectangle GetRectangle(int X, int Y, bool UsingSmiley = false, int customWidth = 16, int customHeight = 16)
        {
            int Width  = customWidth,
                Height = customHeight;

            if (UsingSmiley)
            {
                Width = 26; Height = 26;
            }

            string key = X.ToString() + "::" + Y.ToString() + "::" + Width.ToString() + "::" + Height.ToString();

            if (!RectangleCache.ContainsKey(key))
            {
                RectangleCache.Store(key, new Rectangle(X, Y, Width, Height));
            }

            return((Rectangle)(RectangleCache.Get(key)));
        }