c++boostboost-geometryr-tree

Boost rtree.bounds(): getting more boxes and/or accessing to its structure


Currently I am working with distributed meshes on a numerical simulation: I am using a boost rtree made of bounding boxes as a search tool. I have many bounding boxes, each with a tag (an unsigned int: the process which "owns" the cell).

At a global level I need a more "imprecise" description: thus I am using rtree.bounds() and then send this box around with a global communication. Unfortunately this doesn't always work, as the tags are generated in the following manners:

  1. boxes with the same tag are all clustered together: in this case it works like a charm.
  2. boxes with the same tag form two "connected" clusters: in this case the extra empty space means later computations will make a lot of useless communication

Since an rtree is made of bounding boxes, I am trying to access the rtree structure, so that I can get two or more (possibly few) crude bounding boxes (the first/second layer of the rtree). Is this possible? Or is there a quick algorithm to split the rtree.bounds() box?

Currently I am cutting the bounds bounding box "by hand", but since I have them already in the tree, I believe this is a waste of computational power.

Edit: I've found this forum http://boost-geometry.203548.n3.nabble.com/How-could-I-get-nodes-MBRs-of-the-R-Tree-td4026812.html which seems the answer to my question. I shall try to use it and, if solved, post the solution :)


Solution

  • As you found out there is a way of accessing nodes but it is not part of the official interface of the R-tree. You have to implement a visitor traversing the R-tree and apply it to the R-tree using boost::geometry::index::detail::rtree::utilities::view.

    Have a look at this visitor traversing the R-tree depth-first and checking at each level if bounding box of a node contains all elements from the lower level. Here you can see how this visitor is applied to the R-tree.