예제 #1
0
 private static ArrayList<RectangleF> OptimizeBoundingArea(IEnumerable<RectangleF> boundingArea)
 {
     RTree rTree = new RTree();
     int rectCount = 0;
     foreach (RectangleF rect in boundingArea)
     {
         rTree.Insert(rect);
         rectCount++;
     }
     ArrayList<RectangleF> result = new ArrayList<RectangleF>(rectCount);
     while (rTree.mRoot.Entries.Count > 0)
     {
         Entry entry = rTree.GetAnyLeafEntry();
         RectangleF bb = entry.BoundingBox;
         float area = 0;
         while (bb.Width * bb.Height - area > 0.1f) // *** increase this threshold?
         {
             area = bb.Width * bb.Height;
             ArrayList<Entry> queryResult = rTree.Fetch(bb);
             rTree.Delete(queryResult);
             foreach (Entry resultEntry in queryResult)
             {
                 bb = RectangleF.Union(bb, resultEntry.BoundingBox);
             }
         }
         result.Add(bb);
     }
     return result;
 }
예제 #2
0
 public void Optimize()
 {
     mRects = RTree.FullyOptimizeBoundingArea(this);
 }