diff --git a/Orthtree/include/CGAL/Orthtree.h b/Orthtree/include/CGAL/Orthtree.h index 19d9ea20b4e..17a7e70a204 100644 --- a/Orthtree/include/CGAL/Orthtree.h +++ b/Orthtree/include/CGAL/Orthtree.h @@ -105,11 +105,6 @@ public: */ using Node_index = std::size_t; - /*! - * \brief Optional index of a node in the tree. - */ - using Maybe_node_index = std::optional; - /*! \brief Set of bits representing this node's relationship to its parent. @@ -169,8 +164,8 @@ private: // data members : Property_array& m_node_contents; Property_array& m_node_depths; Property_array& m_node_coordinates; - Property_array& m_node_parents; - Property_array& m_node_children; + Property_array>& m_node_parents; + Property_array>& m_node_children; using Bbox_dimensions = std::array; Bbox m_bbox; @@ -202,8 +197,8 @@ public: m_node_contents(m_node_properties.add_property("contents")), m_node_depths(m_node_properties.add_property("depths", 0)), m_node_coordinates(m_node_properties.add_property("coordinates")), - m_node_parents(m_node_properties.add_property("parents")), - m_node_children(m_node_properties.add_property("children")) { + m_node_parents(m_node_properties.add_property>("parents")), + m_node_children(m_node_properties.add_property>("children")) { m_node_properties.emplace(); @@ -231,8 +226,8 @@ public: m_node_contents(m_node_properties.get_property("contents")), m_node_depths(m_node_properties.get_property("depths")), m_node_coordinates(m_node_properties.get_property("coordinates")), - m_node_parents(m_node_properties.get_property("parents")), - m_node_children(m_node_properties.get_property("children")), + m_node_parents(m_node_properties.get_property>("parents")), + m_node_children(m_node_properties.get_property>("children")), m_bbox(other.m_bbox), m_side_per_depth(other.m_side_per_depth) {} // move constructor @@ -242,8 +237,8 @@ public: m_node_contents(m_node_properties.get_property("contents")), m_node_depths(m_node_properties.get_property("depths")), m_node_coordinates(m_node_properties.get_property("coordinates")), - m_node_parents(m_node_properties.get_property("parents")), - m_node_children(m_node_properties.get_property("children")), + m_node_parents(m_node_properties.get_property>("parents")), + m_node_children(m_node_properties.get_property>("children")), m_bbox(other.m_bbox), m_side_per_depth(other.m_side_per_depth) { // todo: makes sure moved-from is still valid. Maybe this shouldn't be necessary. @@ -430,7 +425,7 @@ public: Node_index first = traversal.first_index(); - auto next = [=](const Self&, Node_index index) -> Maybe_node_index { + auto next = [=](const Self&, Node_index index) -> std::optional { return traversal.next_index(index); }; @@ -816,7 +811,7 @@ public: \return the index of the next sibling of n if n is not the last node in its parent, otherwise nothing. */ - const Maybe_node_index next_sibling(Node_index n) const { + const std::optional next_sibling(Node_index n) const { // Root node has no siblings if (is_root(n)) return {}; @@ -840,17 +835,17 @@ public: \return The index of the next sibling of the parent of n if n is not the root and its parent has a sibling, otherwise nothing. */ - const Maybe_node_index next_sibling_up(Node_index n) const { + const std::optional next_sibling_up(Node_index n) const { // the root node has no next sibling up if (n == 0) return {}; - auto up = Maybe_node_index{parent(n)}; + auto up = std::optional{parent(n)}; while (up) { if (next_sibling(*up)) return {next_sibling(*up)}; - up = is_root(*up) ? Maybe_node_index{} : Maybe_node_index{parent(*up)}; + up = is_root(*up) ? std::optional{} : std::optional{parent(*up)}; } return {}; @@ -884,7 +879,7 @@ public: \return the index of the `d`th first child, nothing if the tree is not deep enough. */ - Maybe_node_index first_child_at_depth(Node_index n, std::size_t d) const { + std::optional first_child_at_depth(Node_index n, std::size_t d) const { std::queue todo; todo.push(n); @@ -1069,7 +1064,7 @@ public: \return the index of the adjacent node if it exists, nothing otherwise. */ - Maybe_node_index adjacent_node(Node_index n, const Local_coordinates& direction) const { + std::optional adjacent_node(Node_index n, const Local_coordinates& direction) const { // Direction: LEFT RIGHT DOWN UP BACK FRONT // direction: 000 001 010 011 100 101 @@ -1118,7 +1113,7 @@ public: \param n index of the node to find a neighbor of \param adjacency which way to find the adjacent node relative to this one */ - Maybe_node_index adjacent_node(Node_index n, Adjacency adjacency) const { + std::optional adjacent_node(Node_index n, Adjacency adjacency) const { return adjacent_node(n, std::bitset(static_cast(adjacency))); }