Skip to content

Commit

Permalink
Fix walker function
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonCampolattaro committed Jul 21, 2020
1 parent fbe4234 commit bd6e078
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 48 deletions.
6 changes: 4 additions & 2 deletions Octree/include/CGAL/Octree.h
Expand Up @@ -41,6 +41,8 @@
#include <vector>
#include <math.h>

using namespace std::placeholders;

namespace CGAL {

namespace Octree {
Expand Down Expand Up @@ -287,8 +289,8 @@ class Octree {

const Node *first = walker.first(&m_root);

Node_walker next = std::bind(&Walker::template next<Points_iterator_range>,
walker, std::placeholders::_1);
Node_walker next = std::bind(&Walker::template next<typename PointRange::iterator>,
walker, _1);

return boost::make_iterator_range(Walker_iterator<const Node>(first, next),
Walker_iterator<const Node>());
Expand Down
91 changes: 47 additions & 44 deletions Octree/include/CGAL/Octree/IO.h
Expand Up @@ -22,50 +22,6 @@

using std::ostream;

template<class PointRange,
class PointMap>
ostream &operator<<(ostream &os, const CGAL::Octree::Octree<PointRange, PointMap> &octree) {

// Create a range of nodes
// auto nodes = octree.template walk<CGAL::Octree::Walker::Preorder>();
auto nodes = octree.walk(CGAL::Octree::Walker::Preorder());

// Iterate over the range and print each node
// for (auto &n : nodes) {
//
// for (int i = 0; i < n.depth() - 1; ++i)
// os << " │ ";
//
// if (!n.is_root()) {
//
// if (n.index() == 7)
// os << " └─";
// else
// os << " ├─";
// }
//
// os << n << std::endl;
//
// if (!n.is_leaf()) {
//
// for (int i = 0; i < n.depth(); ++i)
// os << " │ ";
//
// os << " ┬ " << std::endl;
// }
// }

// Iterate over the range and print each node
for (auto &n : nodes) {

for (int i = 0; i < n.depth(); ++i)
os << ". ";

os << n << std::endl;
}

return os;
}

template<typename Value>
ostream &operator<<(ostream &os, const CGAL::Octree::Node::Node<Value> &node) {
Expand Down Expand Up @@ -112,4 +68,51 @@ ostream &operator<<(ostream &os, const CGAL::Octree::Node::Node<Value> &node) {
return os;
}

template<class PointRange,
class PointMap>
ostream &operator<<(ostream &os, const CGAL::Octree::Octree<PointRange, PointMap> &octree) {

// Create a range of nodes
// auto nodes = octree.template walk<CGAL::Octree::Walker::Preorder>();
auto nodes = octree.walk(CGAL::Octree::Walker::Preorder());

// Iterate over the range and print each node
// for (auto &n : nodes) {
//
// for (int i = 0; i < n.depth() - 1; ++i)
// os << " │ ";
//
// if (!n.is_root()) {
//
// if (n.index() == 7)
// os << " └─";
// else
// os << " ├─";
// }
//
// os << n << std::endl;
//
// if (!n.is_leaf()) {
//
// for (int i = 0; i < n.depth(); ++i)
// os << " │ ";
//
// os << " ┬ " << std::endl;
// }
// }

// Iterate over the range
for (auto &n : nodes) {

// Show the depth
for (int i = 0; i < n.depth(); ++i)
os << ". ";

// Print the node
os << n << std::endl;
}

return os;
}

#endif //CGAL_OCTREE_IO_H
2 changes: 0 additions & 2 deletions Octree/test/Octree/test_tree_walk.cpp
Expand Up @@ -108,8 +108,6 @@ bool test_preorder_25_nodes() {
assert((*iter == octree.root()[7][i]));
}

std::cout << octree;

return true;
}

Expand Down

0 comments on commit bd6e078

Please sign in to comment.