Пример #1
0
        protected bool box_contains(int iBox, Vector3d p)
        {
            // [TODO] this could be way faster...
            var      c   = (Vector3d)box_centers[iBox];
            Vector3d e   = box_extents[iBox];
            var      box = new AxisAlignedBox3d(ref c, e.x + box_eps, e.y + box_eps, e.z + box_eps);

            return(box.Contains(p));
        }
Пример #2
0
        // do full tree traversal below iBox to make sure that all child points are contained
        void debug_check_child_points_in_box(int iBox)
        {
            AxisAlignedBox3d box = get_box(iBox);
            TreeTraversal    t   = new TreeTraversal()
            {
                NextPointF = (vID) => {
                    Vector3d v = points.GetVertex(vID);
                    if (box.Contains(v) == false)
                    {
                        Util.gBreakToDebugger();
                    }
                }
            };

            tree_traversal(iBox, 0, t);
        }
Пример #3
0
        // accumulate point counts and track each box-parent index.
        // also checks that points are contained in boxes
        private void test_coverage(int[] point_counts, int[] parent_indices, int iBox)
        {
            int idx = box_to_index[iBox];

            debug_check_child_points_in_box(iBox);

            if (idx < points_end)
            {
                // point-list case, array is [N t1 t2 ... tN]
                int n = index_list[idx];
                AxisAlignedBox3d box = get_box(iBox);
                for (int i = 1; i <= n; ++i)
                {
                    int vi = index_list[idx + i];
                    point_counts[vi]++;
                    Vector3d v = points.GetVertex(vi);
                    if (!box.Contains(v))
                    {
                        Util.gBreakToDebugger();
                    }
                }
            }
            else
            {
                int i0 = index_list[idx];
                if (i0 < 0)
                {
                    // negative index means we only have one 'child' box to descend into
                    i0 = (-i0) - 1;
                    parent_indices[i0] = iBox;
                    test_coverage(point_counts, parent_indices, i0);
                }
                else
                {
                    // positive index, two sequential child box indices to descend into
                    i0 = i0 - 1;
                    parent_indices[i0] = iBox;
                    test_coverage(point_counts, parent_indices, i0);
                    int i1 = index_list[idx + 1];
                    i1 = i1 - 1;
                    parent_indices[i1] = iBox;
                    test_coverage(point_counts, parent_indices, i1);
                }
            }
        }