Alternative type names in PLY #205

Summary: Add ability to decode ply files which use types like int32.

Reviewed By: nikhilaravi

Differential Revision: D21639208

fbshipit-source-id: 0ede7d4aa353a6e940446680a18e7ac0c48fafee
This commit is contained in:
Jeremy Reizenstein 2020-05-20 01:11:39 -07:00 committed by Facebook GitHub Bot
parent b4fd9d1d34
commit f2d1d2db69
2 changed files with 11 additions and 3 deletions

View File

@ -26,6 +26,14 @@ _PLY_TYPES = {
"uint": _PlyTypeData(4, "I", np.uint32), "uint": _PlyTypeData(4, "I", np.uint32),
"float": _PlyTypeData(4, "f", np.float32), "float": _PlyTypeData(4, "f", np.float32),
"double": _PlyTypeData(8, "d", np.float64), "double": _PlyTypeData(8, "d", np.float64),
"int8": _PlyTypeData(1, "b", np.byte),
"uint8": _PlyTypeData(1, "B", np.ubyte),
"int16": _PlyTypeData(2, "h", np.short),
"uint16": _PlyTypeData(2, "H", np.ushort),
"int32": _PlyTypeData(4, "i", np.int32),
"uint32": _PlyTypeData(4, "I", np.uint32),
"float32": _PlyTypeData(4, "f", np.float32),
"float64": _PlyTypeData(8, "d", np.float64),
} }
_Property = namedtuple("_Property", "name data_type list_size_type") _Property = namedtuple("_Property", "name data_type list_size_type")
@ -84,9 +92,9 @@ class _PlyElementType:
""" """
if not self.is_fixed_size(): if not self.is_fixed_size():
return False return False
first_type = self.properties[0].data_type first_type = _PLY_TYPES[self.properties[0].data_type]
for property in self.properties: for property in self.properties:
if property.data_type != first_type: if _PLY_TYPES[property.data_type] != first_type:
return False return False
return True return True

View File

@ -284,7 +284,7 @@ class TestMeshPlyIO(TestCaseMixin, unittest.TestCase):
format, format,
"element vertex 8", "element vertex 8",
"property float x", "property float x",
"property float y", "property float32 y",
"property float z", "property float z",
"element vertex1 8", "element vertex1 8",
"property float x", "property float x",