Example #1
0
        /// <summary>
        /// Also builds the tree, if necessary.
        /// </summary>
        /// <param name="searchBounds"></param>
        /// <param name="visitor"></param>
        protected virtual void Query(Object searchBounds, IItemVisitor visitor)
        {
            if (!built)
            {
                Build();
            }

            if (itemBoundables.Count == 0)
            {
                Assert.IsTrue(root.Bounds == null);
            }

            if (IntersectsOp.Intersects(root.Bounds, searchBounds))
            {
                Query(searchBounds, root, visitor);
            }
        }
Example #2
0
        /// <summary>
        /// Also builds the tree, if necessary.
        /// </summary>
        /// <param name="searchBounds"></param>
        protected virtual IList Query(object searchBounds)
        {
            if (!built)
            {
                Build();
            }
            ArrayList matches = new ArrayList();

            if (itemBoundables.Count == 0)
            {
                Assert.IsTrue(root.Bounds == null);
                return(matches);
            }
            if (IntersectsOp.Intersects(root.Bounds, searchBounds))
            {
                Query(searchBounds, root, matches);
            }
            return(matches);
        }
Example #3
0
        protected void Query(T searchBounds, IItemVisitor <TItem> visitor)
        {
            Build();

            if (IsEmpty)
            {
                return;
            }

            //if (_itemBoundables.Count == 0)
            //{
            //    //nothing in tree, so return
            //    //Assert.IsTrue(_root.Bounds == null);
            //    return;
            //}

            if (IntersectsOp.Intersects(_root.Bounds, searchBounds))
            {
                Query(searchBounds, _root, visitor);
            }
        }
Example #4
0
 private void Query(T searchBounds, AbstractNode <T, TItem> node, IItemVisitor <TItem> visitor)
 {
     foreach (var childBoundable in node.ChildBoundables)
     {
         if (!IntersectsOp.Intersects(childBoundable.Bounds, searchBounds))
         {
             continue;
         }
         if (childBoundable is AbstractNode <T, TItem> )
         {
             Query(searchBounds, (AbstractNode <T, TItem>)childBoundable, visitor);
         }
         else if (childBoundable is ItemBoundable <T, TItem> )
         {
             visitor.VisitItem(((ItemBoundable <T, TItem>)childBoundable).Item);
         }
         else
         {
             Assert.ShouldNeverReachHere();
         }
     }
 }
Example #5
0
        private void Query(T searchBounds, AbstractNode <T, TItem> node, IList <TItem> matches)
        {
            foreach (var childBoundable in node.ChildBoundables)
            {
                if (!IntersectsOp.Intersects(childBoundable.Bounds, searchBounds))
                {
                    continue;
                }

                if (childBoundable is AbstractNode <T, TItem> )
                {
                    Query(searchBounds, (AbstractNode <T, TItem>)childBoundable, matches);
                }
                else if (childBoundable is ItemBoundable <T, TItem> )
                {
                    matches.Add(((ItemBoundable <T, TItem>)childBoundable).Item);
                }
                else
                {
                    Assert.ShouldNeverReachHere();
                }
            }
        }
Example #6
0
        /// <summary>
        /// Also builds the tree, if necessary.
        /// </summary>
        /// <param name="searchBounds"></param>
        protected IList <TItem> Query(T searchBounds)
        {
            Build();

            var matches = new List <TItem>();

            if (IsEmpty)
            {
                return(matches);
            }

            //if (_itemBoundables.Count == 0)
            //{
            //    //Assert.IsTrue(_root.Bounds == null);
            //    return matches;
            //}

            if (IntersectsOp.Intersects(_root.Bounds, searchBounds))
            {
                Query(searchBounds, _root, matches);
            }
            return(matches);
        }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="searchBounds"></param>
 /// <param name="node"></param>
 /// <param name="visitor"></param>
 private void Query(object searchBounds, AbstractNode node, IItemVisitor visitor)
 {
     foreach (object obj in node.ChildBoundables)
     {
         IBoundable childBoundable = (IBoundable)obj;
         if (!IntersectsOp.Intersects(childBoundable.Bounds, searchBounds))
         {
             continue;
         }
         if (childBoundable is AbstractNode)
         {
             Query(searchBounds, (AbstractNode)childBoundable, visitor);
         }
         else if (childBoundable is ItemBoundable)
         {
             visitor.VisitItem(((ItemBoundable)childBoundable).Item);
         }
         else
         {
             Assert.ShouldNeverReachHere();
         }
     }
 }
Example #8
0
        private void Query(object searchBounds, AbstractNode node, IList matches)
        {
            foreach (var obj in node.ChildBoundables)
            {
                var childBoundable = (IBoundable)obj;
                if (!IntersectsOp.Intersects(childBoundable.Bounds, searchBounds))
                {
                    continue;
                }

                if (childBoundable is AbstractNode)
                {
                    Query(searchBounds, (AbstractNode)childBoundable, matches);
                }
                else if (childBoundable is ItemBoundable)
                {
                    matches.Add(((ItemBoundable)childBoundable).Item);
                }
                else
                {
                    Assert.ShouldNeverReachHere();
                }
            }
        }