1010- Grid: A single sparse voxel grid with support for efficient operations
1111
1212Class-methods for creating Grid objects from various sources:
13+
1314- :meth:`Grid.from_dense()` for dense data
1415- :meth:`Grid.from_dense_axis_aligned_bounds()` for dense defined by axis-aligned bounds
1516- :meth:`Grid.from_grid_batch()` for a single grid from a grid batch
1920- :meth:`Grid.from_points()` for point clouds
2021- :meth:`Grid.from_zero_voxels()` for a single grid with zero voxels
2122
22- Module-level functions for loading and saving grids:
23- - load_grid/save_grid : Load and save grids to/from .nvdb files
23+ Class/Instance-methods for loading and saving grids:
24+ - from_nanovdb/save_nanovdb : Load and save grids to/from .nvdb files
2425
2526Grid supports operations like convolution, pooling, interpolation, ray casting,
2627mesh extraction, and coordinate transformations on sparse voxel data.
@@ -66,7 +67,7 @@ class Grid:
6667 which a grid can be used to index into. This also allows multiple grids to share the same data
6768 storage if desired.
6869
69- When using a :class:`Grid`, voxel coordinates, there are three important coordinate systems to be aware of:
70+ When using a :class:`Grid`'s voxel coordinates, there are three important coordinate systems to be aware of:
7071
7172 - **World Space**: The continuous 3D coordinate system in which the grid exists.
7273 - **Voxel Space**: The discrete voxel index system, where each voxel is identified by its integer indices (i, j, k).
@@ -589,7 +590,6 @@ def clipped_grid(
589590 def coarsened_grid (self , coarsening_factor : NumericMaxRank1 ) -> "Grid" :
590591 """
591592 Return a :class:`Grid` representing the coarsened version of this grid.
592- Each voxel ``[i, j, k]`` in the input is included in the output if it lies within ``ijk_min`` and ``ijk_max``.
593593
594594 Args:
595595 coarsening_factor (NumericMaxRank1): The factor by which to coarsen the grid,
@@ -737,12 +737,12 @@ def dual_grid(self, exclude_border: bool = False) -> "Grid":
737737
738738 def voxel_to_world (self , ijk : torch .Tensor ) -> torch .Tensor :
739739 """
740- Transform a set of grid -space coordinates to their corresponding positions in world space
740+ Transform a set of voxel -space coordinates to their corresponding positions in world space
741741 using this :class:`Grid`'s origin and voxel size.
742742
743743 .. seealso::
744744
745- :meth:`world_to_voxel` for the inverse transformation, and :meth :`voxel_to_world_matrix` and :meth :`world_to_voxel_matrix` for
745+ :meth:`world_to_voxel` for the inverse transformation, and :attr :`voxel_to_world_matrix` and :attr :`world_to_voxel_matrix` for
746746 the actual transformation matrices.
747747
748748
@@ -974,7 +974,7 @@ def inject_to(
974974
975975 If you pass in destination data, ``dst``, then ``dst`` will be modified in-place.
976976 If ``dst`` is ``None``, a new :class:`torch.Tensor` will be created with the
977- shape ``(self .num_voxels, *src.shape[1:])`` and filled with ``default_value``
977+ shape ``(dst_grid .num_voxels, *src.shape[1:])`` and filled with ``default_value``
978978 for any voxels that do not have corresponding data in ``src``.
979979
980980 .. note::
@@ -1028,7 +1028,7 @@ def integrate_tsdf(
10281028
10291029 Args:
10301030 truncation_distance (float): Maximum distance to truncate TSDF values (in world units).
1031- projection_matrix (torch.Tensor): Camera projection matrix. A tensor-like object with ``shape: (4, 4 )``.
1031+ projection_matrix (torch.Tensor): Camera projection matrix. A tensor-like object with ``shape: (3, 3 )``.
10321032 cam_to_world_matrix (torch.Tensor): Camera to world transformation matrix. A tensor-like object with ``shape: (4, 4)``.
10331033 tsdf (torch.Tensor): Current TSDF values for each voxel. A :class:`torch.Tensor` with shape: ``(self.num_voxels, 1)``.
10341034 weights (torch.Tensor): Current integration weights for each voxel.
@@ -1120,7 +1120,7 @@ def integrate_tsdf_with_features(
11201120
11211121 Args:
11221122 truncation_distance (float): Maximum distance to truncate TSDF values (in world units).
1123- projection_matrix (torch.Tensor): Camera projection matrix. A tensor-like object with ``shape: (4, 4 )``.
1123+ projection_matrix (torch.Tensor): Camera projection matrix. A tensor-like object with ``shape: (3, 3 )``.
11241124 cam_to_world_matrix (torch.Tensor): Camera to world transformation matrix. A tensor-like object with ``shape: (4, 4)``.
11251125 features (torch.Tensor): Current feature values associated with each voxel in this :class:`Grid`.
11261126 A :class:`torch.Tensor` with shape ``(total_voxels, feature_dim)``.
@@ -1325,7 +1325,7 @@ def merged_grid(self, other: "Grid") -> "Grid":
13251325
13261326 def neighbor_indexes (self , ijk : torch .Tensor , extent : int , bitshift : int = 0 ) -> torch .Tensor :
13271327 """
1328- Get indices of neighboring voxels in this :class:`Grid` in an N-ring neighborhood of each
1328+ Get indexes of neighboring voxels in this :class:`Grid` in an N-ring neighborhood of each
13291329 voxel coordinate in ``ijk``.
13301330
13311331 Args:
@@ -1337,9 +1337,9 @@ def neighbor_indexes(self, ijk: torch.Tensor, extent: int, bitshift: int = 0) ->
13371337 Default is 0.
13381338
13391339 Returns:
1340- neighbor_indices (torch.Tensor): A :class:`torch.Tensor` of shape ``(num_queries, N)``
1341- containing the linear indices of neighboring voxels for each voxel coordinate in ``ijk``
1342- in the input. If some neighbors are not active in the grid, their indices will be ``-1``.
1340+ neighbor_indexes (torch.Tensor): A :class:`torch.Tensor` of shape ``(num_queries, N)``
1341+ containing the linear indexes of neighboring voxels for each voxel coordinate in ``ijk``
1342+ in the input. If some neighbors are not active in the grid, their indexes will be ``-1``.
13431343 """
13441344 jagged_ijk = JaggedTensor (ijk )
13451345 return self ._impl .neighbor_indexes (jagged_ijk ._impl , extent , bitshift ).jdata
@@ -1459,7 +1459,7 @@ def inject_from_dense_cminor(self, dense_data: torch.Tensor, dense_origin: Numer
14591459
14601460 Args:
14611461 dense_data (torch.Tensor): Dense :class:`torch.Tensor` to read from. Shape: ``(dense_size_x, dense_size_y, dense_size_z, channels*)``.
1462- dense_origins (NumericMaxRank1, optional): Origin of the dense tensor in
1462+ dense_origin (NumericMaxRank1, optional): Origin of the dense tensor in
14631463 voxel space, broadcastable to shape ``(3,)``, integer dtype
14641464
14651465 Returns:
@@ -1490,7 +1490,7 @@ def inject_from_dense_cmajor(self, dense_data: torch.Tensor, dense_origin: Numer
14901490
14911491 Args:
14921492 dense_data (torch.Tensor): Dense :class:`torch.Tensor` to read from. Shape: ``(channels*, dense_size_x, dense_size_y, dense_size_z)``.
1493- dense_origins (NumericMaxRank1, optional): Origin of the dense tensor in
1493+ dense_origin (NumericMaxRank1, optional): Origin of the dense tensor in
14941494 voxel space, broadcastable to shape ``(3,)``, integer dtype
14951495
14961496 Returns:
@@ -1656,7 +1656,7 @@ def sample_trilinear_with_grad(
16561656 Returns:
16571657 interpolated_data (torch.Tensor): Interpolated data at each point. Shape: ``(num_queries, channels*)``.
16581658 interpolation_gradients (torch.Tensor): Gradients of the interpolated data with respect to world coordinates.
1659- This is the spatial gradient of the Bézier interpolation at each point.
1659+ This is the spatial gradient of the trilinear interpolation at each point.
16601660 Shape: ``(num_queries, 3, channels*)``.
16611661 """
16621662 jagged_points = JaggedTensor (points )
@@ -2052,7 +2052,7 @@ def world_to_voxel(self, points: torch.Tensor) -> torch.Tensor:
20522052
20532053 .. seealso::
20542054
2055- :meth:`voxel_to_world` for the inverse transformation, and :meth :`voxel_to_world_matrix` and :meth :`world_to_voxel_matrix` for
2055+ :meth:`voxel_to_world` for the inverse transformation, and :attr :`voxel_to_world_matrix` and :attr :`world_to_voxel_matrix` for
20562056 the actual transformation matrices.
20572057
20582058 Args:
@@ -2072,7 +2072,7 @@ def inject_to_dense_cminor(
20722072 grid_size : NumericMaxRank1 | None = None ,
20732073 ) -> torch .Tensor :
20742074 """
2075- Inject values from :class:`torch.Tensor` associated with this :class:`Grid` into a
2075+ Write values from a :class:`torch.Tensor` associated with this :class:`Grid` into a
20762076 dense :class:`torch.Tensor`.
20772077
20782078 This is the "C Minor" (channels minor) version, which assumes the ``dense_data`` is in XYZC order. *i.e* the
@@ -2092,8 +2092,8 @@ def inject_to_dense_cminor(
20922092
20932093 .. seealso::
20942094
2095- :meth:`inject_from_dense_cmajor ` for reading from a dense tensor in "C Major " order,
2096- which assumes the dense tensor has shape ``[channels*, dense_size_x, dense_size_y, dense_size_z]``.
2095+ :meth:`inject_from_dense_cminor ` for reading from a dense tensor in "C Minor " order,
2096+ which assumes the dense tensor has shape ``[dense_size_x, dense_size_y, dense_size_z, channels* ]``.
20972097
20982098 .. seealso::
20992099
@@ -2131,7 +2131,7 @@ def inject_to_dense_cmajor(
21312131 grid_size : NumericMaxRank1 | None = None ,
21322132 ) -> torch .Tensor :
21332133 """
2134- Write values from :class:`torch.Tensor` associated with this :class:`Grid` into a
2134+ Write values from a :class:`torch.Tensor` associated with this :class:`Grid` into a
21352135 dense :class:`torch.Tensor`.
21362136
21372137 This is the "C Major" (channels major) version, which assumes the ``dense_data`` is in CXYZ order. *i.e* the
@@ -2141,7 +2141,7 @@ def inject_to_dense_cmajor(
21412141 within the range defined by ``min_coord`` and ``grid_size``.
21422142 Voxels not present in the sparse grid are filled with zeros. *.i.e.* this method will copy
21432143 all the voxel values in the range ``[min_coord, min_coord + grid_size)`` into a dense tensor
2144- of shape ``[dense_size_x, dense_size_y, dense_size_z, channels* ]``, such that ``min_coord``
2144+ of shape ``[channels*, dense_size_x, dense_size_y, dense_size_z]``, such that ``min_coord``
21452145 maps to index ``(0, 0, 0)`` in the dense tensor, and ``min_coord + grid_size - 1`` maps to index
21462146 ``(dense_size_x - 1, dense_size_y - 1, dense_size_z - 1)`` in the dense tensor.
21472147
@@ -2207,7 +2207,7 @@ def bbox(self) -> torch.Tensor:
22072207
22082208 .. note::
22092209
2210- The bounding box is inclusive of the minimum voxel and the the maximum voxel.
2210+ The bounding box is inclusive of the minimum voxel and the maximum voxel.
22112211
22122212 *e.g.* if you have a grid with a single voxel at index ``(0, 0, 0)``, the bounding box will be
22132213 ``[[0, 0, 0], [0, 0, 0]]``.
@@ -2247,7 +2247,7 @@ def dual_bbox(self) -> torch.Tensor:
22472247
22482248 .. note::
22492249
2250- The bounding box is inclusive of the minimum voxel and the the maximum voxel.
2250+ The bounding box is inclusive of the minimum voxel and the maximum voxel.
22512251
22522252 *e.g.* if you have a grid with a single voxel at index ``(0, 0, 0)``, the dual grid will contain voxels
22532253 at indices ``(0, 0, 0), (0, 0, 1), (0, 1, 0), ..., (1, 1, 1)``, and the bounding box will be
0 commit comments