-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtraversal.cpp
39 lines (33 loc) · 1.03 KB
/
traversal.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Copyright (C) 2024, Inria
* GRAPHDECO research group, https://team.inria.fr/graphdeco
* All rights reserved.
*
* This software is free for non-commercial, research and evaluation use
* under the terms of the LICENSE.md file.
*
* For inquiries contact [email protected]
*/
#include "traversal.h"
void recExpand(int node_id, Node* nodes, std::vector<int>& indices, int target)
{
Node& node = nodes[node_id];
for (int i = 0; i < node.count_leafs; i++)
indices.push_back(node.start + i);
if (node.depth <= target) // We are below target. Nodes will not be expanded, content approximated
{
for (int i = 0; i < node.count_merged; i++)
indices.push_back(node.start + node.count_leafs + i);
}
else // we keep expanding and adding visible leaves
{
for (int i = 0; i < node.count_children; i++)
recExpand(node.start_children + i, nodes, indices, target);
}
}
std::vector<int> Traversal::expandToTarget(Node* nodes, int target)
{
std::vector<int> indices;
recExpand(0, nodes, indices, target);
return indices;
}