Пример #1
0
 private void FilterSelfSubAreas(List <IntegerRectangle> areas)
 {
     for (int i = areas.Count - 1; i >= 0; i--)
     {
         IntegerRectangle filtered = areas[i];
         for (int j = areas.Count - 1; j >= 0; j--)
         {
             if (i != j)
             {
                 IntegerRectangle area = areas[j];
                 if (filtered.x >= area.x && filtered.y >= area.y && filtered.right <= area.right && filtered.top <= area.top)
                 {
                     filtered.Dispose();
                     IntegerRectangle topOfStack = areas.Pop();
                     if (i < areas.Count)
                     {
                         // Move the one on the top to the freed position
                         areas[i] = topOfStack;
                     }
                     break;
                 }
             }
         }
     }
 }
Пример #2
0
        private void GenerateDividedAreas(IntegerRectangle divider, IntegerRectangle area, List <IntegerRectangle> results)
        {
            int count = 0;

            int rightDelta = area.right - divider.right;

            if (rightDelta > 0)
            {
                results.Add(IntegerRectangle.Create(divider.right, area.y, rightDelta, area.height));
                count++;
            }

            int leftDelta = divider.x - area.x;

            if (leftDelta > 0)
            {
                results.Add(IntegerRectangle.Create(area.x, area.y, leftDelta, area.height));
                count++;
            }

            int bottomDelta = area.top - divider.top;

            if (bottomDelta > 0)
            {
                results.Add(IntegerRectangle.Create(area.x, divider.top, area.width, bottomDelta));
                count++;
            }

            int topDelta = divider.y - area.y;

            if (topDelta > 0)
            {
                results.Add(IntegerRectangle.Create(area.x, area.y, area.width, topDelta));
                count++;
            }

            if (count == 0 && (divider.width < area.width || divider.height < area.height))
            {
                // Only touching the area, store the area itself
                results.Add(area);
            }
            else
            {
                area.Dispose();
            }
        }
Пример #3
0
 public void RemoveFreeArea(IntegerRectangle area)
 {
     m_FreeAreasList.Remove(area);
     area.Dispose();
 }