mymesh.tree.OctreeNode#

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

Bases: TreeNode

The OctreeNode is the basic unit of the octree 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.OctreeNode, optional) – The octree node that contains this node, by default None

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

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

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

  • limits (list) – bounds of the octree node

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

Properties#

Methods#

OctreeNode.ContainsBoxes(boxes)

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

OctreeNode.ContainsPts(points)

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

OctreeNode.ContainsTris(tris[, TriNormals])

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

OctreeNode.PointInNode(point[, inclusive])

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

OctreeNode.PointsInNode(points[, inclusive])

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

OctreeNode.clearData([clearChildren])

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

OctreeNode.getLevel(level)

Get all child nodes at a particular octree level

OctreeNode.getLimits()

Get the spatial bounds of the current octree node.

OctreeNode.getMaxDepth()

Get the maximum depth of the octree.

OctreeNode.getVertices()

Get the coordinates of the 8 vertices of the cube that correspond to the octree node.

OctreeNode.hasChildren()

Check if the node has any child nodes

OctreeNode.makeChildren([childstate])

Initialize child nodes for the current node

OctreeNode.makeChildrenBoxes(boxes[, ...])

Make child nodes based on boxes.

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

Make child nodes based on points.

OctreeNode.makeChildrenTris(tris, TriNormals)

Make child nodes based on triangles.

OctreeNode.node_distance(x)

Calculate the nearest distance between a point and an octree node.

OctreeNode.prune(level)

OctreeNode.query_knn(x[, k])

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