public interface ITree
Base level interface for Grasshopper data trees.

Properties

AllItems

#
IEnumerable<object> AllItems { get; }
Enumerate over all items in this tree.

AllPears

#
IEnumerable<IPear> AllPears { get; }
Enumerate over all item/meta data pears in this tree.

AllTwigs

#
IEnumerable<ITwig> AllTwigs { get; }
Enumerate over all twigs in this tree.

CommonMetaData

#
MetaData CommonMetaData { get; }
Gets the non-conflicting meta data inside this tree.

Description

#
string Description { get; }
Gets a string describing the topology of this tree.

ItemCount

#
int ItemCount { get; }
Gets the total number of non-null items in this tree.

Items

#
IItemAccessor Items { get; }
Access the items in this tree.

LeafCount

#
int LeafCount { get; }
Gets the number of leaf items in this tree (this includes all items and all nulls).

MetaCount

#
int MetaCount { get; }
Gets the number of meta data entries.

NonNullItems

#
IEnumerable<object> NonNullItems { get; }
Enumerate over all non-null items in this tree.

NonNullPears

#
IEnumerable<IPear> NonNullPears { get; }
Enumerate over all non-null item/meta data pears in this tree.

NullCount

#
int NullCount { get; }
Gets the total number of null items in this tree.

PathCount

#
int PathCount { get; }
Gets the number of paths (and thus twigs) in this tree.

Paths

#
Paths Paths { get; }
Access the paths of this tree.

Pears

#
IPearAccessor Pears { get; }
Access the pears in this tree.

Twigs

#
ITwigAccessor Twigs { get; }
Access the twigs in this tree.

Type

#
Type Type { get; }
Gets the type of the data stored in this tree.

TypeAssistant

#
ITypeAssistant TypeAssistant { get; }
Gets the type assistant (if any) associated with the type constraint. More derived types that are stored in this tree may have more specific type assistants.

TypeFlavour

#
TypeFlavour TypeFlavour { get; }
Gets some information about the generic type parameter of this tree.

Methods

ConvertItems<Q>

#
Tree<Q> ConvertItems<Q>(Func<object, Q> replaceItem, Pear<Q> nullReplacement, CancellationToken token)
Modify all items in this tree.
replaceItem (Func<object, Q>)Replacement method for non-null items.
nullReplacement (Pear<Q>)Replacement pear for null values. If not provided, nulls are simply persisted.
token (CancellationToken)Cancellation token.

ConvertPears

#
ITree ConvertPears(Func<IPear, IPear> replacePear, IPear nullReplacement, CancellationToken token)
Modify all pears in this tree.
replacePear (Func<IPear, IPear>)Replacement method for non-null pears.
nullReplacement (IPear)Replacement method for nulls. If not provided, nulls are simply persisted.
token (CancellationToken)Cancellation token.

ConvertPears<Q>

#
Tree<Q> ConvertPears<Q>(Func<IPear, Pear<Q>> replacePear, Pear<Q> nullReplacement, CancellationToken token)
Modify all pears in this tree.
replacePear (Func<IPear, Pear<Q>>)Replacement method for non-null items.
nullReplacement (Pear<Q>)Replacement method for nulls. If not provided, nulls are simply persisted.
token (CancellationToken)Cancellation token.

Filter

#
ITree Filter(IEnumerable<SiteRule> rules)
Apply a collection of rules to all the twigs and all the items in this tree.
rules (IEnumerable<SiteRule>)Rules to apply.
A new tree with only the twigs and items that were valid under the given rules.

Filter

#
ITree Filter(params SiteRule[] rules)
Apply one or more rules to all the twigs and all the items in this tree.
rules (params SiteRule[])Rules to apply.
A new tree with only the twigs and items that were valid under the given rule.

Flatten

#
ITree Flatten()
Flatten the entire tree.
Modified tree.

Flatten

#
ITree Flatten(Path path)
Flatten the entire tree.
path (Path)Path to flatten into.
Modified tree.

Flip

#
ITree Flip(int elementIndex, IndexModifier indexing)
Flip the tree by exchanging the twig indices of all items with one of the path elements.
elementIndex (int)Path element to flip.
indexing (IndexModifier)Indexing to apply to the indices.
Flipped tree.

GetCoverage

#
object GetCoverage(Coverage coverage)
Gets the part of a tree that is implied by a specific coverage.
coverage (Coverage)Coverage.
Part of the tree identified by the coverage, or null if the coverage doesn't intersect with the tree.

Graft

#
ITree Graft()
Perform a graft operation on the entire tree.
Modified tree.

IsCoincidentWith

#
bool IsCoincidentWith(Coverage coverage)
Test whether a given coverage coincides with this tree.
coverage (Coverage)Coverage to test.
True if the coverage is valid.

IsCoincidentWith

#
bool IsCoincidentWith(Site site)
Tests whether a given site (path+twig index) is part of this tree.
site (Site)Tree site.
True if the site exists within the tree.

NullAt

#
bool NullAt(int twigIndex, int itemIndex)
Gets whether a specific item is null or not.
twigIndex (int)Index of twig.
itemIndex (int)Index of item.
True if item at the given site is null.

NullAt

#
bool NullAt(Path path, int itemIndex)
Gets whether a specific item is null or not.
path (Path)Path of item twig.
itemIndex (int)Index within twig.
True if item at the given site is null.

ReplacePath

#
ITree ReplacePath(Path find, Path replace)
Replace one path with another. If the replace path already exists within the tree, the items will be appended to the existing twig.
find (Path)Path to find.
replace (Path)Path to replace.
Modified tree.

Similarity

#
TreeSimilarity Similarity(ITree tree)
Compares two data trees for similarity.
tree (ITree)Data tree to compare to.
A TreeSimilarity type. This method never returns the PathsAndListsAndItems value.

Split

#
void Split(IEnumerable<SiteRule> rules, out ITree positive, out ITree negative)
Split this tree into a positive and a negative state by applying a collection of rules.
rules (IEnumerable<SiteRule>)Rules to apply.
positive (out ITree)Tree containing all the twigs and items that are valid under the given rules.
negative (out ITree)Tree containing all the twigs and items that are invalid under the given rules.

Split

#
void Split(SiteRule rule, out ITree positive, out ITree negative)
Split this tree into a positive and a negative state by applying a specific rule.
rule (SiteRule)Rule to apply.
positive (out ITree)Tree containing all the twigs and items that are valid under the given rule.
negative (out ITree)Tree containing all the twigs and items that are invalid under the given rule.

ToString

#
string ToString(TwigFormatStyle style)
Format this tree using a specific formatting template.
style (TwigFormatStyle)Formatting style.
String describing the tree.

TryConvert<TQ>

#
Tree<TQ> TryConvert<TQ>()
Try and convert this tree into a tree of a specific type.
Tree of type TQ or null if no conversion could be found.

TryConvert<TQ>

#
Tree<TQ> TryConvert<TQ>(CancellationToken token, ConversionRecord record)
Try and convert this tree into a tree of a specific type.
token (CancellationToken)Cancellation token.
record (ConversionRecord)If not null, conversion messages will be added to this record.
Tree of type TQ or null if no conversion could be found.

TryConvert<TQ>

#
Tree<TQ> TryConvert<TQ>(CancellationToken token)
Try and convert this tree into a tree of a specific type.
token (CancellationToken)Cancellation token.
Tree of type TQ or null if no conversion could be found.

WithIncrementalPaths

#
ITree WithIncrementalPaths()
Simplify the numbering of paths by starting at zero and incrementing by one for each element in the sequence.

WithMetaData

#
ITree WithMetaData(ITree source, MergeBehaviour mergeBehaviour)
Merge all data from another tree.
source (ITree)Source of meta data. Source.Count must equal the local ImageCount and any twig in source which contains meta data must have the same length as the corresponding twig in this tree.
mergeBehaviour (MergeBehaviour)Custom data merge behaviour.

WithMetaData

#
ITree WithMetaData(MetaData primary, MetaData secondary)
Assign meta data to all items in this tree.
primary (MetaData)Primary data (assign no matter what). May be null.
secondary (MetaData)Secondary data (assign only if doesn't conflict). May be null.
Potentially modified tree.

WithoutEmptyTwigs

#
ITree WithoutEmptyTwigs()
Remove all twigs that contain no items from this tree.
Modified tree.

WithoutMetaData

#
ITree WithoutMetaData()
Clear all meta data from all twigs, but leave items intact.

WithoutNullItems

#
ITree WithoutNullItems()
Remove all null items from all twigs.
Modified tree.

WithoutPaths

#
ITree WithoutPaths(IEnumerable<Path> paths)
Remove all specified paths and corresponding twigs.
paths (IEnumerable<Path>)Paths to remove.
Modified tree.

WithoutPaths

#
ITree WithoutPaths(params Path[] paths)
Remove the specified paths and corresponding twigs from this tree.
paths (params Path[])Paths to remove.
Modified tree.

WithoutSites

#
ITree WithoutSites(IEnumerable<Site> sites)
Remove all specified sites from the tree.
sites (IEnumerable<Site>)Sites to remove.
Modified tree

WithoutSites

#
ITree WithoutSites(params Site[] sites)
Remove the specified sites from this tree.
sites (params Site[])Loci to remove.
Modified tree.

WithPathPrefix

#
ITree WithPathPrefix(int element)
Prepend an integer to all paths in the tree.
element (int)Element to prepend.
Modified tree.

WithPathPrefix

#
ITree WithPathPrefix(Path path)
Prepend an entire path to all existing paths in the tree.
path (Path)Path to prepend.
Modified tree.

WithPaths

#
ITree WithPaths(Paths source)
Create a new tree with different paths but the same twigs.
source (Paths)Paths to adopt.
Modified tree.

WithPathSuffix

#
ITree WithPathSuffix(int element)
Append an integer to all paths in the tree.
element (int)Element to append.
Modified tree.

WithPathSuffix

#
ITree WithPathSuffix(Path path)
Append an entire path to all existing paths in the tree.
path (Path)Path to append.
Modified tree.

WithRandomisedTwigs

#
ITree WithRandomisedTwigs()
Randomise the items within the twigs of this tree.

WithRandomisedTwigs

#
ITree WithRandomisedTwigs(Random random)
Randomise the items within the twigs of this tree.
random (Random)

WithRenumberedPaths

#
ITree WithRenumberedPaths()
Renumber all paths in this tree in ascending order.
Modified tree.

WithRenumberedPaths

#
ITree WithRenumberedPaths(int start)
Renumber all paths in this tree in ascending order.
start (int)Starting number for first path.
Modified tree.

WithRenumberedPaths

#
ITree WithRenumberedPaths(Path path, int index)
Renumber all paths in this tree in ascending order.
path (Path)Path layout to use for renumbering.
index (int)Element integer of path to increment.
Modified tree.

WithReversedTwigs

#
ITree WithReversedTwigs()
Reverse the order of all the items in the twigs of this tree.
Reversed tree.

WithSimplifiedPaths

#
ITree WithSimplifiedPaths(PathAlignment options)
Perform a simplify operation on this tree.
options (PathAlignment)Simplify options
Modified tree.

WithSite

#
ITree WithSite(Site site, IPear pear)
Replace a single pear in this tree.
site (Site)Location of pear.
pear (IPear)New pear. If the pear is of an incompatible type, an exception will be thrown.
Modified tree, or original tree if the site does not point to a valid location within the tree.

WithSortedTwigs

#
ITree WithSortedTwigs()
Sort all twigs using the default comparer.
Tree with sorted twigs.

WithTopology

#
ITree WithTopology(ITree source)
Copy the topology of another tree while keeping the data from this tree. For a successful topology copy, the source and the target trees must have the same number of items.
source (ITree)Source tree to copy topology from.
modified tree.

WithTrimmedPaths

#
ITree WithTrimmedPaths()
Trim the tree by removing the last element in each path and merging twigs together.
Modified tree.

WithTrimmedPaths

#
ITree WithTrimmedPaths(int count)
Trim the tree by removing the last N elements in each path and merging twigs together.
count (int)Number of elements to collapse.
Modified tree.