mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-08-02 03:42:50 +08:00
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
This commit is contained in:
parent
d27ef14ec7
commit
90d00f1b2b
@ -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:
|
||||
|
@ -195,6 +195,15 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase):
|
||||
):
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user