DeepSDFStruct.flexicubes.flexicubes#
Classes
|
This class implements the DeepSDFStruct.flexicubes method for extracting meshes from scalar fields. |
- class DeepSDFStruct.flexicubes.flexicubes.FlexiCubes(device='cuda', qef_reg_scale=0.001, weight_scale=0.99)#
Bases:
object
This class implements the DeepSDFStruct.flexicubes method for extracting meshes from scalar fields. It maintains a series of lookup tables and indices to support the mesh extraction process. DeepSDFStruct.flexicubes, a differentiable variant of the Dual Marching Cubes (DMC) scheme, enhances the geometric fidelity and mesh quality of reconstructed meshes by dynamically adjusting the surface representation through gradient-based optimization.
During instantiation, the class loads DMC tables from a file and transforms them into PyTorch tensors on the specified device.
- device#
Specifies the computational device (default is “cuda”).
- Type:
str
- dmc_table#
Dual Marching Cubes (DMC) table that encodes the edges associated with each dual vertex in 256 Marching Cubes (MC) configurations.
- Type:
torch.Tensor
- num_vd_table#
Table holding the number of dual vertices in each of the 256 MC configurations.
- Type:
torch.Tensor
- check_table#
Table resolving ambiguity in cases C16 and C19 of the DMC configurations.
- Type:
torch.Tensor
- tet_table#
Lookup table used in tetrahedralizing the isosurface.
- Type:
torch.Tensor
- quad_split_1#
Indices for splitting a quad into two triangles along one diagonal.
- Type:
torch.Tensor
- quad_split_2#
Alternative indices for splitting a quad into two triangles along the other diagonal.
- Type:
torch.Tensor
- quad_split_train#
Indices for splitting a quad into four triangles during training by connecting all edges to their midpoints.
- Type:
torch.Tensor
- cube_corners#
Defines the positions of a standard unit cube’s eight corners in 3D space, ordered starting from the origin (0,0,0), moving along the x-axis, then y-axis, and finally z-axis. Used as a blueprint for generating a voxel grid.
- Type:
torch.Tensor
- cube_corners_idx#
Cube corners indexed as powers of 2, used to retrieve the case id.
- Type:
torch.Tensor
- cube_edges#
Edge connections in a cube, listed in pairs. Used to retrieve edge vertices in DMC.
- Type:
torch.Tensor
- edge_dir_table#
A mapping tensor that associates edge indices with their corresponding axis. For instance, edge_dir_table[0] = 0 indicates that the first edge is oriented along the x-axis.
- Type:
torch.Tensor
- dir_faces_table#
A tensor that maps the corresponding axis of shared edges across four adjacent cubes to the shared faces of these cubes. For instance, dir_faces_table[0] = [5, 4] implies that for four cubes sharing an edge along the x-axis, the first and second cubes share faces indexed as 5 and 4, respectively. This tensor is only utilized during isosurface tetrahedralization.
- Type:
torch.Tensor
- adj_pairs#
A tensor containing index pairs that correspond to neighboring cubes that share the same edge.
- Type:
torch.Tensor
- qef_reg_scale#
The scaling factor applied to the regularization loss to prevent issues with singularity when solving the QEF. This parameter is only used when a ‘grad_func’ is specified.
- Type:
float
- weight_scale#
The scale of weights in DeepSDFStruct.flexicubes. Should be between 0 and 1.
- Type:
float
- construct_voxel_grid(resolution)#
Generates a voxel grid based on the specified resolution.
- Parameters:
res (int or list[int]) – The resolution of the voxel grid. If an integer is provided, it is used for all three dimensions. If a list or tuple of 3 integers is provided, they define the resolution for the x, y, and z dimensions respectively.
- Returns:
- Returns the vertices and the indices of the
cube corners (index into vertices) of the constructed voxel grid. The vertices are centered at the origin, with the length of each dimension in the grid being one.
- Return type:
(torch.Tensor, torch.Tensor)