public void RStarTreeConstructorTest() { // default values RStarTree tree = new RStarTree(); tree.Height.ShouldBe(0); tree.NumberOfGeometries.ShouldBe(0); tree.MinChildren.ShouldBe(8); tree.MaxChildren.ShouldBe(12); // min. 2, max. 4 children tree = new RStarTree(2, 4); tree.Height.ShouldBe(0); tree.NumberOfGeometries.ShouldBe(0); tree.MinChildren.ShouldBe(2); tree.MaxChildren.ShouldBe(4); // min. 10, max. 100 children tree = new RStarTree(10, 100); tree.Height.ShouldBe(0); tree.NumberOfGeometries.ShouldBe(0); tree.MinChildren.ShouldBe(10); tree.MaxChildren.ShouldBe(100); // exceptions Should.Throw <ArgumentOutOfRangeException>(() => new RStarTree(0, 1)); Should.Throw <ArgumentOutOfRangeException>(() => new RStarTree(1, 1)); }
public void ImportAndReset(IEnumerable <IndexedFaceSet> faceSets) { var faceSetsArray = faceSets.ToArray(); if (settings.Direction.SupportAnyDirection) { foreach (var indexedFaceSet in faceSetsArray) { vectorDirOperator.AddIndexedFaceSet(indexedFaceSet); } } spatialRepository.TriangleMeshes = faceSetsArray.Select(f => f.CreateMesh()).ToList(); currentTriangleCount = 0; foreach (var triangleMesh in spatialRepository.TriangleMeshes) { var rtree = new RStarTree <Triangle>(); rtree.Add(triangleMesh.Triangles); currentTriangleCount += triangleMesh.Triangles.Count; triangleMesh.RTreeRoot = rtree; } }
public void AddImport(List <TriangleMesh> meshes) { spatialRepository.AddMeshes(meshes); var currentTriangleCount = 0; foreach (var triangleMesh in spatialRepository.TriangleMeshes) { var rtree = new RStarTree <Triangle>(); rtree.Add(triangleMesh.Triangles); currentTriangleCount += triangleMesh.Triangles.Count; triangleMesh.RTreeRoot = rtree; } Console.WriteLine("Triangles imported:" + currentTriangleCount); }
public void RStarTreeAddTest() { RStarTree tree = new RStarTree(2, 3); // add a single geometry tree.Add(_geometries[0]); Assert.AreEqual(1, tree.Height); Assert.AreEqual(1, tree.NumberOfGeometries); tree.Add(_geometries[1]); Assert.AreEqual(1, tree.Height); Assert.AreEqual(2, tree.NumberOfGeometries); tree.Add(_geometries[2]); Assert.AreEqual(1, tree.Height); Assert.AreEqual(3, tree.NumberOfGeometries); tree.Add(_geometries[3]); Assert.AreEqual(2, tree.Height); Assert.AreEqual(4, tree.NumberOfGeometries); for (Int32 geometryIndex = 4; geometryIndex < _geometries.Count; geometryIndex++) { tree.Add(_geometries[geometryIndex]); } Assert.AreEqual(_geometries.Count, tree.NumberOfGeometries); Assert.IsTrue(tree.Height >= Math.Floor(Math.Log(_geometries.Count, 3))); Assert.IsTrue(tree.Height <= Math.Ceiling(Math.Log(_geometries.Count, 2))); // add a complete collection tree = new RStarTree(2, 3); tree.Add(_geometries); Assert.AreEqual(_geometries.Count, tree.NumberOfGeometries); // errors Assert.Throws <ArgumentNullException>(() => tree.Add((IGeometry)null)); Assert.Throws <ArgumentNullException>(() => tree.Add((IEnumerable <IGeometry>)null)); }
public void RStarTreeAddTest() { RStarTree tree = new RStarTree(2, 3); // add a single geometry tree.Add(this.geometries[0]); tree.Height.ShouldBe(1); tree.NumberOfGeometries.ShouldBe(1); tree.Add(this.geometries[1]); tree.Height.ShouldBe(1); tree.NumberOfGeometries.ShouldBe(2); tree.Add(this.geometries[2]); tree.Height.ShouldBe(1); tree.NumberOfGeometries.ShouldBe(3); tree.Add(this.geometries[3]); tree.Height.ShouldBe(2); tree.NumberOfGeometries.ShouldBe(4); for (Int32 geometryIndex = 4; geometryIndex < this.geometries.Count; geometryIndex++) { tree.Add(this.geometries[geometryIndex]); } tree.NumberOfGeometries.ShouldBe(this.geometries.Count); tree.Height.ShouldBeGreaterThanOrEqualTo((Int32)Math.Floor(Math.Log(this.geometries.Count, 3))); tree.Height.ShouldBeLessThanOrEqualTo((Int32)Math.Ceiling(Math.Log(this.geometries.Count, 2))); // add a complete collection tree = new RStarTree(2, 3); tree.Add(this.geometries); tree.NumberOfGeometries.ShouldBe(this.geometries.Count); // exceptions Should.Throw <ArgumentNullException>(() => tree.Add((IGeometry)null)); Should.Throw <ArgumentNullException>(() => tree.Add((IEnumerable <IGeometry>)null)); }
public void RStarTreeConstructorTest() { // default values RStarTree tree = new RStarTree(); Assert.AreEqual(0, tree.Height); Assert.AreEqual(0, tree.NumberOfGeometries); Assert.AreEqual(8, tree.MinChildren); Assert.AreEqual(12, tree.MaxChildren); // min. 2, max. 4 children tree = new RStarTree(2, 4); Assert.AreEqual(0, tree.Height); Assert.AreEqual(0, tree.NumberOfGeometries); Assert.AreEqual(2, tree.MinChildren); Assert.AreEqual(4, tree.MaxChildren); // min. 10, max. 100 children tree = new RStarTree(10, 100); Assert.AreEqual(0, tree.Height); Assert.AreEqual(0, tree.NumberOfGeometries); Assert.AreEqual(10, tree.MinChildren); Assert.AreEqual(100, tree.MaxChildren); // errors Assert.Throws <ArgumentOutOfRangeException>(() => new RStarTree(0, 1)); Assert.Throws <ArgumentOutOfRangeException>(() => new RStarTree(1, 1)); }
public void CreateRTree() { RTreeRoot = new RStarTree <Triangle>(); RTreeRoot.Add(triangles); }