code: private int countAreas(Area a, Rectangular r)
      {
          int ret = 0;
          
          for (int i = 0; i < a.getChildCount(); i++)
          {
              Area n = a.getChildAt(i);
              if (a.getTopology().getPosition(n).intersects(r))
                  ret++;
          }
          return ret;
      }
docs: Counts the number of sub-areas in the specified region of the area
  @param a the area to be examined
  @param r the grid region of the area to be examined
  @return the number of visual areas in the specified area of the grid