Пример #1
0
        /// <summary>
        /// 指定境界ボリュームと接触する葉ノードを反復処理する列挙子の取得
        /// </summary>
        /// <param name="volume">境界ボリューム</param>
        /// <returns>列挙子</returns>
        public IEnumerable <LeafNode> QueryLeaves(volume volume)
        {
            Stack <Node> stack = new Stack <Node>(256);

            stack.Push(_Root);
            while (stack.Count != 0)
            {
                var node = stack.Pop();
                if (node == null)
                {
                    continue;
                }

                if (volume.Intersects(node.Volume))
                {
                    var leaf = node.AsLeaf;
                    if (leaf != null)
                    {
                        yield return(leaf);
                    }
                    else
                    {
                        var branch = node.AsBranch;
                        stack.Push(branch.Child1);
                        stack.Push(branch.Child2);
                    }
                }
            }
        }