Skip to content

Commit 90d00f1

Browse files
bottlerfacebook-github-bot
authored andcommitted
PLY heterogenous faces fix
Summary: PLY with mixture of triangle and quadrilateral faces was failing. Reviewed By: gkioxari Differential Revision: D36592981 fbshipit-source-id: 5373edb2f38389ac646a75fd2e1fa7300eb8d054
1 parent d27ef14 commit 90d00f1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pytorch3d/io/ply_io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ def _load_ply(f, *, path_manager: PathManager) -> _PlyData:
10431043
faces = torch.LongTensor(np.vstack(face_arrays).astype(np.int64))
10441044
else:
10451045
face_list = []
1046-
for face_item in face:
1046+
for (face_item,) in face:
10471047
if face_item.ndim != 1:
10481048
raise ValueError("Bad face data.")
10491049
if face_item.shape[0] < 3:

tests/test_io_ply.py

+9
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,15 @@ def test_pluggable_load_cube(self):
195195
):
196196
io.load_mesh(f3.name)
197197

198+
def test_heterogenous_verts_per_face(self):
199+
# The cube but where one face is pentagon not square.
200+
text = CUBE_PLY_LINES.copy()
201+
text[-1] = "5 3 7 4 0 1"
202+
stream = StringIO("\n".join(text))
203+
verts, faces = load_ply(stream)
204+
self.assertEqual(verts.shape, (8, 3))
205+
self.assertEqual(faces.shape, (13, 3))
206+
198207
def test_save_too_many_colors(self):
199208
verts = torch.tensor(
200209
[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0]], dtype=torch.float32

0 commit comments

Comments
 (0)