KDNode.split

giant.ray_tracer.kdtree:

KDNode.split(self, force=False, flip=False, print_progress=True)

This method is used to “grow” the tree. It takes the geometry primitives contained in this node, and distributes them to the left and right using the median value of the center of each facet along the axis with the widest separation.

Normally this method won’t split once there are less than 10 geometry primitives contained in the node. This can be over ridden by setting the force flag to True, which will split until there is only 1 geometry primitive in the node.

The results are stored in the left and right attributes of the current node as well as returned as a tuple. The local surface is also removed from this node since the primitives are distributed to the child nodes.

Typically a user won’t directly use this method and instead will use KDTree.build().

Parameters:
  • force (bool) – A flag specifying whether to force splitting even past once there are less than 10 facets in the node

  • flip (bool) – A flag specifying whether to flip which side of the split gets the “equals” in the comparison. If True then the right side gets the equals. If False then the left side.

  • print_progress (bool) – A flag specifying whether to print the progress of the splitting as we go. This prints a a lot to the screen but at least lets you know that things are not stuck somewhere

Returns:

A tuple of the new left and right nodes (in order) or a tuple of None, None if we have already split as far as possible

Return type:

Union[Tuple[KDNode, KDNode], Tuple[None, None]]