diff --git a/Orthtree/include/CGAL/Orthtree.h b/Orthtree/include/CGAL/Orthtree.h index dce5637e089..e67caf2fa06 100644 --- a/Orthtree/include/CGAL/Orthtree.h +++ b/Orthtree/include/CGAL/Orthtree.h @@ -110,6 +110,11 @@ public: */ typedef std::size_t Node_index; + /*! + * \brief Optional index of a node in the tree. + */ + typedef boost::optional Maybe_node_index; + /*! * \brief The Sub-tree / Orthant type. */ @@ -443,7 +448,7 @@ public: return std::distance(m_nodes.data(), &node); } - boost::optional index(const Node* node) const { + Maybe_node_index index(const Node* node) const { if (node == nullptr) return {}; return index(*node); } @@ -480,7 +485,7 @@ public: auto first = traversal.first_index(); - auto next = [=](const Self& tree, Node_index index) -> boost::optional { + auto next = [=](const Self& tree, Node_index index) -> Maybe_node_index { return traversal.next_index(index); }; @@ -493,7 +498,7 @@ public: Node_index first = traversal.first_index(); - auto next = [=](const Self& tree, Node_index index) -> boost::optional { + auto next = [=](const Self& tree, Node_index index) -> Maybe_node_index { return traversal.next_index(index); }; @@ -719,7 +724,7 @@ public: return m_nodes[node].m_children_index.get() + i; } - const boost::optional next_sibling(Node_index n) const { + const Maybe_node_index next_sibling(Node_index n) const { // Root node has no siblings if (is_root(n)) return {}; @@ -735,17 +740,17 @@ public: return child(parent(n), local_coords + 1); } - const boost::optional next_sibling_up(Node_index n) const { + const Maybe_node_index next_sibling_up(Node_index n) const { // the root node has no next sibling up if (n == 0) return {}; - auto up = boost::optional{parent(n)}; + auto up = Maybe_node_index{parent(n)}; while (up) { if (next_sibling(up.get())) return {next_sibling(up.get())}; - up = is_root(up.get()) ? boost::optional{} : boost::optional{parent(up.get())}; + up = is_root(up.get()) ? Maybe_node_index{} : Maybe_node_index{parent(up.get())}; } return {}; @@ -760,7 +765,7 @@ public: return first; } - boost::optional first_child_at_depth(Node_index n, std::size_t d) const { + Maybe_node_index first_child_at_depth(Node_index n, std::size_t d) const { std::queue todo; todo.push(n); @@ -916,7 +921,7 @@ public: \return the index of the adjacent node if it exists, nothing otherwise. */ - boost::optional adjacent_node(Node_index n, typename Node::Local_coordinates direction) const { + Maybe_node_index adjacent_node(Node_index n, typename Node::Local_coordinates direction) const { // Direction: LEFT RIGHT DOWN UP BACK FRONT // direction: 000 001 010 011 100 101 @@ -962,7 +967,7 @@ public: /*! \brief equivalent to `adjacent_node()`, with an adjacency direction rather than a bitset. */ - boost::optional adjacent_node(Node_index n, typename Node::Adjacency adjacency) const { + Maybe_node_index adjacent_node(Node_index n, typename Node::Adjacency adjacency) const { return adjacent_node(n, std::bitset(static_cast(adjacency))); } diff --git a/Orthtree/include/CGAL/Orthtree/Node.h b/Orthtree/include/CGAL/Orthtree/Node.h index bce33e2191f..ca6bce35e5a 100644 --- a/Orthtree/include/CGAL/Orthtree/Node.h +++ b/Orthtree/include/CGAL/Orthtree/Node.h @@ -49,6 +49,7 @@ public: typedef typename Enclosing::Dimension Dimension; ///< Dimension type. typedef typename Enclosing::Degree Degree; ///< Degree type. typedef typename Enclosing::Node_index Node_index; ///< Index type. + typedef typename Enclosing::Maybe_node_index Maybe_node_index; ///< Index type. /*! \brief Self typedef for convenience. @@ -98,8 +99,8 @@ private: std::uint8_t m_depth = 0; Global_coordinates m_global_coordinates{}; - boost::optional m_parent_index{}; - boost::optional m_children_index{}; + Maybe_node_index m_parent_index{}; + Maybe_node_index m_children_index{}; // Only the Orthtree class has access to the non-default // constructor, mutators, etc.