Skip to content

Commit

Permalink
PLY heterogenous faces fix
Browse files Browse the repository at this point in the history
Summary: PLY with mixture of triangle and quadrilateral faces was failing.

Reviewed By: gkioxari

Differential Revision: D36592981

fbshipit-source-id: 5373edb2f38389ac646a75fd2e1fa7300eb8d054
  • Loading branch information
bottler authored and facebook-github-bot committed May 24, 2022
1 parent d27ef14 commit 90d00f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pytorch3d/io/ply_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def _load_ply(f, *, path_manager: PathManager) -> _PlyData:
faces = torch.LongTensor(np.vstack(face_arrays).astype(np.int64))
else:
face_list = []
for face_item in face:
for (face_item,) in face:
if face_item.ndim != 1:
raise ValueError("Bad face data.")
if face_item.shape[0] < 3:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_io_ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ def test_pluggable_load_cube(self):
):
io.load_mesh(f3.name)

def test_heterogenous_verts_per_face(self):
# The cube but where one face is pentagon not square.
text = CUBE_PLY_LINES.copy()
text[-1] = "5 3 7 4 0 1"
stream = StringIO("\n".join(text))
verts, faces = load_ply(stream)
self.assertEqual(verts.shape, (8, 3))
self.assertEqual(faces.shape, (13, 3))

def test_save_too_many_colors(self):
verts = torch.tensor(
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0]], dtype=torch.float32
Expand Down

0 comments on commit 90d00f1

Please sign in to comment.