Skip to content

Commit

Permalink
Rename depth_first to preorder
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Jun 25, 2020
1 parent 43a9819 commit f88dd80
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Octree/include/CGAL/Octree.h
Expand Up @@ -186,6 +186,10 @@ namespace CGAL {
os << ". ";

os << "(" << node->location()[0] << "," << node->location()[1] << "," << node->location()[2] << ") ";

if (node->num_points() > 0)
os << " [" << node->num_points() << " points]";

os << std::endl;

node = tree_walker(node);
Expand Down
21 changes: 11 additions & 10 deletions Octree/include/CGAL/Octree/Tree_walker_criterion.h
Expand Up @@ -8,7 +8,7 @@ namespace CGAL {

// Passing null returns the first node
if (nullptr == n)
return n;
return nullptr;

// If this node has no parent, it has no siblings
if (nullptr == n->parent())
Expand All @@ -25,7 +25,7 @@ namespace CGAL {
return &((*n->parent())[index + 1]);
}

struct Depth_first {
struct Preorder {

template<class Node>
Node *first(Node *root) {
Expand All @@ -42,19 +42,20 @@ namespace CGAL {

if (n->is_leaf()) {

// Check if this node is the last sibling
if (7 != n->index().to_ulong()) {
Node *next = next_sibling(n);

if (nullptr == next) {

Node *parent = n->parent();

// Return the next sibling
return (next_sibling(n));
if (nullptr == parent)
return nullptr;

} else {
return next_sibling(parent);

// Return the next sibling of the parent
// FIXME: this should be able to search upwards at the last sibling
return (next_sibling(n->parent()));
}

return next;

} else {

Expand Down
3 changes: 2 additions & 1 deletion Octree/test/Octree/test_tree_walk.cpp
Expand Up @@ -41,7 +41,8 @@ int main(void) {
Octree octree(points, point_map);
octree.refine(10, 1);

auto treeWalker = CGAL::Depth_first();
auto treeWalker = CGAL::Preorder();
std::cout << octree.root() << std::endl;
octree.print(std::cout, treeWalker.first(&octree.root()), treeWalker);

return 0;
Expand Down

0 comments on commit f88dd80

Please sign in to comment.