Skip to content

Commit

Permalink
add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
true-real-michael committed Nov 22, 2023
1 parent 7205ae4 commit 55a1004
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions octreelib/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
GridVisualizationType,
VisualizationConfig,
)
from octreelib.internal.typing import T
from octreelib.internal.point import PointCloud
from octreelib.internal.voxel import Voxel, VoxelBase
from octreelib.octree import Octree, OctreeConfig

__all__ = ["Grid", "GridConfig"]

Expand Down
5 changes: 4 additions & 1 deletion octreelib/octree/octree.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,21 @@ def insert_points(self, points: PointCloud):
:param points: Points to insert.
"""
if self._has_children:
# distribute points to children
# For all points calculate the child to insert in
child_indices_for_points = (
(points - self.corner_min) // (self.edge_length / 2)
).astype(int)
unique_indices, inverse_indices = np.unique(
child_indices_for_points, axis=0, return_inverse=True
)

# Reorder and group points by the child to insert in
grouped_points = np.split(
points[inverse_indices.argsort()],
np.cumsum(np.bincount(inverse_indices))[:-1],
)
for child_index, child_points in zip(unique_indices, grouped_points):
# Calculate the internal child id from its binary representation
child_internal_id = (
child_index[0] * 4 + child_index[1] * 2 + child_index[2]
)
Expand Down

0 comments on commit 55a1004

Please sign in to comment.