mymesh.tree.KDtreeNode#

class mymesh.tree.KDtreeNode(location, axis=0, parent=None, data=None, level=0, state='unknown', K=None)[source]#

Bases: TreeNode

The KDtreeNode is the basic unit of the KD-tree data structure. The structure consists of a series of nodes that reference their parent and child nodes, allowing for traversal of the tree structure.

Parameters:
  • location (array_like) – Location of the node. This is only a single coordinate defining the location of the hyperplane along the axis.

  • axis (int, optional) – Index of the axis along which the data will be split (0=x, 1=y,…). By default, 0.

  • parent (tree.KDtreeNode, optional) – The KDtree node that contains this node, by default None

  • data (list or dict, optional) – Data associated with the KDtree node. The type of data depends on the how the KDtree 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 octree

    • ’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#

KDtreeNode.clearData([clearChildren])

Reset the data attribute for this node, and optionally all children

KDtreeNode.getLevel(level)

Get all child nodes at a particular octree level

KDtreeNode.getMaxDepth()

Get the maximum depth of the octree.

KDtreeNode.hasChildren()

Check if the node has any child nodes

KDtreeNode.makeChildrenPts(points[, ...])

Initialize child nodes for the current node

KDtreeNode.node_distance(x)

Calculate the nearest distance between a point and the location of the splitting plane of the current node.

KDtreeNode.prune(level)

KDtreeNode.query_knn(x[, k])

Find the k-nearest neighbor points in the tree to a point.