cvcg_utils.mesh package

cvcg_utils.mesh.gaussian_io module

class cvcg_utils.mesh.gaussian_io.ActGaussianModelTorch(xyz: torch.Tensor, features: torch.Tensor, opacity: torch.Tensor, scaling: torch.Tensor, rotation: torch.Tensor, max_sh_degree: int)

Bases: object

features: torch.Tensor
max_sh_degree: int
opacity: torch.Tensor
rigid_transform(transf_mat: torch.Tensor = None, scale: float = None)
  • returns a copy of self after a rigid transformation and isotropic scaling

  • if both are None, simply returns a copy

  • scale is applied after rigid transform

transf_mat: [4, 4], must be rigid transform scale: float, must be positive

rotation: torch.Tensor
scaling: torch.Tensor
xyz: torch.Tensor
class cvcg_utils.mesh.gaussian_io.PreactGaussianModelNp(xyz: numpy.ndarray, features_dc: numpy.ndarray, features_rest: numpy.ndarray, opacity: numpy.ndarray, scaling: numpy.ndarray, rotation: numpy.ndarray, max_sh_degree: int)

Bases: object

activate() ActGaussianModelTorch
features_dc: ndarray
features_rest: ndarray
max_sh_degree: int
opacity: ndarray
rotation: ndarray
scaling: ndarray
xyz: ndarray
cvcg_utils.mesh.gaussian_io.load_ply(path)

cvcg_utils.mesh.gaussian_model module

cvcg_utils.mesh.mesh_io module

class cvcg_utils.mesh.mesh_io.MeshData(verts: numpy.ndarray = None, faces: numpy.ndarray = None, uv_verts: numpy.ndarray = None, uv_faces: numpy.ndarray = None, v_normals: numpy.ndarray = None, f_normals: numpy.ndarray = None, v_colors: numpy.ndarray = None, f_colors: numpy.ndarray = None, v_quality: numpy.ndarray = None, edge_uv: numpy.ndarray = None)

Bases: object

edge_uv: ndarray = None
f_colors: ndarray = None
f_normals: ndarray = None
faces: ndarray = None
uv_faces: ndarray = None
uv_verts: ndarray = None
v_colors: ndarray = None
v_normals: ndarray = None
v_quality: ndarray = None
verts: ndarray = None
cvcg_utils.mesh.mesh_io.merge_meshes(mesh_1: MeshData, mesh_2: MeshData)

performs simple concatenation on verts and faces only

cvcg_utils.mesh.mesh_io.read_glb(fn: str) List[MeshData]
cvcg_utils.mesh.mesh_io.read_obj(fn: str) MeshData
cvcg_utils.mesh.mesh_io.read_ply(fn) MeshData
cvcg_utils.mesh.mesh_io.write_obj(fn: str, verts: ndarray, faces: ndarray, uv_verts: ndarray = None, uv_faces: ndarray = None, texture_img: ndarray = None)

texture_img should be uint8, [H, W, C], rgb

cvcg_utils.mesh.mesh_io.write_ply(fn: str, v: ndarray, f: ndarray = None, v_color: ndarray = None, f_color: ndarray = None, v_normal: ndarray = None, v_quality: ndarray = None, f_quality: ndarray = None, edge_uv: ndarray = None, texture_img: ndarray = None)

cvcg_utils.mesh.mesh_proc module

cvcg_utils.mesh.mesh_proc.get_boundary_edges(faces)
cvcg_utils.mesh.mesh_proc.get_boundary_verts(n_verts: int, faces: torch.Tensor)
cvcg_utils.mesh.mesh_proc.get_face_normals(verts: torch.Tensor, faces: torch.Tensor, normalize: bool)

verts: […, Nv, 3] faces: [Nf, 3]

out: face_normals (batched): […, Nf, 3]

cvcg_utils.mesh.mesh_proc.get_laplacian(n_verts: int, faces: torch.Tensor, dtype=torch.float) torch.Tensor

Modified from pytorch3d.ops.laplacian

Computes the laplacian matrix. The definition of the laplacian is L[i, j] = -1 , if i == j L[i, j] = 1 / deg(i) , if (i, j) is an edge L[i, j] = 0 , otherwise where deg(i) is the degree of the i-th vertex in the graph.

Parameters:
  • n_verts

  • faces – tensor of shape (Nf, 2)

Returns:

Sparse FloatTensor of shape (V, V)

Return type:

L

cvcg_utils.mesh.mesh_proc.get_mesh_eigenfunctions(verts, faces, k)
cvcg_utils.mesh.mesh_proc.get_unique_edges(faces)
cvcg_utils.mesh.mesh_proc.get_vert_normals(verts: torch.Tensor, faces: torch.Tensor, normalize: bool)

verts: […, Nv, 3] faces: [Nf, 3]

out: vert_normals (batched): […, Nv, 3]

cvcg_utils.mesh.mesh_proc.remove_unreferenced(vert_attrs: ndarray | torch.Tensor, faces: ndarray | torch.Tensor, vert_list_mask: ndarray | torch.Tensor = None, face_list_mask: ndarray | torch.Tensor = None)

vert_attrs: [Nv, C] faces: [Nf, 3]

vert_list_mask: [Nv], bool face_list_mask: [Nf], bool

out: - vert_attrs_cleaned - faces_cleaned

explanation: - a face will be removed if:

  1. it’s False in face_list_mask

  2. any of its vertices is False in vert_list_mask

  • a vert will be removed if: (1) it’s not referenced by any face after face masking

cvcg_utils.mesh.mesh_proc.remove_unreferenced_np(vert_attrs: ndarray, faces: ndarray, vert_list_mask: ndarray = None, face_list_mask: ndarray = None)
cvcg_utils.mesh.mesh_proc.remove_unreferenced_th(vert_attrs: torch.Tensor, faces: torch.Tensor, vert_list_mask: torch.Tensor = None, face_list_mask: torch.Tensor = None)

Module contents