I have a grid made of squares, where each element has of course its own (integer) index. I used boost to create an RTree of bounding boxes for this grid, and I am able to extract a level of the RTree, which consists of a std::vector<BoundingBox> containing all the bounding boxes that make the given level of the rtree.
So far so good.
My goal is now: for a given level of the RTree, how can I know the indices of the cell that are inside each BoundingBox?
For instance, say that my third level is made of 10 bounding boxes. For each one of these 10 bounding boxes, I'd like to know the indices of the original grid that are inside each bounding box.
I think that logically it should be possible to retrieve such an information from the tree structure, but I can't find any example around. Any help is highly appreciated.
There is no external tree traversal (just geometrical queries and enumeration).
If you have the bounding boxes, you can of course do a geometrical query for those on the tree. Note that you can composite indexables as tree value-types. For example
std::pair<Geom, Index>is built-in:When you get query results, you'll get the entire entry, so both the cell and the index.
Live On Coliru
With sample output: