mymesh.tree.TreeNode#
- class mymesh.tree.TreeNode(parent=None, data=None, level=0, state='unknown')[source]#
Bases:
objectThe TreeNode is the base class for several different spatial tree structures. The structure consists of a series of nodes that reference their parent and child nodes, allowing for traversal of the tree structure.
- Parameters:
parent (tree.TreeNode, optional) – The tree node that contains this node, by default None
data (list or dict, optional) – Data associated with the tree node. The type of data depends on the how the tree was created, by default None.
level (int, optional) – Depth within the tree structure, by default 0. The root node is at level 0, the root’s children are at level 1, etc.
state (str, optional) –
Specifies whether the node’s place in the tree structure, by default ‘unknown’.
Possible states are:
’root’: This node is the root of the tree
’branch’: This is node is an intermediate node between the root and leaves
’leaf’: This is node is a terminal end and has no children.
’empty’: No data is contained within this node, and it has no children
’unknown’: State hasn’t been specified.
Properties#
Methods#
TreeNode.clearData([clearChildren])Reset the data attribute for this node, and optionally all children
TreeNode.getLevel(level)Get all child nodes at a particular octree level
Get the maximum depth of the octree.
Check if the node has any child nodes
TreeNode.prune(level)