Rtree Insert\Remove

Hi,

i have difficulties in understanding the insert\remove mechanism of Rtrees in Rhino. Why do I need an index AND a point position to remove a point? And what is this pointposition refering to (also bounding box can be used)?

I can do
rtree = rc.Geometry.RTree() rtree.Insert(rs.coerce3dpoint([1,1,1]),10) print rtree.Count rtree.Remove(rs.coerce3dpoint([1,1,1]), 10) print rtree.Count

but this is also working.
rtree = rc.Geometry.RTree() rtree.Insert(rs.coerce3dpoint([1,1,1]),10) print rtree.Count rtree.Remove(rs.coerce3dpoint([1,1,2]), 10) print rtree.Count

Whats taking place under the hood? I am trying to add and remove a lot of points from rtree in several iterations. But if I always need to know the position of the point I want to remove I will run into performance issues.

Thanks in advance!

Philip

1 Like

Did you ever find an answer to this @powerpp?

RTree is a spatial data-structure meaning that

  1. RTree has its own logic of indexing based on geometric properties i.e. bounding boxes or points
  2. Index given by a user just maps to original list

You can see this as a Dictionary with optimized spatial sorting.
I recommend to read Wikipedia what is RTree.