/// <summary> /// Queries this index and returns all objects with overlapping bounding boxes. /// </summary> /// <param name="box"></param> /// <returns></returns> public IEnumerable <T> Get(BoxF2D box) { var result = new HashSet <T>(); RTreeMemoryIndex <T> .Get(_root, box, result); return(result); }
public IEnumerable <T> Get(BoxF2D box) { HashSet <T> result = new HashSet <T>(); RTreeMemoryIndex <T> .Get(this._root, box, result); return((IEnumerable <T>)result); }
/// <summary> /// Fills the collection with data. /// </summary> /// <param name="node"></param> /// <param name="box"></param> /// <param name="result"></param> private static void Get(Node node, BoxF2D box, HashSet <T> result) { if (node.Children is List <Node> ) { var children = (node.Children as List <Node>); for (int idx = 0; idx < children.Count; idx++) { if (box.Overlaps(node.Boxes[idx])) { if (box.Contains(node.Boxes[idx])) { // add all the data from the child. RTreeMemoryIndex <T> .GetAll(children[idx], result); } else { // add the data from the child. RTreeMemoryIndex <T> .Get(children[idx], box, result); } } } } else { var children = (node.Children as List <T>); if (children != null) { // the children are of the data type. for (int idx = 0; idx < node.Children.Count; idx++) { if (node.Boxes[idx].Overlaps(box)) { result.Add(children[idx]); } } } } }
private static void Get(RTreeMemoryIndex <T> .Node node, BoxF2D box, HashSet <T> result) { if (node.Children is List <RTreeMemoryIndex <T> .Node> ) { List <RTreeMemoryIndex <T> .Node> children = node.Children as List <RTreeMemoryIndex <T> .Node>; for (int index = 0; index < children.Count; ++index) { if (box.Overlaps(node.Boxes[index])) { if (box.Contains(node.Boxes[index])) { RTreeMemoryIndex <T> .GetAll(children[index], result); } else { RTreeMemoryIndex <T> .Get(children[index], box, result); } } } } else { List <T> children = node.Children as List <T>; if (children == null) { return; } for (int index = 0; index < node.Children.Count; ++index) { if (node.Boxes[index].Overlaps(box)) { result.Add(children[index]); } } } }