示例#1
0
        public void QueryQuadTree()
        {
            // generate random bounds
            RectangleF extends;
            var allBounds = CreateRandomRectangles(out extends);

            // construct the quad tree
            var quadTree = new QuadTree(extends, 5, false);
            for (int i = 0; i < allBounds.Length; i++)
                quadTree.Insert(i, allBounds[i]);

            var queryRectangles = Enumerable.Range(0, 10000)
                                            .Select(i => CreateRandomRectangle(2f))
                                            .ToArray();

            // query the quad tree (and time it)
            // 1050ms on my pc
            TestHelper.AssertIsFasterThan(3000, () =>
            {
                for (int i = 0; i < queryRectangles.Length; i++)
                {
                    var rect = queryRectangles[i];
                    var res = quadTree.GetIndices(ref rect, 0f).ToList();
                }
            });
        }
示例#2
0
        public void ConstructQuadTree()
        {
            // generate random bounds
            RectangleF extends;
            var allBounds = CreateRandomRectangles(out extends);

            // construct the quad tree (and time it)
            // 40ms on my pc
            TestHelper.AssertIsFasterThan(300, () =>
                {
                    var quadTree = new QuadTree(extends, 5, false);
                    for (int i = 0; i < allBounds.Length; i++)
                        quadTree.Insert(i, allBounds[i]);
                });
        }
示例#3
0
 public QTNode(RectangleF bounds, int level, QuadTree tree)
 {
     this.tree = tree;
     this._bounds = bounds;
     this._level = level;
     //if (level < MinLevels)
     //{
     //    //create children
     //}
     if (Level == tree.maxLevels)
     {                
         indexList = new List<int>();                
         boundsList = new List<RectangleF>();
     }
 }