Пример #1
0
        public void AllLeavesPutAtRoot()
        {
            Octree <int> tree = new Octree <int>(1, new AxisAlignedBoundingBox(-10, -20, -30, 10, 20, 30));

            tree.Insert(1, new AxisAlignedBoundingBox(-9, -19, -29, 9, 19, 29));
            tree.Insert(2, new AxisAlignedBoundingBox(-9, -19, -29, 9, 19, 29));
            tree.Insert(3, new AxisAlignedBoundingBox(-9, -19, -29, 9, 19, 29));
            tree.Insert(4, new AxisAlignedBoundingBox(-9, -19, -29, 9, 19, 29));

            Assert.IsTrue(tree.CountBranches() == 1);

            tree.SearchBounds(new AxisAlignedBoundingBox(-9, -19, -29, 9, 19, 29));
            Assert.AreEqual(tree.QueryResults.Count(), 4, "Found all items.");
            tree.SearchPoint(0, 0, 0);
            Assert.AreEqual(4, tree.QueryResults.Count(), "All or around this point.");
            tree.FindCollisions(1);
            Assert.AreEqual(3, tree.QueryResults.Count(), "Don't find the item we are starting from.");
            Assert.AreEqual(4, tree.Count, "Have the right count.");

            tree.Remove(3);
            tree.SearchBounds(new AxisAlignedBoundingBox(-9, -19, -29, 9, 19, 29));
            Assert.AreEqual(3, tree.QueryResults.Count(), "Found all items.");
            tree.SearchPoint(0, 0, 0);
            Assert.AreEqual(3, tree.QueryResults.Count(), "All or around this point.");
            tree.FindCollisions(1);
            Assert.AreEqual(2, tree.QueryResults.Count(), "Don't find the item we are starting from.");
            Assert.AreEqual(3, tree.Count, "Have the right count.");
        }