Node3d<T>

References
[DebuggerDisplay("C:{ChildCount}, I:{ItemCount}, {NodeIndex}")] public sealed class Node3d<T>
Basic node in a Tree3d structure. Nodes in tree structures maintain a local region and either a list of content indices or a list of up to 8 child nodes.
T

Constructors

Node3d

#
Create a new spatial tree root.
public Node3d(
converter,
Converter delegate.
region,
Bounding box for this node. The region should be big enough to contain all items you're going to insert.
limit
Node subdivision limit.
)

Node3d

#
Create a new spatial tree root.
public Node3d(
converter,
Converter delegate.
region
Bounding box for this node. The region should be big enough to contain all items you're going to insert.
)

Properties

Center

#
Gets the center of the spatial region of this node. If the node contains no children the center is always in the middle of the Region. If the node does contain child-nodes, the center may be anywhere within the region.
public Point3d Center { get; }

ChildCount

#
Gets the number of defined child nodes. Leaf nodes have no children. Root and twig nodes can have anywhere between 1 and 8 children.
public int ChildCount { get; }

ChildNode

#
Gets the child node at the given index.
public Node3d<T> ChildNode[int index] { get; }
index (int)Index of child node to retrieve. Valid indices are from 0 to 7 inclusive.

ContentAverage

#
Returns the average coordinate of all items in this node. If this node does not contain any items, Point3d.Unset is returned.
public Point3d ContentAverage { get; }

ContentBoundingBox

#
Returns the boundingbox of all items in this node. If this node does not contain any items, BoundingBox.Empty is returned.
public BoundingBox ContentBoundingBox { get; }

IndicesLocal

#
Gets the list of item indices that are contained within this node.
public List<int> IndicesLocal { get; }

IndicesRecursive

#
Gets the list of item indices that are contained within this node and any child nodes.
public List<int> IndicesRecursive { get; }

IsLeaf

#
Gets whether this node is a leaf node. Leaf nodes have no child nodes.
public bool IsLeaf { get; }

IsMutable

#
Gets whether this tree is mutable. You can only add items to mutable trees. We don't recommend removing items from unmutable trees, though that shouldn't necessarily lead to problems. Trees become unmutable after a call to ShrinkRegions(), CollapseNodes() or OptimizeTree().
public bool IsMutable { get; }

IsRoot

#
Gets whether this node is a root node. Root nodes have no parent node and depth zero.
public bool IsRoot { get; }

IsTwig

#
Gets whether this node is a twig node. Twig nodes have both parents and at least one child.
public bool IsTwig { get; }

ItemCount

#
Gets the total number of items stored directly in this node.
public int ItemCount { get; }

ItemsGlobal

#
Gets the list of all items stored inside this entire tree. Do not modify this collection unless you know what you are doing.
public List<T> ItemsGlobal { get; }

ItemsLocal

#
Gets a list of all the items stored directly in this node. This list is constructed every time you access this property, so keep it down to a minimum.
public List<T> ItemsLocal { get; }

Limit

#
Gets the subdivision limit for this tree. This limit can only be set once when you create a new tree. It is fixed forever after.
public int Limit { get; }

MemoryConsumption

#
Gets the estimated memory consumption of the (sub)tree structure. Items inside the global list are not included in this estimate.
public long MemoryConsumption { get; }

NextNode

#
Gets the logical neighbour to the right of this node. There is no spatial relationships between logical neighbours, this is purely an iteration aid.
public Node3d<T> NextNode { get; }

NodeDepth

#
Gets the recursive depth of this node. The tree root is at depth zero. The first subdivision is at depth one, and so on and so forth.
public int NodeDepth { get; }

ParentNode

#
Gets the immediate parent of this node. Root nodes have no parent.
public Node3d<T> ParentNode { get; }

Region

#
Gets the spatial region of this node.
public BoundingBox Region { get; }

RootNode

#
Gets the ultimate root node for this tree.
public Node3d<T> RootNode { get; }

WeightedSubdivision

#
Gets or sets whether subdivision is weighted based on content averages. Setting this value will only affect future subdivisions, not existing ones.
public bool WeightedSubdivision { get; set; }

Methods

Add

#
Insert another item into the tree. The item should be within the region of this node.
public void Add(
T
item
Item to insert.
)

AddRange

#
Insert a collection of items into the tree. The items should all be within the region of this node.
public void AddRange(
items
Items to add.
)

AddToRhinoDocument

#
public void AddToRhinoDocument()

ChildIndex

#
Find the child index that is associated with a given coordinate.
protected int ChildIndex()
Index of twig that would contain the point.

ChildRegion

#
Compute the region of a specific child node.
protected BoundingBox ChildRegion(
index
Index of twig to compute.
)

CollapseNodes

#
Collapse the (sub)tree rooted at this node. Collapsing happens when a node only has a single child, in which case the child usurps the position previously held by the parent. Do not collapse a (sub)tree if you still plan to add items later.
public Node3d<T> CollapseNodes()
The new root for this (sub)tree. May well be an instance of this node if it cannot be collapsed.

FurthestItem

#
Find the furtest item.
public Index3d<T> FurthestItem(
x,
x coordinate to search from.
y,
y coordinate to search from.
z,
z coordinate to search from.
minimumDistance,
Minimum distance for furtest item. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for furtest item. Items further than maximumDistance will be ignored.
)
The index of the furtest item or null if no furtest item could be found.

FurthestItem

#
Find the furtest item.
public Index3d<T> FurthestItem(
x,
x coordinate to search from.
y,
y coordinate to search from.
z
z coordinate to search from.
)
The index of the furtest item or null if no furtest item could be found.

FurthestItem

#
Find the furtest item.
public Index3d<T> FurthestItem(
locus,
Location to search from.
minimumDistance,
Minimum distance for furtest item. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for furtest item. Items further than maximumDistance will be ignored.
)
The index of the furtest item or null if no furtest item could be found.

FurthestItem

#
Find the furtest item.
public Index3d<T> FurthestItem(
locus
Location to search from.
)
The index of the furtest item or null if no furtest item could be found.

FurthestItem

#
Find the furtest item.
public Index3d<T> FurthestItem(
T
locus,
Location to search from.
minimumDistance,
Minimum distance for furtest item. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for furtest item. Items further than maximumDistance will be ignored.
)
The index of the furtest item or null if no furtest item could be found.

FurthestItem

#
Find the furtest item.
public Index3d<T> FurthestItem(
T
locus
Location to search from.
)
The index of the furtest item or null if no furtest item could be found.

InsertIndexRecursive

#
Adust this node and all child nodes for the insertion of a single index.
protected void InsertIndexRecursive(
index
Index to insert.
)

NearestItem

#
Find the nearest item.
public Index3d<T> NearestItem(
x,
x coordinate to search from.
y,
y coordinate to search from.
z,
z coordinate to search from.
minimumDistance,
Minimum distance for nearest item. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for nearest item. Items further than maximumDistance will be ignored.
)
The index of the nearest item or null if no nearest item could be found.

NearestItem

#
Find the nearest item using custom validation criteria.
public Index3d<T> NearestItem(
x,
x coordinate to search from.
y,
y coordinate to search from.
z,
z coordinate to search from.
validationDelegate
Item validation delegate.
)
The index of the nearest item or null if no nearest item could be found.

NearestItem

#
Find the nearest item.
public Index3d<T> NearestItem(
x,
x coordinate to search from.
y,
y coordinate to search from.
z
z coordinate to search from.
)
The index of the nearest item or null if no nearest item could be found.

NearestItem

#
Find the nearest item.
public Index3d<T> NearestItem(
locus,
Location to search from.
minimumDistance,
Minimum distance for nearest item. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for nearest item. Items further than maximumDistance will be ignored.
)
The index of the nearest item or null if no nearest item could be found.

NearestItem

#
Find the nearest item.
public Index3d<T> NearestItem(
locus
Location to search from.
)
The index of the nearest item or null if no nearest item could be found.

NearestItem

#
Find the nearest item.
public Index3d<T> NearestItem(
T
locus,
Location to search from.
minimumDistance,
Minimum distance for nearest item. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for nearest item. Items further than maximumDistance will be ignored.
)
The index of the nearest item or null if no nearest item could be found.

NearestItem

#
Find the nearest item.
public Index3d<T> NearestItem(
T
locus
Location to search from.
)
The index of the nearest item or null if no nearest item could be found.

NearestItems

#
Find the N nearest items.
public List<Index3d<T>> NearestItems(
x,
x coordinate to search from.
y,
y coordinate to search from.
z,
z coordinate to search from.
groupSize,
Number of nearest items to return.
minimumDistance,
Minimum distance for nearest items. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for nearest items. Items further than maximumDistance will be ignored.
)
A list of nearest items, sorted from nearest to furthest.

NearestItems

#
Find the N nearest items.
public List<Index3d<T>> NearestItems(
x,
x coordinate to search from.
y,
y coordinate to search from.
z,
z coordinate to search from.
groupSize
Number of nearest items to return.
)
A list of nearest items, sorted from nearest to furthest.

NearestItems

#
Find the N nearest items.
public List<Index3d<T>> NearestItems(
T
locus,
Search locus.
groupSize,
Number of nearest items to return.
minimumDistance,
Minimum distance for nearest items. Items closer than minimumDistance will be ignored.
maximumDistance
Maximum distance for nearest items. Items further than maximumDistance will be ignored.
)
A list of nearest items, sorted from nearest to furthest.

NearestItems

#
Find the N nearest items.
public List<Index3d<T>> NearestItems(
T
locus,
Search locus.
groupSize
Number of nearest items to return.
)
A list of nearest items, sorted from nearest to furthest.

OptimizeTree

#
Optimize this tree for fast searches. Do not call this method if you still plan to add items in the future. You can no longer modify this tree once it has been optimized.
public Node3d<T> OptimizeTree()
The new root of the optimized tree. If the root could not be optimized an instance of this node will be returned.

Rebuild

#
Aggregate all points in this node and re-build it.
protected void Rebuild()

Remove

#
Remove the item with the given index from the entire tree. It doesn't matter on which node you call this function, it is a tree-wide operation.
public void Remove(
index
Index of item to remove.
)

Remove

#
Remove the item with the given index from the entire tree. It doesn't matter on which node you call this function, it is a tree-wide operation.
public void Remove(
index
Index of item to remove.
)

RemoveIndexRecursive

#
Adjust this node and all child nodes to cater for the removal of a single index. If a node contains the specified index, that item will be removed entirely.
protected void RemoveIndexRecursive(
index
Index to remove.
)

ShrinkRegions

#
Shrink the region for this node and all child nodes. Do not use this method if you intend to add more items later as it creates spatial gaps in the tree structure. You can shrink nodes if you're done adding items and want to start searching the tree.
public void ShrinkRegions()

SubTree

#
Gets an iterator for all nodes in this (sub)tree.
public IEnumerator<Node3d<T>> SubTree(
omitStructuralNodes
If true, nodes that contain other nodes will be skipped. Only nodes containing items will be included.
)

TrimExcess

#
Trim the excess space on all index lists. You can call this method to reduce memory usage. It will not modify the tree in any functional way.
public void TrimExcess()