RTree
ReferencesRepresents 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
Finalizer
~RTree
#~RTree()
Passively reclaims unmanaged resources when the class user did not explicitly call Dispose().
Properties
Methods
Constructs a new tree with an element for each point cloud point.
Parameters:
| points (IEnumerable<Point3d>) | Points. |
Returns: A new tree, or null on error.
Constructs a new tree with an element for each face in the mesh. The element id is set to the index of the face.
Parameters:
| mesh (Mesh) | A mesh. |
Returns: A new tree, or null on error.
Constructs a new tree with an element for each point cloud point.
Parameters:
| cloud (PointCloud) | A point cloud. |
Returns: A new tree, or null on error.
public void Dispose()
Actively reclaims unmanaged resources that this instance uses.
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.
Parameters:
| disposing (bool) | true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer. |
Inserts an element into the tree.
Parameters:
| box (BoundingBox) | A bounding box. |
| elementId (int) | A number. |
Returns: true if element was successfully inserted.
Inserts an element into the tree.
Parameters:
| box (BoundingBox) | A bounding box. |
| elementId (nint) | A pointer. |
Returns: true if element was successfully inserted.
Inserts an element into the tree.
Inserts an element into the tree.
Inserts an element into the tree.
Inserts an element into the tree.
public static IEnumerable<int[]> Point3dClosestPoints(IEnumerable<Point3d> hayPoints, IEnumerable<Point3d> needlePts, double limitDistance)
Finds the point in a list of 3D points that is closest to a test point.
Parameters:
| hayPoints (IEnumerable<Point3d>) | A series of points. |
| needlePts (IEnumerable<Point3d>) | Points to search for. |
| limitDistance (double) | The maximum allowed distance. |
Returns: An enumerable of arrays of indices; each array contains the indices for each of the needlePts.
public static IEnumerable<int[]> Point3dKNeighbors(IEnumerable<Point3d> hayPoints, IEnumerable<Point3d> needlePts, int amount)
Finds a certain amount of points in a list of 3D points that are the k-closest to a test point.
Parameters:
| hayPoints (IEnumerable<Point3d>) | A series of points. |
| needlePts (IEnumerable<Point3d>) | Points to search for. |
| amount (int) | The required amount of closest neighbors to find. |
Returns: An enumerable of arrays of indices; each array contains the indices for each of the needlePts.
public static IEnumerable<int[]> PointCloudClosestPoints(PointCloud pointcloud, IEnumerable<Point3d> needlePts, double limitDistance)
Finds the point in a list of 3D points that is closest to a test point.
Parameters:
| pointcloud (PointCloud) | A point cloud to be searched. |
| needlePts (IEnumerable<Point3d>) | Points to search for. |
| limitDistance (double) | The maximum allowed distance. |
Returns: An enumerable of arrays of indices; each array contains the indices for each of the needlePts.
public static IEnumerable<int[]> PointCloudKNeighbors(PointCloud pointcloud, IEnumerable<Point3d> needlePts, int amount)
Finds a certain amount of points in a list of 3D points that are the k-closest to a test point.
Parameters:
| pointcloud (PointCloud) | A point cloud to be searched. |
| needlePts (IEnumerable<Point3d>) | Points to search for. |
| amount (int) | The required amount of closest neighbors to find. |
Returns: An enumerable of arrays of indices; each array contains the indices for each of the needlePts.
Removes an element from the tree.
Parameters:
| box (BoundingBox) | A bounding box. |
| elementId (int) | A number. |
Returns: true if element was successfully removed.
Removes an element from the tree.
Parameters:
| box (BoundingBox) | A bounding box. |
| elementId (nint) | A pointer. |
Returns: true if element was successfully removed.
Removes an element from the tree.
Removes an element from the tree.
Removes an element from the tree.
Searches for items in a bounding box.
The bounding box can be singular and contain exactly one single point.
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.
Parameters:
| box (BoundingBox) | A bounding box. |
| callback (EventHandler<RTreeEventArgs>) | An event handler to be raised when items are found. |
| tag (object) | State to be passed inside the RTreeEventArgs Tag property. |
Returns: true if entire tree was searched. It is possible no results were found.
Searches for items in a bounding box.
The bounding box can be singular and contain exactly one single point.
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.
Parameters:
| box (BoundingBox) | A bounding box. |
| callback (EventHandler<RTreeEventArgs>) | An event handler to be raised when items are found. |
Returns: true if entire tree was searched. It is possible no results were found.
Searches for items in a sphere.
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.
Parameters:
| sphere (Sphere) | bounds used for searching. |
| callback (EventHandler<RTreeEventArgs>) | An event handler to be raised when items are found. |
| tag (object) | State to be passed inside the RTreeEventArgs Tag property. |
Returns: true if entire tree was searched. It is possible no results were found.
Searches for items in a sphere.
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.
Parameters:
| sphere (Sphere) | bounds used for searching. |
| callback (EventHandler<RTreeEventArgs>) | An event handler to be raised when items are found. |
Returns: true if entire tree was searched. It is possible no results were found.
Searches for pairs of bounding boxes that overlap.
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.
Parameters:
| tolerance (double) | bounds used for searching. |
| callback (EventHandler<RTreeEventArgs>) | An event handler to be raised when items are found. |
| tag (object) | State to be passed inside the RTreeEventArgs Tag property. |
Returns: true if entire tree was searched. It is possible no results were found.
public static bool SearchOverlaps(RTree treeA, RTree treeB, double tolerance, EventHandler<RTreeEventArgs> callback)
Searches two R-trees for all pairs elements whose bounding boxes overlap.
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.
Parameters:
| treeA (RTree) | A first tree. |
| treeB (RTree) | A second tree. |
| tolerance (double) | If the distance between a pair of bounding boxes is less than tolerance, then callback is called. |
| callback (EventHandler<RTreeEventArgs>) | A callback event handler. |
Returns: true if entire tree was searched. It is possible no results were found.