SpatialTree<T>
ReferencesProvides a spatial lookup tree for 3d point-like data. This class uses an adaptive octree-subdivision algorithm. If you're dealing with n-dimensional where n != 3, then you can use the SampleSet class in the Grasshopper2.Geometry.Clustering namespace.
Type parameters:
| T | Type of data to encapsulate. |
Constructors
SpatialTree
#Construct a new empty octree.
Properties
Indexers
Methods
Bounds
#Gets the bounding box for a collection of indexed items.
Parameters:
| indices (IEnumerable<int>) | Indices to include. |
Returns: Bounding box.
BuildTree
#public void BuildTree()
Ensure the tree has been constructed.
Remarks: This method locks, so check to see whether _root is null as a lightweight test.
Clear
#public void Clear()
Remove all items from the tree. Although why you would want to do this instead of just creating just a new spatial tree is unclear.
Difference
#Compute the difference along the x, y and z axes between two items.
Distance
#Compute the distance between two instances.
Parameters:
| a (T) | First instance. |
| b (T) | Second instance. |
Returns: Distance between a and b.
Draw
#Draw all leaf nodes as box corners.
Parameters:
| pipeline (DisplayPipeline) | |
| viewport (RhinoViewport) |
FindAbovePlane
#Find all items above a plane.
Parameters:
| slice (InfinitePlane) | Plane slice. |
Returns: An array of item indices.
FindCustom
#public int[] FindCustom(Func<OrthogonalBox, TreeSearchInstruction> regionDelegate, Func<int, Locus, bool> locusDelegate)
Perform a custom search.
Parameters:
| regionDelegate (Func<OrthogonalBox, TreeSearchInstruction>) | Delegate used for accepting/rejecting node regions. |
| locusDelegate (Func<int, Locus, bool>) | Delegate used for accepting/rejecting individual items. |
Returns: Array of all indices that were found using the search delegates.
FindInBox
#Find all items within a box.
Parameters:
| box (OrthogonalBox) | Box region. |
Returns: An array of item indices.
FindInSphere
#Find all items within a sphere.
Parameters:
| sphere (SphericalBall) | Sphere region. |
Returns: An array of item indices.
ForgetAbout
#Remove an item from the spatial lookup caches. This will prevent the item from being found using a Near or Far search, but it will not remove the item from this collection or affect the indices of other items.
Parameters:
| index (int) |
FurthestItem
#Find the nearest item to a search point.
FurthestItem
#Find the nearest item to a search point.
Parameters:
| locus (Locus) | Start of search. |
Returns: Integer of nearest item or -1 if no such item could be found.
FurthestItems
#Find the nearest items to a search point.
FurthestItems
#Find the nearest items to a search point.
NearestItem
#Find the nearest item to a search line.
Parameters:
| line (LinearSegment) | Line of search. |
| minSearchRadius (double) | Minimum search distance. |
| maxSearchRadius (double) | Maximum search distance. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItem
#Find the nearest item to a search line.
Parameters:
| line (LinearSegment) | Line of search. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItem
#Find the nearest item to a search point.
NearestItem
#Find the nearest item to a search point.
Parameters:
| locus (Locus) | Start of search. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItem
#public int NearestItem(RegionDistance regionDelegate, LocusDistance locusDelegate, double minSearchRadius, double maxSearchRadius)
Find the nearest item using a custom distance metric.
Parameters:
| regionDelegate (RegionDistance) | Delegate used for region distance metrics. |
| locusDelegate (LocusDistance) | Delegate used for locus distance metrics. |
| minSearchRadius (double) | Minimum search distance. |
| maxSearchRadius (double) | Maximum search distance. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItem
#Find the nearest item using a custom distance metric.
Parameters:
| regionDelegate (RegionDistance) | Delegate used for region distance metrics. |
| locusDelegate (LocusDistance) | Delegate used for locus distance metrics. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItem
#Find the nearest item to a search locus.
NearestItem
#Find the nearest item to a search locus.
Parameters:
| locus (T) | Start of search. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItems
#public int[] NearestItems(LinearSegment line, int count, double minSearchRadius, double maxSearchRadius)
Find the nearest item to a search line.
Parameters:
| line (LinearSegment) | Line of search. |
| count (int) | Number of items to include. |
| minSearchRadius (double) | Minimum search distance. |
| maxSearchRadius (double) | Maximum search distance. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItems
#Find the nearest item to a search line.
Parameters:
| line (LinearSegment) | Line of search. |
| count (int) | Number of items to include. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItems
#Find the nearest items to a search point.
NearestItems
#Find the nearest items to a search point.
NearestItems
#public int[] NearestItems(RegionDistance regionDelegate, LocusDistance locusDelegate, int count, double minSearchRadius, double maxSearchRadius)
Find the nearest items using a custom distance metric.
Parameters:
| regionDelegate (RegionDistance) | Delegate used for region distance metrics. |
| locusDelegate (LocusDistance) | Delegate used for locus distance metrics. |
| count (int) | Number of items to include. |
| minSearchRadius (double) | Minimum search distance. |
| maxSearchRadius (double) | Maximum search distance. |
Returns: Integer of nearest item or -1 if no such item could be found.
NearestItems
#Find the nearest items using a custom distance metric.
Parameters:
| regionDelegate (RegionDistance) | Delegate used for region distance metrics. |
| locusDelegate (LocusDistance) | Delegate used for locus distance metrics. |
| count (int) | Number of items to include. |
Returns: Integer of nearest item or -1 if no such item could be found.
Optimize
#public void Optimize()
Optimize this tree. Optimized trees will have faster searches, but they become immutable. Any changes made to an optimized tree will result in the tree being rebuilt.
Quadrance
#Compute the quadrance between two instances.
Parameters:
| a (T) | First instance. |
| b (T) | Second instance. |
Returns: Quadrance between a and b.