public class RTree : IDisposable
Represents a spatial search structure based on implementations of the R-tree algorithm by Toni Gutman.
Remarks: The opennurbs rtree code is a modified version of the free and unrestricted R-tree implementation obtained from http://www.superliminal.com/sources/sources.htm .

Constructors

RTree

#ExampleSince v5.0
Initializes a new, empty instance of the tree.
public RTree()

Finalizer

~RTree

#
Passively reclaims unmanaged resources when the class user did not explicitly call Dispose().
~RTree()

Properties

Count

#Since v5.0
Gets the number of items in this tree.
public int Count { get; }

Methods

Clear

#Since v5.0
Removes all elements.
public void Clear()

CreateFromPointArray

#Since v6.0
Constructs a new tree with an element for each point cloud point.
public static RTree CreateFromPointArray(
points
Points.
)
A new tree, or null on error.

CreateMeshFaceTree

#Since v5.0
Constructs a new tree with an element for each face in the mesh. The element id is set to the index of the face.
public static RTree CreateMeshFaceTree(
Mesh
mesh
A mesh.
)
A new tree, or null on error.

CreatePointCloudTree

#Since v5.0
Constructs a new tree with an element for each point cloud point.
public static RTree CreatePointCloudTree(
cloud
A point cloud.
)
A new tree, or null on error.

Dispose

#Since v5.0
Actively reclaims unmanaged resources that this instance uses.
public void Dispose()

Dispose

#
For derived class implementers.

This method is called with argument true when class user calls Dispose(), while with argument false when the Garbage Collector invokes the finalizer, or Finalize() method.

You must reclaim all used unmanaged resources in both cases, and can use this chance to call Dispose on disposable fields if the argument is true.

Also, you must call the base virtual method within your overriding method.

protected virtual void Dispose(
disposing
true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer.
)

Insert

#Since v5.0
Inserts an element into the tree.
public bool Insert(
box,
A bounding box.
elementId
A number.
)
true if element was successfully inserted.

Insert

#Since v5.0
Inserts an element into the tree.
public bool Insert(
box,
A bounding box.
nint
elementId
A pointer.
)
true if element was successfully inserted.

Insert

#Since v5.0
Inserts an element into the tree.
public bool Insert(
point,
A point.
elementId
A number.
)
true if element was successfully inserted.

Insert

#Since v5.0
Inserts an element into the tree.
public bool Insert(
point,
A point.
nint
elementId
A pointer.
)
true if element was successfully inserted.

Insert

#ExampleSince v5.0
Inserts an element into the tree.
public bool Insert(
point,
A point.
elementId
A number.
)
true if element was successfully inserted.

Insert

#Since v5.0
Inserts an element into the tree.
public bool Insert(
point,
A point.
nint
elementId
A pointer.
)
true if element was successfully inserted.

Point3dClosestPoints

#Since v6.0
Finds the point in a list of 3D points that is closest to a test point.
public static IEnumerable<int[]> Point3dClosestPoints(
hayPoints,
A series of points.
needlePts,
Points to search for.
limitDistance
The maximum allowed distance.
)
An enumerable of arrays of indices; each array contains the indices for each of the needlePts.

Point3dKNeighbors

#Since v6.0
Finds a certain amount of points in a list of 3D points that are the k-closest to a test point.
public static IEnumerable<int[]> Point3dKNeighbors(
hayPoints,
A series of points.
needlePts,
Points to search for.
amount
The required amount of closest neighbors to find.
)
An enumerable of arrays of indices; each array contains the indices for each of the needlePts.

PointCloudClosestPoints

#Since v6.0
Finds the point in a list of 3D points that is closest to a test point.
public static IEnumerable<int[]> PointCloudClosestPoints(
pointcloud,
A point cloud to be searched.
needlePts,
Points to search for.
limitDistance
The maximum allowed distance.
)
An enumerable of arrays of indices; each array contains the indices for each of the needlePts.

PointCloudKNeighbors

#Since v6.0
Finds a certain amount of points in a list of 3D points that are the k-closest to a test point.
public static IEnumerable<int[]> PointCloudKNeighbors(
pointcloud,
A point cloud to be searched.
needlePts,
Points to search for.
amount
The required amount of closest neighbors to find.
)
An enumerable of arrays of indices; each array contains the indices for each of the needlePts.

Remove

#Since v5.0
Removes an element from the tree.
public bool Remove(
box,
A bounding box.
elementId
A number.
)
true if element was successfully removed.

Remove

#Since v5.0
Removes an element from the tree.
public bool Remove(
box,
A bounding box.
nint
elementId
A pointer.
)
true if element was successfully removed.

Remove

#Since v5.0
Removes an element from the tree.
public bool Remove(
point,
A point.
elementId
A number.
)
true if element was successfully removed.

Remove

#Since v5.0
Removes an element from the tree.
public bool Remove(
point,
A point.
elementId
A number.
)
true if element was successfully removed.

Remove

#Since v5.0
Removes an element from the tree.
public bool Remove(
point,
A point.
nint
elementId
A pointer.
)
true if element was successfully removed.

Search

#Since v5.0
Searches for items in a bounding box.

The bounding box can be singular and contain exactly one single point.

public bool Search(
box,
A bounding box.
callback,
An event handler to be raised when items are found.
tag
State to be passed inside the RTreeEventArgs Tag property.
)
Remarks: Do not modify the tree while a Search() is in progress. Doing so can have unintended consequences, including corruption and crashes.If you need to modify the tree, collect the results during the search and modify the tree once the search is completed.
true if entire tree was searched. It is possible no results were found.

Search

#Since v5.0
Searches for items in a bounding box.

The bounding box can be singular and contain exactly one single point.

public bool Search(
box,
A bounding box.
callback
An event handler to be raised when items are found.
)
Remarks: Do not modify the tree while a Search() is in progress. Doing so can have unintended consequences, including corruption and crashes.If you need to modify the tree, collect the results during the search and modify the tree once the search is completed.
true if entire tree was searched. It is possible no results were found.

Search

#ExampleSince v5.0
Searches for items in a sphere.
public bool Search(
sphere,
bounds used for searching.
callback,
An event handler to be raised when items are found.
tag
State to be passed inside the RTreeEventArgs Tag property.
)
Remarks: Do not modify the tree while a Search() is in progress. Doing so can have unintended consequences, including corruption and crashes.If you need to modify the tree, collect the results during the search and modify the tree once the search is completed.
true if entire tree was searched. It is possible no results were found.

Search

#Since v5.0
Searches for items in a sphere.
public bool Search(
sphere,
bounds used for searching.
callback
An event handler to be raised when items are found.
)
Remarks: Do not modify the tree while a Search() is in progress. Doing so can have unintended consequences, including corruption and crashes.If you need to modify the tree, collect the results during the search and modify the tree once the search is completed.
true if entire tree was searched. It is possible no results were found.

SearchOverlaps

#Since v9.0
Searches for pairs of bounding boxes that overlap.
public bool SearchOverlaps(
tolerance,
bounds used for searching.
callback,
An event handler to be raised when items are found.
tag
State to be passed inside the RTreeEventArgs Tag property.
)
Remarks: Do not modify the tree while a Search() is in progress. Doing so can have unintended consequences, including corruption and crashes.If you need to modify the tree, collect the results during the search and modify the tree once the search is completed.
true if entire tree was searched. It is possible no results were found.

SearchOverlaps

#Since v5.0
Searches two R-trees for all pairs elements whose bounding boxes overlap.
public static bool SearchOverlaps(
treeA,
A first tree.
treeB,
A second tree.
tolerance,
If the distance between a pair of bounding boxes is less than tolerance, then callback is called.
callback
A callback event handler.
)
Remarks: Do not modify the tree while a Search() is in progress. Doing so can have unintended consequences, including corruption and crashes.If you need to modify the tree, collect the results during the search and modify the tree once the search is completed.
true if entire tree was searched. It is possible no results were found.