kaolin.rep.TriangleMesh¶
-
class
TriangleMesh
(vertices: torch.Tensor, faces: torch.Tensor, uvs: torch.Tensor, face_textures: torch.Tensor, textures: torch.Tensor, edges: torch.Tensor, edge2key: dict, vv: torch.Tensor, vv_count: torch.Tensor, vf: torch.Tensor, vf_count: torch.Tensor, ve: torch.Tensor, ve_count: torch.Tensor, ff: torch.Tensor, ff_count: torch.Tensor, ef: torch.Tensor, ef_count: torch.Tensor, ee: torch.Tensor, ee_count: torch.Tensor)[source]¶ Abstract class to represent 3D Trianlge meshes.
-
compute_adjacency_matrix_full
()[source]¶ Calcualtes a binary adjacency matrix for a mesh.
- Returns
binary adjacency matrix
- Return type
Example
>>> mesh = TriangleMesh.from_obj('model.obj') >>> adj_info = mesh.compute_adjacency_matrix_full() >>> neighborhood_sum = torch.mm( adj_info, mesh.vertices)
-
compute_adjacency_matrix_sparse
()[source]¶ Calcualtes a sparse adjacency matrix for a mess
- Returns
sparse adjacency matrix
- Return type
(torch.sparse.Tensor)
Example
>>> mesh = Mesh.from_obj('model.obj') >>> adj_info = mesh.compute_adjacency_matrix_sparse() >>> neighborhood_sum = torch.sparse.mm(adj_info, mesh.vertices)
-
load_tensors
(enable_adjacency: bool = False)[source]¶ Loads the tensor information of the mesh from a saved numpy array.
- Parameters
filename – Path of the file to load the file from.
Example
>>> mesh = TriangleMesh.load_tensors('mesh.npy')
-
sample
(num_samples: int, eps: float = 1e-10)[source]¶ Uniformly samples the surface of a mesh.
- Parameters
- Returns
- (torch.Tensor, torch.Tensor) uniformly sampled points and
the face idexes which each point corresponds to.
Example
>>> points, chosen_faces = mesh.sample(10) >>> points tensor([[ 0.0293, 0.2179, 0.2168], [ 0.2003, -0.3367, 0.2187], [ 0.2152, -0.0943, 0.1907], [-0.1852, 0.1686, -0.0522], [-0.2167, 0.3171, 0.0737], [ 0.2219, -0.0289, 0.1531], [ 0.2217, -0.0115, 0.1247], [-0.1400, 0.0364, -0.1618], [ 0.0658, -0.0310, -0.2198], [ 0.1926, -0.1867, -0.2153]]) >>> chosen_faces tensor([ 953, 38, 6, 3480, 563, 393, 395, 3309, 373, 271])
-