public void InsertOne() { var boundingBox = BoundingBox.ByCorners(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(1, 1, 1)); var tree = new SimpleOctree(boundingBox, new OctreeOptions()); tree.Add("test object", boundingBox); var list = tree.QueryRange(boundingBox); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object", list[0]); }
public void QueryRange() { List <object> list = null; list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(10, 10, 10))); Assert.AreEqual(8, list.Count); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(10, 10, 5))); Assert.AreEqual(4, list.Count); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(0, 0, 5), Point.ByCoordinates(10, 10, 10))); Assert.AreEqual(4, list.Count); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(0, 0, 0), Point.ByCoordinates(5, 5, 5))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 1", list[0]); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(0, 5, 0), Point.ByCoordinates(5, 10, 5))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 2", list[0]); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(5, 0, 0), Point.ByCoordinates(10, 5, 5))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 3", list[0]); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(5, 5, 0), Point.ByCoordinates(10, 10, 5))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 4", list[0]); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(0, 0, 5), Point.ByCoordinates(5, 5, 10))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 5", list[0]); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(0, 5, 5), Point.ByCoordinates(5, 10, 10))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 6", list[0]); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(5, 0, 5), Point.ByCoordinates(10, 5, 10))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 7", list[0]); list = tree.QueryRange(BoundingBox.ByCorners(Point.ByCoordinates(5, 5, 5), Point.ByCoordinates(10, 10, 10))); Assert.AreEqual(1, list.Count); Assert.AreEqual("test object 8", list[0]); }