def get_voxel_centers_grid_smaller_pc(pts, grid_resolution, distance_threshold_vs=10):
    """
    This is more efficient when the point cloud is considerable smaller than the grid. n_p << grid_res^3
    :param pts:
    :param grid_resolution:
    :param distance_threshold_vs:
    :return:
    """
    from scipy.ndimage.filters import convolve

    # get grid voxel centers
    pts_vs = model_space_to_volume_space(pts, grid_resolution)
    query_pts_vol = np.zeros((grid_resolution, grid_resolution, grid_resolution), dtype=np.float32)
    query_pts_vol[pts_vs[:, 0], pts_vs[:, 1], pts_vs[:, 2]] = 1.0

    # expand query points from the known necessary points
    kernel = np.ones((distance_threshold_vs, distance_threshold_vs, distance_threshold_vs), dtype=np.float32)
    grid_pts_near_surf_vol = convolve(query_pts_vol, kernel, mode='nearest')

    # convert volume to points in model space
    grid_pts_near_surf_vs = np.nonzero(grid_pts_near_surf_vol[:-1, :-1, :-1])
    grid_pts_near_surf_vs = np.stack(grid_pts_near_surf_vs, axis=1)
    grid_pts_near_surf_ms = volume_space_to_model_space(grid_pts_near_surf_vs, grid_resolution)

    return grid_pts_near_surf_ms.astype(np.float32)

    This is more efficient when the point cloud is considerable smaller than the grid. n_p << grid_res^3
    :param pts:
    :param grid_resolution:
    :param distance_threshold_vs:
    :return:
    
source/sdf.py