Example #1
0
 private bool SaveQuadTreeObject(QuadNode root, StreamWriter strWriter)
 {
     if (root == null)
         return false;
     //write object's information
     List<Item> allItem = root.GetAllObjects();
     for (int i = 0; i < allItem.Count; i++)
     {
         strWriter.WriteLine("" + root.Id + " " // node id
             + allItem[i].ItemInfoID + " " // item id
             + allItem[i].ItemRectangle.X + " " // position X
             + allItem[i].ItemRectangle.Y + " " // position Y
             + allItem[i].ItemRectangle.Width + " " // partition width
             + allItem[i].ItemRectangle.Height // partition height
             );
     }
     if (root.NodeLT != null)
         SaveQuadTreeObject(root.NodeLT, strWriter); // save objects in left-top node
     if (root.NodeLB != null)
         SaveQuadTreeObject(root.NodeLB, strWriter); // save objects in left-bottom node
     if (root.NodeRB != null)
         SaveQuadTreeObject(root.NodeRB, strWriter); // save objects in right-bottom node
     if (root.NodeRT != null)
         SaveQuadTreeObject(root.NodeRT, strWriter); // save objects in right-top node
     return true;
 }