예제 #1
0
        public void TestContains()
        {
            var tree = new QuadTree <TreeItem>(new Rectangle(0, 0, 50, 50));

            var i = new TreeItem(new Rectangle(0, 0, 3, 3));
            var j = new TreeItem(new Rectangle(20, 20, 40, 40));
            var k = new TreeItem(new Rectangle(15, 2, 4, 6));

            tree.Add(i);
            tree.Add(j);

            Assert.IsTrue(tree.Contains(i));
            Assert.IsTrue(tree.Contains(j));
            Assert.IsFalse(tree.Contains(k));
        }
예제 #2
0
        public void TestRemoveBug()
        {
            var tree = new QuadTree <TreeItem>(new Rectangle(0, 0, 10, 10), 1);

            var i = new TreeItem(new Rectangle(0, 0, 3, 3));
            var j = new TreeItem(new Rectangle(0, 0, 2, 2));

            tree.Add(i);
            tree.Add(j);

            var success = tree.Remove(j);

            Assert.IsTrue(success);
            Assert.AreEqual(1, tree.Count);
            Assert.IsTrue(tree.Contains(i));
            Assert.IsFalse(tree.Contains(j));
        }
예제 #3
0
        public void AddAPointAssertExists()
        {
            var ut = new QuadTree(Bounding2DBox.Max, 10, new SimpleQuadTreeDivisionStrategy());

            ut.Add(Point2Int.Zero);

            Assert.IsTrue(ut.Contains(Point2Int.Zero));
        }
        public void ThenIExpectTheQuadTreeToContainTheFollowingPoints(Table table)
        {
            var points = table.GetPoints();

            foreach (var vector2Int in points)
            {
                var isContained = _quadTree.Contains(vector2Int);
                Assert.IsTrue(isContained);
            }
        }
예제 #5
0
        public void TestInsert()
        {
            var tree = new QuadTree <TreeItem>(new Rectangle(0, 0, 50, 50));

            Assert.AreEqual(0, tree.Count);

            var i = new TreeItem(new Rectangle(0, 0, 3, 3));

            tree.Add(i);

            Assert.IsTrue(tree.Contains(i));
            Assert.AreEqual(1, tree.Count);
        }