warp.geometry.lipschitz_octree#
- warp.geometry.lipschitz_octree(
- field,
- origin,
- root_width,
- max_depth,
- threshold=0.0,
- lipschitz_bound=1.0,
- device=None,
Return max-depth octree cells that may intersect a level set of a Lipschitz-bounded implicit field.
Builds a sparse octree top-down, keeping only cells whose subtree can still reach the
thresholdlevel set of a 1-Lipschitz field: a cell of widthhcentered atcsurvives when|field(c) - threshold| <= lipschitz_bound * (sqrt(3)/2) * h. The surviving leaves atmax_depthform a thin shell around the surface.This mirrors
igl::lipschitz_octreefrom libigl. It is the pruning stage used bysparse_marching_cubes(), exposed separately so callers can build their own extractors, visualize the adaptive grid, or reuse the cells.This function does not support backward-mode automatic differentiation, by design: cell selection is a discrete, threshold-based search, not a smooth function of
field’s values, so there is no gradient to carry fromfieldto the outputcells. Recording this function on awarp.Tape()is silent – no warning, no gradient; seesparse_marching_cubes_from_cells()for the differentiable extraction stage.- Parameters:
field (Callable[[array], array]) – The implicit function, in the batched form accepted by
sparse_marching_cubes().origin (vec3f | tuple[float, float, float]) – The minimum corner of the cubic root cell. Set
originandroot_widthso that the box[origin, origin + root_width]covers the entire level set to be found; cells outside it are never visited.root_width (float) – The side length of the cubic root cell.
max_depth (int) – The octree depth. Leaf cells have width
root_width / 2**max_depth.threshold (float) – The isovalue defining the surface.
lipschitz_bound (float) – An upper bound on the Lipschitz constant of
field.device (Device | str | None) – The Warp device to run on. Defaults to the current device.
- Returns:
A tuple
(cells, cell_width)wherecellsis awarp.array[warp.vec3i]of the leaf cells’ integer minimum-corner subscripts, in the conventionsparse_marching_cubes_from_cells()expects (cell(i, j, k)covers[origin + cell_width * (i, j, k), origin + cell_width * (i + 1, j + 1, k + 1)]), andcell_widthis their common side length.cellsis empty if the level set is not bracketed.- Return type: