/// <summary> /// Returns all nodes in this quadrant that intersect the given bounds. /// The nodes are returned in pretty much random order as far as the caller is concerned. /// </summary> /// <param name="nodes">List of nodes found in the given bounds</param> /// <param name="bounds">The bounds that contains the nodes you want returned</param> public void GetIntersectingNodes(IList <IMesQuadNode <T> > nodes, RectangleF bounds) { if (bounds.IsEmpty) { return; } Single w = Bounds.Width / 2; Single h = Bounds.Height / 2; // assumption that the Rect struct is almost as fast as doing the operations // manually since Rect is a value type. RectangleF topLeft = new RectangleF(Bounds.Left, Bounds.Top, w, h); RectangleF topRight = new RectangleF(Bounds.Left + w, Bounds.Top, w, h); RectangleF bottomLeft = new RectangleF(Bounds.Left, Bounds.Top + h, w, h); RectangleF bottomRight = new RectangleF(Bounds.Left + w, Bounds.Top + h, w, h); // See if any child quadrants completely contain this node. if (topLeft.IntersectsWith(bounds) && TopLeft != null) { TopLeft.GetIntersectingNodes(nodes, bounds); } if (topRight.IntersectsWith(bounds) && TopRight != null) { TopRight.GetIntersectingNodes(nodes, bounds); } if (bottomLeft.IntersectsWith(bounds) && BottomLeft != null) { BottomLeft.GetIntersectingNodes(nodes, bounds); } if (bottomRight.IntersectsWith(bounds) && BottomRight != null) { BottomRight.GetIntersectingNodes(nodes, bounds); } GetIntersectingNodes(Nodes, nodes, bounds); }