public OctTree(BoundingCuboid boundary, int maxItems, ISimpleOctTreeDivisionStrategy <T> simpleOctTreeDivisionStrategy) { Boundary = boundary; MaxItems = maxItems; SimpleOctTreeDivisionStrategy = simpleOctTreeDivisionStrategy; Points = new Point3Int <T> [0]; }
public Point3Int(Point3Int point, T value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } Point = point; Value = value; }
public BoundingCuboid(Point3Int lowerLeft, Point3Int upperRight) { if (lowerLeft.X > upperRight.X || lowerLeft.Y > upperRight.Y || lowerLeft.Z > upperRight.Z) { throw new ArgumentOutOfRangeException($"lower left is not less than upper right. lowerLeft:{lowerLeft}, upperRight:{upperRight}"); } LowerLeft = lowerLeft; UpperRight = upperRight; }
public void Add(Point3Int <T> point) { if (Points.Length + 1 > MaxItems) { SpawnChildrenAndSubdivide(point); return; } var newPoints = new Point3Int <T> [Points.Length + 1]; Points.CopyTo(newPoints, 0); Points = newPoints; Points[Points.Length - 1] = point; }
private void SpawnChildrenAndSubdivide(Point3Int <T> point) { OctTree <T> tlf; OctTree <T> trf; OctTree <T> tlb; OctTree <T> trb; OctTree <T> blf; OctTree <T> brf; OctTree <T> blb; OctTree <T> brb; SimpleOctTreeDivisionStrategy.SubDivide(Points, point, Boundary, out tlf, out trf, out tlb, out trb, out blf, out brf, out blb, out brb); ULF = tlf; URF = trf; URB = trb; ULB = tlb; BLF = blf; BRF = brf; BLB = blb; BRB = brb; Points = null; }
public bool ContainsPoint(Point3Int point) { return(point.X >= LowerLeft.X && point.X < UpperRight.X && point.Y >= LowerLeft.Y && point.Y < UpperRight.Y && point.Z >= LowerLeft.Z && point.Z < UpperRight.Z); }