mymesh.tree.QuadtreeNode#

class mymesh.tree.QuadtreeNode(centroid, size, parent=None, data=None, level=0, state='unknown')[source]#

Bases: TreeNode

The QuadtreeNode is the basic unit of the quadtree 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:
  • parent (tree.QuadtreeNode, optional) – The quadtree node that contains this node, by default None

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

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

  • centroid (array_like) – Location of the center of the quadtree node

  • size (float) – Side length of the cube associated with the quadtree node

  • limits (list) – bounds of the quadtree node

  • vertices (np.ndarray) – Coordinates of the vertices of the quadtree node

Properties#

Methods#

QuadtreeNode.ContainsEdges(edges)

Identify which of a set of a edges is contained in the node

QuadtreeNode.ContainsPts(points)

Identify which of a set of a points is contained in the node

QuadtreeNode.PointInNode(point[, inclusive])

Check if a point is within the bounds of the current node.

QuadtreeNode.PointsInNode(points[, inclusive])

Check if a set of points is within the bounds of the current node.

QuadtreeNode.clearData([clearChildren])

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

QuadtreeNode.getLevel(level)

Get all child nodes at a particular octree level

QuadtreeNode.getLimits()

Get the spatial bounds of the current quadtree node.

QuadtreeNode.getMaxDepth()

Get the maximum depth of the octree.

QuadtreeNode.getVertices()

Get the coordinates of the 4 vertices of the square that correspond to the quadtree node.

QuadtreeNode.hasChildren()

Check if the node has any child nodes

QuadtreeNode.makeChildren([childstate])

Initialize child nodes for the current node

QuadtreeNode.makeChildrenEdges(edges[, ...])

Make child nodes based on edges.

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

Make child nodes based on points.

QuadtreeNode.node_distance(x)

Calculate the nearest distance between a point and a quadtree node.

QuadtreeNode.prune(level)

QuadtreeNode.query_knn(x[, k])

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