I was hoping to get an example or more information on how to create an ON_RTree when I have a large list of points to insert. Currently, I insert the points one-by-one starting from an empty ON_RTree made by using the parameter-less constructor of ON_RTree.
Maybe the question is whether it is more efficient to use ON_MEMORY_POOL and leaf_count, and, if so, how to do this.
Seeing the constructor for ON_RTree with a leaf count and an ON_MEMORY_POOL made me thinking that if I know the leaf count before I create the tree that the inserting would be more efficient.
Also, some references seem to suggest that bulk insert can be made more efficient than one-by-one insert.
ON_MEMORY_POOL parameter:
There is no efficiency gain in creation or use of an ON_RTree for using a custom memory pool. That parameter is provided so you can skip the destruction step and not leak heap by simply destroying the heap. In general, this is useful when you want to cancel a large and complicated calculation that you have carefully designed to use all heap from an ON_MEMORY_POOL you are managing. When canceling, you can simple destroy the heap and skip carefully cleaning up all the bits and pieces that may be in use when the user decided to cancel.
leaf_count
If you are lucky enough to know the number of leaves in the tree, then specifying the leaf count can marginally reduce the amount of memory overhead. However, using this parameter will not improve creation or use performance.
You need to insert the items one at a time so the spatial decomposition tree can be properly balanced.
General use:
The ON_RTree is designed to provide a tool that can be used for multiple high speed searches through a collection of lots of smallish objects that are spread over a largish region.
If you are doing a single search, or all the leaves are in the same place, or there are only a few leaves, then ON_RTree is not the correct tool.