From f39ee93a47bda34347e8bbcffd7c2a01dc831f90 Mon Sep 17 00:00:00 2001 From: Jackson Campolattaro Date: Mon, 29 Jun 2020 12:31:56 -0400 Subject: [PATCH] Add boost iterator over nodes as member class of octree --- Octree/include/CGAL/Octree.h | 36 ++++++++++++++++++++++++--- Octree/test/Octree/test_tree_walk.cpp | 2 ++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Octree/include/CGAL/Octree.h b/Octree/include/CGAL/Octree.h index 5d77494b1a3f..6b7038473274 100644 --- a/Octree/include/CGAL/Octree.h +++ b/Octree/include/CGAL/Octree.h @@ -40,6 +40,7 @@ */ #include #include +#include #include #include #include @@ -63,15 +64,41 @@ namespace CGAL { // Define the Node based on this kernel typedef Octree_node Node; - // Some other useful types typedef typename Kernel::FT FT; typedef typename Kernel::Vector_3 Vector; typedef typename Kernel::Iso_cuboid_3 Iso_cuboid; - // New Types : typedef typename PointRange::iterator Range_iterator; typedef typename std::iterator_traits::value_type Range_type; - // TODO: Kernel can be deduced from the point map + + public: // Classes + + class const_iterator : + public boost::iterator_facade { + + public: + + const_iterator() : m_node(0) {}; + + const_iterator(Node *p, std::function next) : m_node(p), m_next(next) {}; + + private: + friend class boost::iterator_core_access; + + void increment() { + // TODO: This will use a node traversal function + std::cout << "Incrementing" << std::endl; + } + + Node const &dereference() const { return *m_node; } + + private: + + Node const *m_node; + + std::function m_next; + + }; private: // data members : Node m_root; /* root node of the octree */ @@ -87,6 +114,7 @@ namespace CGAL { std::vector m_unit_per_depth; /* number of unit node (smallest) inside one node for each depth for one axis */ public: // functions : + Octree( PointRange &pwn, PointMap &point_map, @@ -210,7 +238,6 @@ namespace CGAL { return rhs.m_root == m_root; } - private: // functions : Point compute_barycenter_position(Node &node) const { @@ -263,6 +290,7 @@ namespace CGAL { Point center = compute_barycenter_position(node); reassign_points(node, node.points_begin(), node.points_end(), center); } + }; // end class Octree } // namespace CGAL diff --git a/Octree/test/Octree/test_tree_walk.cpp b/Octree/test/Octree/test_tree_walk.cpp index b37a9d6599fe..9ad92772087e 100644 --- a/Octree/test/Octree/test_tree_walk.cpp +++ b/Octree/test/Octree/test_tree_walk.cpp @@ -7,6 +7,8 @@ #include #include +#include + typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef CGAL::Point_set_3 Point_set;