kaolin.rep.QuadMesh

class QuadMesh(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 Quad meshes.

compute_adjacency_matrix_full()[source]

calcualtes a binary adjacency matrix for a mesh

Returns

binary adjacency matrix

Return type

(torch.Tensor)

Example

>>> mesh = QuadMesh.from_obj('model.obj')
>>> adj_info = mesh.compute_adjacency_matrix_full()
>>> neighborhood_sum = torch.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 – the file name to load the file from.

Example

>>> mesh = QuadMesh.load_tensors('mesh.npy')
sample(num_samples: int)[source]

Uniformly samples the surface of a mesh.

Parameters

num_samples (int) – number of points to sample.

Returns

uniformly sampled points face_choices (torch.Tensor): the face idexes which each point

corresponds to.

Return type

points (torch.Tensor)

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])
save_mesh(filename)[source]

Save a mesh to a wavefront .obj file format

Parameters
  • filename (str) – target filename

  • verts (FloatTensor) – vertices of the mesh

  • faces (LongTensor) – list of vertex indexes for each face

Example

>>> verts, faces = load_obj('object.obj')
>>> verts = verts * 20
>>> save_mesh('larger_object.obj', verts, faces)