コード例 #1
0
        // traversal implementation. you can override to customize this if necessary.
        protected virtual void tree_traversal(int iBox, int depth, TreeTraversal traversal)
        {
            int idx = box_to_index[iBox];

            if (idx < points_end)
            {
                // point-list case, array is [N t1 t2 ... tN]
                int n = index_list[idx];
                for (int i = 1; i <= n; ++i)
                {
                    int ti = index_list[idx + i];
                    if (PointFilterF != null && PointFilterF(ti) == false)
                    {
                        continue;
                    }

                    traversal.NextPointF(ti);
                }
            }
            else
            {
                int i0 = index_list[idx];
                if (i0 < 0)
                {
                    // negative index means we only have one 'child' box to descend into
                    i0 = (-i0) - 1;
                    if (traversal.NextBoxF(get_box(i0), depth + 1))
                    {
                        tree_traversal(i0, depth + 1, traversal);
                    }
                }
                else
                {
                    // positive index, two sequential child box indices to descend into
                    i0 = i0 - 1;
                    if (traversal.NextBoxF(get_box(i0), depth + 1))
                    {
                        tree_traversal(i0, depth + 1, traversal);
                    }

                    int i1 = index_list[idx + 1] - 1;
                    if (traversal.NextBoxF(get_box(i1), depth + 1))
                    {
                        tree_traversal(i1, depth + 1, traversal);
                    }
                }
            }
        }