public void ItemsInside(BoundingBox box, ref IList <T> output) { if (_SplitDimension != CoordinateAxis.Undefined) { double min = box.MinInDimension(_SplitDimension); double max = box.MaxInDimension(_SplitDimension); double t0 = (min - _Origin) / _CellSize; double t1 = (max - _Origin) / _CellSize; int startIndex = (int)Math.Max(Math.Floor(t0), 0); int endIndex = (int)Math.Min(Math.Floor(t1), _Branches.Length - 1); for (int i = startIndex; i <= endIndex; i++) { DDTreeNode <T> node = _Branches[i]; if (node != null) { node.ItemsInside(box, ref output); } } } else { foreach (T item in _Children) { if (_Tree.MaxXOf(item) >= box.MinX && _Tree.MinXOf(item) <= box.MaxX && _Tree.MaxYOf(item) >= box.MinY && _Tree.MinYOf(item) <= box.MaxY && _Tree.MaxZOf(item) >= box.MinZ && _Tree.MinZOf(item) <= box.MaxZ && !output.Contains(item)) { output.Add(item); } } } }
/// <summary> /// Find all items within the specified bounding box /// </summary> /// <param name="box">The bounding box to check</param> /// <param name="items">A collection to be populated with the items inside the box</param> public void ItemsInside(BoundingBox box, ref IList <T> output) { _RootNode.ItemsInside(box, ref output); }