コード例 #1
0
        private static void RecursivelyWalkNode(Node node, Box space, ref List <T> found, ref int numTests)
        {
            if (node.IsLeaf)
            {
                LeafNode leaf = (LeafNode)node;
                numTests++;
                if (space.Intersects(leaf.BoundingBox))
                {
                    numTests += leaf.Elements.Count;
                    foreach (Entry e in leaf.Elements)
                    {
                        if (space.Intersects(e.BoundingBox))
                        {
                            found.Add(e.Element);
                        }
                    }
                }
                return;
            }
            InnerNode n = (InnerNode)node;

            numTests++;
            if (space.Intersects(n.BoundingBox))
            {
                RecursivelyWalkNode(n.Child0, space, ref found, ref numTests);
                RecursivelyWalkNode(n.Child1, space, ref found, ref numTests);
            }
        }
コード例 #2
0
        private void TraceWalkNode(Node node, Box space, int indent = 0)
        {
            PrintLine(indent, node.ToString());
            PrintLine(indent, "{");
            if (node.IsLeaf)
            {
                if (space.Intersects(((LeafNode)node).BoundingBox))
                {
                    PrintLine(indent + 1, "space lookup success. returning the following...");
                }
                else
                {
                    PrintLine(indent + 1, "space lookup failed.");
                    PrintLine(indent + 1, "comparing " + ((LeafNode)node).BoundingBox + " with " + space);

                    PrintLine(indent + 1, "NOT returning the following...");
                }

                foreach (Entry e in ((LeafNode)node).Elements)
                {
                    PrintLine(indent + 1, e.Element + " at " + e.BoundingBox.Center);
                }
            }
            else
            {
                InnerNode n = (InnerNode)node;
                if (space.Intersects(n.BoundingBox))
                {
                    TraceWalkNode(n.Child0, space, indent + 1);
                    TraceWalkNode(n.Child1, space, indent + 1);
                }
            }
            PrintLine(indent, "}");
        }
コード例 #3
0
        private static void walkNode(Node node, Box space, ref List <T> found)
        {
            if (node.IsLeaf)
            {
                LeafNode leaf = (LeafNode)node;
                if (space.Intersects(leaf.BoundingBox))
                {
                    foreach (Entry e in leaf.Elements)
                    {
                        if (space.Intersects(e.BoundingBox))
                        {
                            found.Add(e.Element);
                        }
                    }
                }
                return;
            }
            InnerNode n = (InnerNode)node;

            if (space.Intersects(n.BoundingBox))
            {
                walkNode(n.Child0, space, ref found);
                walkNode(n.Child1, space, ref found);
            }
        }