GridBatch

class fvdb.GridBatch

A batch of sparse VDB grids.

property address

The memory address of the underlying C++ GridBatch object.

avg_pool(self: fvdb.GridBatch, pool_factor: fvdb.Vec3iOrScalar, data: fvdb.JaggedTensor, stride: fvdb.Vec3iOrScalar = 0, coarse_grid: fvdb.GridBatch | None = None) tuple[fvdb.JaggedTensor, fvdb.GridBatch]

Downsample this batch of grids using average pooling.

Parameters:
  • pool_factor (int or 3-tuple of ints) – How much to pool by (i,e, (2,2,2) means take average over 2x2x2 from start of window).

  • data (JaggedTensor) – Data at each voxel in this grid to be downsampled (JaggedTensor of shape [B, -1, *]).

  • stride (int) – The stride to use when pooling

  • coarse_grid (GridBatch, optional) – An optional coarse grid used to specify the output. This is mainly used for memory efficiency so you can chache grids. If you don’t pass it in, we’ll just create it for you.

Returns:
  • coarse_data (JaggedTensor) – a JaggedTensor of shape [B, -1, *] of downsampled data.

  • coarse_grid (GridBatch) – the downsampled grid batch.

property bbox

A [num_grids, 2, 3] tensor of the bounding box of each grid in this batch where bbox[i, 0] is the minimimum ijk coordinate of the i^th grid, and bbox[i, 1] is the maximum ijk coordinate.

bbox_at(self: fvdb.GridBatch, bi: int) torch.Tensor

Get the bounding box (in voxel coordinates) of the bi^th grid in the batch.

Parameters:

bi (int) – The index of the grid to get the bounding box of.

Returns:

bbox (torch.Tensor) – A tensor, bbox, of shape [2, 3] where bbox = [[bmin_i, bmin_j, bmin_z=k], [bmax_i, bmax_j, bmax_k]] is the bi^th bounding box such that bmin <= ijk < bmax for all voxels ijk in the bi^th grid.

clip(self: fvdb.GridBatch, features: fvdb.JaggedTensor, ijk_min: fvdb.Vec3iBatch, ijk_max: fvdb.Vec3iBatch) tuple[fvdb.JaggedTensor, fvdb.GridBatch]

Return a batch of grids representing the clipped version of this batch of grids and corresponding features.

Parameters:
  • features (JaggedTensor) – A JaggedTensor of shape [B, -1, *] containing features associated with this batch of grids.

  • ijk_min (list of int triplets) – Index space minimum bound of the clip region.

  • ijk_max (list of int triplets) – Index space maximum bound of the clip region.

Returns:
  • clipped_features (JaggedTensor) – a JaggedTensor of shape [B, -1, *] of clipped data.

  • clipped_grid (GridBatch) – the clipped grid batch.

clipped_grid(self: fvdb.GridBatch, ijk_min: fvdb.Vec3iBatch, ijk_max: fvdb.Vec3iBatch) fvdb.GridBatch

Return a batch of grids representing the clipped version of this batch. Each voxel [i, j, k] in the input batch is included in the output if it lies within ijk_min and ijk_max.

Parameters:
  • ijk_min (list of int triplets) – Index space minimum bound of the clip region.

  • ijk_max (list of int triplets) – Index space maximum bound of the clip region.

Returns:

clipped_grid (GridBatch) – A GridBatch representing the clipped version of this grid batch.

coarsened_grid(self: fvdb.GridBatch, coarsening_factor: fvdb.Vec3iOrScalar) fvdb.GridBatch

Return a batch of grids representing the coarsened version of this batch. Each voxel [i, j, k] in this grid batch maps to voxel [i / branchFactor, j / branchFactor, k / branchFactor] in the coarse batch.

Parameters:

coarsening_factor (int or 3-tuple of ints) – How much to coarsen by (i,e, (2,2,2) means take every other voxel from start of window).

Returns:

coarsened_grid (GridBatch) – A GridBatch representing the coarsened version of this grid batch.

contiguous(self: fvdb.GridBatch) fvdb.GridBatch

Return a contiguous copy of this grid batch.

conv_grid(self: fvdb.GridBatch, kernel_size: fvdb.Vec3iOrScalar, stride: fvdb.Vec3iOrScalar) fvdb.GridBatch

Return a batch of grids representing the convolution of this batch with a given kernel. Each voxel [i, j, k] in the output batch is the sum of the voxels in the input batch [i * stride, j * stride, k * stride] to [i * stride + kernel_size, j * stride + kernel_size, k * stride + kernel_size].

Parameters:
  • kernel_size (int or 3-tuple of ints) – The size of the kernel to convolve with.

  • stride (int or 3-tuple of ints) – The stride to use when convolving.

Returns:

conv_grid (GridBatch) – A GridBatch representing the convolution of this grid batch.

coords_in_active_voxel(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor, ignore_disabled: bool = False) fvdb.JaggedTensor

Given a set of ijk coordinates, return a JaggedTensor of booleans indicating which coordinates are active in this gridbatch

Parameters:
  • ijk (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of integer ijk coordinates.

  • ignore_disabled (bool) – Whether to ignore disabled voxels when computing the output.

Returns:

coords_in_active_voxel (JaggedTensor) – A JaggedTensor of shape [num_grids, -1] of booleans indicating which coordinates are in the grid.

cpu(self: fvdb.GridBatch) fvdb.GridBatch
cubes_in_grid(self: fvdb.GridBatch, cube_centers: fvdb.JaggedTensor, cube_min: fvdb.Vec3dOrScalar = 0.0, cube_max: fvdb.Vec3dOrScalar = 0.0, ignore_disabled: bool = False) fvdb.JaggedTensor

Given a set of cube centers and extents, return a JaggedTensor of booleans indicating whether cubes fully reside in active voxels.

Parameters:
  • cube_centers (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of cube centers.

  • cube_min (float or triple of floats) – The minimum extent of each cube (all cubes have the same size).

  • cube_max (float or triple of floats) – The maximum extent of the cube (all cubes have the same size).

  • ignore_disabled (bool) – Whether to ignore disabled voxels when computing the output.

Returns:

cubes_intersect_grid (JaggedTensor) – A JaggedTensor of shape [num_grids, -1] of booleans indicating whether cubes fully reside in active voxels.

cubes_intersect_grid(self: fvdb.GridBatch, cube_centers: fvdb.JaggedTensor, cube_min: fvdb.Vec3dOrScalar = 0.0, cube_max: fvdb.Vec3dOrScalar = 0.0, ignore_disabled: bool = False) fvdb.JaggedTensor

Given a set of cube centers and extents, return a JaggedTensor of booleans indicating whether cubes intersect active voxels.

Parameters:
  • cube_centers (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of cube centers.

  • cube_min (float or triple of floats) – The minimum extent of each cube (all cubes have the same size).

  • cube_max (float or triple of floats) – The maximum extent of the cube (all cubes have the same size).

  • ignore_disabled (bool) – Whether to ignore disabled voxels when computing the output.

Returns:

cubes_intersect_grid (JaggedTensor) – A JaggedTensor of shape [num_grids, -1] of booleans indicating whether cubes intersect active voxels.

cuda(self: fvdb.GridBatch) fvdb.GridBatch
property cum_enabled_voxels

An integer tensor containing the cumulative number of voxels enabled in each grid in this batch. i.e. [nvox_0, nvox_0+nvox_1, nvox_0+nvox_1+nvox_2, …]

cum_enabled_voxels_at(self: fvdb.GridBatch, arg0: int) int

Get the cumulative number of enabled voxels in the bi^th grid in the batch. i.e. nvox_0+nvox_1+…+nvox_i. If this grid isn’t mutable, this returns the same value as cum_voxels_at.

property cum_voxels

An integer tensor containing the cumulative number of voxels indexed by the grids in this batch. i.e. [nvox_0, nvox_0+nvox_1, nvox_0+nvox_1+nvox_2, …]

cum_voxels_at(self: fvdb.GridBatch, arg0: int) int

Get the cumulative number of voxels in the bi^th grid in the batch. i.e. nvox_0+nvox_1+…+nvox_i

property device

The device on which this grid is stored.

disable_ijk(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor) None

If this is grid is mutable, disable voxels at the specified coordinates, otherwise throw an exception. If the ijk values are already disabled or are not represented in this GridBatch, then this function is no-op.

Parameters:

ijk (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of ijk coordinates to disable.

property disabled_mask

A boolean JaggedTensor of shape [B, -1] indicating whether each voxel in the grid is disabled or not.

property dual_bbox

A [num_grids, 2, 3] tensor of the bounding box of the dual of each grid in this batch where bbox[i, 0] is the minimimum ijk coordinate of the i^th dual grid, and bbox[i, 1] is the maximum ijk coordinate.

dual_bbox_at(self: fvdb.GridBatch, arg0: int) torch.Tensor

Get the bounding box (in voxel coordinates) of the dual of the bi^th grid in the batch.

dual_grid(self: fvdb.GridBatch, exclude_border: bool = False) fvdb.GridBatch

Return a batch of grids representing the dual of this batch. i.e. The centers of the dual grid correspond to the corners of this grid batch. The [i, j, k] coordinate of the dual grid corresponds to the bottom/left/back corner of the [i, j, k] voxel in this grid batch.

Parameters:

exclude_border (bool) – Whether to exclude the border of the grid batch when computing the dual grid

Returns:

dual_grid (GridBatch) – A GridBatch representing the dual of this grid batch.

enable_ijk(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor) None

If this is grid is mutable, enable voxels at the specified coordinates, otherwise throw an exception. If the ijk values are already enabled or are not represented in this GridBatch, then this function is no-op.

Parameters:

ijk (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of ijk coordinates to disable.

property enabled_mask

A boolean JaggedTensor of shape [B, -1] indicating whether each voxel in the grid is enabled or not.

fill_from_grid(self: fvdb.GridBatch, features: fvdb.JaggedTensor, other_grid: fvdb.GridBatch, default_value: float = 0.0) fvdb.JaggedTensor

Given a GridBatch and features associated with it, return a JaggedTensor representing features for this batch of grid. Fill any voxels not in the GridBatch with the default value.

Parameters:
  • other_features (JaggedTensor) – A JaggedTensor of shape [B, -1, *] containing features associated with other_grid.

  • other_grid (GridBatch) – A GridBatch containing the grid to fill from.

  • default_value (float) – The value to fill in for voxels not in the GridBatch (default 0.0).

Returns:

filled_features (JaggedTensor) – A JaggedTensor of shape [B, -1, *] of features associated with this batch of grids.

property grid_count

The number of grids indexed by this batch.

grid_to_world(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor) fvdb.JaggedTensor
property grid_to_world_matrices

A [num_grids, 4, 4] tensor of the grid to world transformation matrices for each grid in this batch.

property ijk

A [num_grids, -1, 3] JaggedTensor of the ijk coordinates of each voxel in this batch.

property ijk_enabled

A [num_grids, -1, 3] JaggedTensor of the ijk coordinates of each enabled voxel in this batch.

ijk_to_index(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor, cumulative: bool = False) fvdb.JaggedTensor
ijk_to_inv_index(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor, cumulative: bool = False) fvdb.JaggedTensor
is_contiguous(self: fvdb.GridBatch) bool

Whether this grid batch is contiguous.

is_same(self: fvdb.GridBatch, other: fvdb.GridBatch) bool

Check if this grid batch refers to the same underlying NanoVDB grid as another GridBatch.

Parameters:

other (GridBatch) – The other grid batch to compare to.

Returns:

is_same (bool) – Whether the two grid batches are the same.”

jagged_like(self: fvdb.GridBatch, data: torch.Tensor, ignore_disabled: bool = True) fvdb.JaggedTensor

Create a JaggedTensor with the same offsets as this grid batch.

Parameters:
  • data (torch.Tensor) – A tensor of shape [total_voxels, *] to be converted to a JaggedTensor.

  • ignore_disabled (bool) – Whether to ignore disabled voxels when creating the JaggedTensor.

Returns:

jagged_data (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, *] with the same offsets as this grid batch.

property jidx

A [total_voxels,] tensor of the jagged index of each voxel in this batch.

property joffsets

A [num_grids+1,] tensor of the jagged offsets of each grid in this batch.

marching_cubes(self: fvdb.GridBatch, field: fvdb.JaggedTensor, level: float = 0.0) list[fvdb.JaggedTensor]
max_grids_per_batch = 1024
max_pool(self: fvdb.GridBatch, pool_factor: fvdb.Vec3iOrScalar, data: fvdb.JaggedTensor, stride: fvdb.Vec3iOrScalar = 0, coarse_grid: fvdb.GridBatch | None = None) tuple[fvdb.JaggedTensor, fvdb.GridBatch]

Downsample this batch of grids using maxpooling.

Parameters:
  • pool_factor (int or 3-tuple of ints) – How much to pool by (i,e, (2,2,2) means take max over 2x2x2 from start of window).

  • data (JaggedTensor) – Data at each voxel in this grid to be downsampled (JaggedTensor of shape [B, -1, *]).

  • stride (int) – The stride to use when pooling

  • coarse_grid (GridBatch, optional) – An optional coarse grid used to specify the output. This is mainly used for memory efficiency so you can chache grids. If you don’t pass it in, we’ll just create it for you.

Returns:
  • coarse_data (JaggedTensor) – a JaggedTensor of shape [B, -1, *] of downsampled data.

  • coarse_grid (GridBatch) – the downsampled grid batch.

property mutable

Whether the grid is mutable.

neighbor_indexes(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor, extent: int, bitshift: int = 0) fvdb.JaggedTensor
property num_bytes

A [num_grids] tensor of the number of bytes used by each grid in this batch.

property num_enabled_voxels

An integer tensor containing the number of enabled voxels per grid indexed by this batch. If this grid is not mutable, this will be the same as num_voxels.

num_enabled_voxels_at(self: fvdb.GridBatch, arg0: int) int

Get the number of enabled voxels in the bi^th grid in the batch. If this grid isn’t mutable, this returns the same value as num_voxels_at.

property num_leaf_nodes

A [num_grids] tensor of the number of leaf nodes used by each grid in this batch.

property num_voxels

An integer tensor containing the number of voxels per grid indexed by this batch.

num_voxels_at(self: fvdb.GridBatch, arg0: int) int

Get the number of voxels in the bi^th grid in the batch.

origin_at(self: fvdb.GridBatch, arg0: int) torch.Tensor

Get the origin of the bi^th grid in the batch.

property origins

A [num_grids, 3] tensor of world space origins for each grid in this batch.

points_in_active_voxel(self: fvdb.GridBatch, points: fvdb.JaggedTensor, ignore_disabled: bool = False) fvdb.JaggedTensor

Given a set of points, return a JaggedTensor of booleans indicating which points are in active voxels.

Parameters:
  • points (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of point positions.

  • ignore_disabled (bool) – Whether to ignore disabled voxels when computing the output.

Returns:

points_in_active_voxel (JaggedTensor) – A JaggedTensor of shape [num_grids, -1] of booleans indicating which points are in active voxels.

ray_implicit_intersection(self: fvdb.GridBatch, ray_origins: fvdb.JaggedTensor, ray_directions: fvdb.JaggedTensor, grid_scalars: fvdb.JaggedTensor, eps: float = 0.0) fvdb.JaggedTensor
read_from_dense(self: fvdb.GridBatch, dense_data: torch.Tensor, dense_origins: fvdb.Vec3iBatch = tensor([0, 0, 0], dtype=torch.int32)) fvdb.JaggedTensor

Read the data in a dense tensor into a JaggedTensor indexed by this batch of grids. Non-indexed values are ignored.

Parameters:
  • dense_data (torch.Tensor) – A tensor of shape [num_grids, width, height, depth, *] of values to be read from.

  • dense_origins (list of floats) – The ijk coordinate corresponding to dense_data[*, 0, 0, 0].

Returns:

sparse_data (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, *] of values indexed by this grid batch.

sample_bezier(self: fvdb.GridBatch, points: fvdb.JaggedTensor, voxel_data: fvdb.JaggedTensor) fvdb.JaggedTensor
sample_bezier_with_grad(self: fvdb.GridBatch, points: fvdb.JaggedTensor, voxel_data: fvdb.JaggedTensor) list[fvdb.JaggedTensor]
sample_trilinear(self: fvdb.GridBatch, points: fvdb.JaggedTensor, voxel_data: fvdb.JaggedTensor) fvdb.JaggedTensor
sample_trilinear_with_grad(self: fvdb.GridBatch, points: fvdb.JaggedTensor, voxel_data: fvdb.JaggedTensor) list[fvdb.JaggedTensor]
segments_along_rays(self: fvdb.GridBatch, ray_origins: fvdb.JaggedTensor, ray_directions: fvdb.JaggedTensor, max_segments: int, eps: float = 0.0, ignore_masked: bool = False) fvdb.JaggedTensor
set_from_dense_grid(self: fvdb.GridBatch, num_grids: int, dense_dims: fvdb.Vec3i, ijk_min: fvdb.Vec3i = tensor([0, 0, 0], dtype=torch.int32), voxel_sizes: fvdb.Vec3dBatchOrScalar = 1.0, origins: fvdb.Vec3dBatch = tensor([0., 0., 0.]), mask: torch.Tensor | None = None) None

Set the voxels in this grid batch to a dense grid with shape [num_grids, width, height, depth], otpionally masking out certain voxels

Parameters:
  • num_grids (int) – The number of grids in the batch

  • dense_dims (triple of ints) – The dimensions of the dense grid [width, height, depth]

  • ijk_min (triple of ints) – Index space minimum bound of the dense grid.

  • voxel_sizes (float, list, tensor) – Either a float or triple specifyng the voxel size of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the voxel size for each grid.

  • origins (float, list, tensor) – Either a float or triple specifyng the world space origin of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the world space origin for each grid.

  • mask (torch.Tensor) – A tensor of shape [num_grids, width, height, depth] of booleans indicating which voxels to include/exclude.

set_from_ijk(self: fvdb.GridBatch, ijk: fvdb.JaggedTensor, pad_min: fvdb.Vec3i = tensor([0, 0, 0], dtype=torch.int32), pad_max: fvdb.Vec3i = tensor([0, 0, 0], dtype=torch.int32), voxel_sizes: fvdb.Vec3dBatchOrScalar = 1.0, origins: fvdb.Vec3dBatch = tensor([0., 0., 0.])) None

Set the voxels in this grid batch to those specified by a given set of ijk coordinates (with optional padding)

Parameters:
  • ijk (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of ijk coordinates.

  • pad_min (triple of ints) – Index space minimum bound of the padding region.

  • pad_max (triple of ints) – Index space maximum bound of the padding region.

  • voxel_sizes (float, list, tensor) – Either a float or triple specifyng the voxel size of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the voxel size for each grid.

  • origins (float, list, tensor) – Either a float or triple specifyng the world space origin of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the world space origin for each grid.

set_from_mesh(self: fvdb.GridBatch, mesh_vertices: fvdb.JaggedTensor, mesh_faces: fvdb.JaggedTensor, voxel_sizes: fvdb.Vec3dBatchOrScalar = 1.0, origins: fvdb.Vec3dBatch = tensor([0, 0, 0], dtype=torch.int32)) None

Set the voxels in this grid batch to those which intersect a given triangle mesh

Parameters:
  • mesh_vertices (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of mesh vertex positions.

  • mesh_faces (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of integer indexes into mesh_vertices specifying the faces of each mesh.

  • voxel_sizes (float, list, tensor) – Either a float or triple specifyng the voxel size of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the voxel size for each grid.

  • origins (float, list, tensor) – Either a float or triple specifyng the world space origin of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the world space origin for each grid.

set_from_nearest_voxels_to_points(self: fvdb.GridBatch, points: fvdb.JaggedTensor, voxel_sizes: fvdb.Vec3dBatchOrScalar = 1.0, origins: fvdb.Vec3dBatch = tensor([0., 0., 0.])) None

Set the voxels in this grid batch to the nearest voxel to each point in a given point cloud

Parameters:
  • points (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of point positions.

  • voxel_sizes (float, list, tensor) – Either a float or triple specifyng the voxel size of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the voxel size for each grid.

  • origins (float, list, tensor) – Either a float or triple specifyng the world space origin of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the world space origin for each grid.

set_from_points(self: fvdb.GridBatch, points: fvdb.JaggedTensor, pad_min: fvdb.Vec3i = tensor([0, 0, 0], dtype=torch.int32), pad_max: fvdb.Vec3i = tensor([0, 0, 0], dtype=torch.int32), voxel_sizes: fvdb.Vec3dBatchOrScalar = 1.0, origins: fvdb.Vec3dBatch = tensor([0, 0, 0], dtype=torch.int32)) None

Set the voxels in this grid batch to those which contain a point in a given point cloud (with optional padding)

Parameters:
  • points (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of point positions.

  • pad_min (triple of ints) – Index space minimum bound of the padding region.

  • pad_max (triple of ints) – Index space maximum bound of the padding region.

  • mesh_faces (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of integer indexes into mesh_vertices specifying the faces of each mesh.

  • voxel_sizes (float, list, tensor) – Either a float or triple specifyng the voxel size of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the voxel size for each grid.

  • origins (float, list, tensor) – Either a float or triple specifyng the world space origin of all the grids in the batch or a tensor of shape [num_grids, 3] specifying the world space origin for each grid.

set_global_origin(self: fvdb.GridBatch, origin: fvdb.Vec3d) None

Set the origin of all grids in this batch.

Parameters:

origin (list of floats) – The new global origin of this batch of grids.

set_global_voxel_size(self: fvdb.GridBatch, voxel_size: fvdb.Vec3dOrScalar) None

Set the voxel size of all grids in this batch.

Parameters:

voxel_size (list of floats) – The new global voxel size of this batch of grids.

sparse_conv_halo(self: fvdb.GridBatch, input: fvdb.JaggedTensor, weight: torch.Tensor, variant: int = 8) fvdb.JaggedTensor

Perform in-grid convolution using fast Halo Buffer method. Currently only supports 3x3x3 kernels.

Parameters:
  • input (JaggedTensor) – A JaggedTensor of shape [B, -1, *] containing features associated with this batch of grids.

  • weight (torch.Tensor) – A tensor of shape [O, I, 3, 3, 3] containing the convolution kernel.

  • variant (int) – Which variant of the Halo Buffer method to use. Currently 8 and 64 are supported.

Returns:

out (JaggedTensor) – a JaggedTensor of shape [B, -1, *] of convolved data.

sparse_conv_kernel_map(self: fvdb.GridBatch, kernel_size: fvdb.Vec3iOrScalar, stride: fvdb.Vec3iOrScalar, target_grid: fvdb.GridBatch | None = None) tuple[fvdb.SparseConvPackInfo, fvdb.GridBatch]
splat_bezier(self: fvdb.GridBatch, points: fvdb.JaggedTensor, points_data: fvdb.JaggedTensor) fvdb.JaggedTensor
splat_trilinear(self: fvdb.GridBatch, points: fvdb.JaggedTensor, points_data: fvdb.JaggedTensor) fvdb.JaggedTensor
subdivide(self: fvdb.GridBatch, subdiv_factor: fvdb.Vec3iOrScalar, data: fvdb.JaggedTensor, mask: fvdb.JaggedTensor | None = None, fine_grid: fvdb.GridBatch | None = None) tuple[fvdb.JaggedTensor, fvdb.GridBatch]

Subdivide the grid batch and associated data tensor into a finer GridBatch and data tensor using nearest neighbor sampling. Each voxel [i, j, k] in this grid batch maps to voxels [i * subdivFactor, j * subdivFactor, k * subdivFactor] in the fine batch. Each data value in the subdividided data tensor inherits its parent value

Parameters:
  • subdiv_factor (int or 3-tuple of ints) – How much to subdivide by (i,e, (2,2,2) means subdivide each voxel into 2^3 voxels).

  • data (JaggedTensor) – A JaggedTensor of shape [B, -1, *] containing data associated with this batch of grids.

  • mask (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of booleans indicating which voxels to subdivide.

  • fine_grid (GridBatch) – An optional fine grid used to specify the output. This is mainly used for memory efficiency so you can chache grids. If you don’t pass it in, we’ll just create it for you.

Returns:
  • fine_data (JaggedTensor) – A JaggedTensor of shape [B, -1, *] of data associated with the fine grid batch.

  • fine_grid (GridBatch) – A GridBatch representing the subdivided version of this grid batch.

subdivided_grid(self: fvdb.GridBatch, subdiv_factor: fvdb.Vec3iOrScalar, mask: fvdb.JaggedTensor | None = None) fvdb.GridBatch

Subdivide the grid batch into a finer grid batch. Each voxel [i, j, k] in this grid batch maps to voxels [i * subdivFactor, j * subdivFactor, k * subdivFactor] in the fine batch.

Parameters:
  • subdiv_factor (int or 3-tuple of ints) – How much to subdivide by (i,e, (2,2,2) means subdivide each voxel into 2^3 voxels).

  • mask (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, 3] of booleans indicating which voxels to subdivide.

Returns:

subdivided_grid (GridBatch) – A GridBatch representing the subdivided version of this grid batch.

to(*args, **kwargs)

Overloaded function.

  1. to(self: fvdb._Cpp.GridBatch, device: fvdb._Cpp.TorchDeviceOrString) -> fvdb._Cpp.GridBatch

  2. to(self: fvdb._Cpp.GridBatch, to_tensor: torch.Tensor) -> fvdb._Cpp.GridBatch

  3. to(self: fvdb._Cpp.GridBatch, to_jtensor: fvdb::JaggedTensor) -> fvdb._Cpp.GridBatch

  4. to(self: fvdb._Cpp.GridBatch, to_grid: fvdb._Cpp.GridBatch) -> fvdb._Cpp.GridBatch

property total_bbox

A tensor, total_bbox, of shape [2, 3] where total_bbox = [[bmin_i, bmin_j, bmin_z=k], [bmax_i, bmax_j, bmax_k]] is the bounding box such that bmin <= ijk < bmax for all voxels ijk in the batch.

property total_bytes

The total number of bytes used by this batch of grids.

property total_enabled_voxels

The total number of enabled voxels indexed by this batch of grids.

property total_leaf_nodes

The total number of leaf nodes used by this batch of grids.

property total_voxels

The total number of voxels indexed by this batch of grids.

uniform_ray_samples(self: fvdb.GridBatch, ray_origins: fvdb.JaggedTensor, ray_directions: fvdb.JaggedTensor, t_min: fvdb.JaggedTensor, t_max: fvdb.JaggedTensor, step_size: float, cone_angle: float = 0.0, include_end_segments: bool = True, return_midpoints: bool = False, eps: float = 0.0) fvdb.JaggedTensor
property viz_edge_network

A pair of JaggedTensors (gv, ge) of shape [num_grids, -1, 3] and [num_grids, -1, 2] where gv are the corner positions of each voxel and ge are edge indices indexing into gv. This property is useful for visualizing the grid.

voxel_size_at(self: fvdb.GridBatch, arg0: int) torch.Tensor

Get the voxel size of the bi^th grid in the batch.

property voxel_sizes

A [num_grids, 3] tensor of voxel sizes for each grid in this batch.

voxels_along_rays(self: fvdb.GridBatch, ray_origins: fvdb.JaggedTensor, ray_directions: fvdb.JaggedTensor, max_voxels: int, eps: float = 0.0, return_ijk: bool = True, cumulative: bool = False) list[fvdb.JaggedTensor]
world_to_grid(self: fvdb.GridBatch, points: fvdb.JaggedTensor) fvdb.JaggedTensor
property world_to_grid_matrices

A [num_grids, 4, 4] tensor of the world to grid transformation matrices for each grid in this batch.

write_to_dense(self: fvdb.GridBatch, sparse_data: fvdb.JaggedTensor, min_coord: fvdb.Vec3iBatch | None = None, grid_size: fvdb.Vec3i | None = None) torch.Tensor

Read the data in a tensor indexed by this batch of grids into a dense tensor, setting non indexed values to zero.

Parameters:
  • sparse_data (JaggedTensor) – A JaggedTensor of shape [num_grids, -1, *] of values indexed by this grid batch.

  • min_coord (list of ints) – Index space minimum bound of the dense grid.

  • grid_size (list of ints) – The dimensions of the dense grid to read into [width, height, depth]

Returns:

dense_data (torch.Tensor) – A tensor of shape [num_grids, width, height, depth, *] of values indexed by this grid batch.