'How to get all bounds from boost::rtree

I have a built boost rtree:

using CBGPoint3d    = boost::geometry::model::point<float, 3, boost::geometry::cs::cartesian>;
using CBGBox3D      = boost::geometry::model::box<CBGPoint3d>;
using CBGTreeItem   = std::pair<CBGBox3D, CEntityLoaderBase*>;

boost::geometry::index::rtree<CBGTreeItem, boost::geometry::index::dynamic_rstar> m_tree;

I can iterate through leaf nodes:

for (auto const& v : m_tree)
   //do something

I can get root bounds:

m_tree.bounds();

But how can I get other level bounds ? There is no bounds iterator....



Solution 1:[1]

This is not a part of the official interface but it is possible to traverse the R-tree manually. You have to implement your own node visitor and use bgi::detail::rtree::utilities::view<Rtree> to apply it to the root node. Have a look at the utilities in this directory:

https://github.com/boostorg/geometry/tree/develop/include/boost/geometry/index/detail/rtree/utilities

in particular the one checking correctness of bounding boxes in the hierarchy:

https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/index/detail/rtree/utilities/are_boxes_ok.hpp

and the one gathering statistics about the internal structure of the R-tree:

https://github.com/boostorg/geometry/blob/develop/include/boost/geometry/index/detail/rtree/utilities/statistics.hpp

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Adam Wulkiewicz