Skip to content

Commit f2d1d2d

Browse files
bottlerfacebook-github-bot
authored andcommitted
Alternative type names in PLY facebookresearch#205
Summary: Add ability to decode ply files which use types like int32. Reviewed By: nikhilaravi Differential Revision: D21639208 fbshipit-source-id: 0ede7d4aa353a6e940446680a18e7ac0c48fafee
1 parent b4fd9d1 commit f2d1d2d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

pytorch3d/io/ply_io.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
"uint": _PlyTypeData(4, "I", np.uint32),
2727
"float": _PlyTypeData(4, "f", np.float32),
2828
"double": _PlyTypeData(8, "d", np.float64),
29+
"int8": _PlyTypeData(1, "b", np.byte),
30+
"uint8": _PlyTypeData(1, "B", np.ubyte),
31+
"int16": _PlyTypeData(2, "h", np.short),
32+
"uint16": _PlyTypeData(2, "H", np.ushort),
33+
"int32": _PlyTypeData(4, "i", np.int32),
34+
"uint32": _PlyTypeData(4, "I", np.uint32),
35+
"float32": _PlyTypeData(4, "f", np.float32),
36+
"float64": _PlyTypeData(8, "d", np.float64),
2937
}
3038

3139
_Property = namedtuple("_Property", "name data_type list_size_type")
@@ -84,9 +92,9 @@ def is_constant_type_fixed_size(self) -> bool:
8492
"""
8593
if not self.is_fixed_size():
8694
return False
87-
first_type = self.properties[0].data_type
95+
first_type = _PLY_TYPES[self.properties[0].data_type]
8896
for property in self.properties:
89-
if property.data_type != first_type:
97+
if _PLY_TYPES[property.data_type] != first_type:
9098
return False
9199
return True
92100

tests/test_ply_io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def test_load_simple_binary(self):
284284
format,
285285
"element vertex 8",
286286
"property float x",
287-
"property float y",
287+
"property float32 y",
288288
"property float z",
289289
"element vertex1 8",
290290
"property float x",

0 commit comments

Comments
 (0)