Skip to content

Commit 098d744

Browse files
authored
Fix/forward kwargs (#2346)
With the pull-request #2241, `load_mesh` does not respect the parameter `process` anymore. With this pull-request, the `kwargs` are being forwarded in `load_stl`.
2 parents a046c7a + a6f33d8 commit 098d744

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

tests/test_loaded.py

+12
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ def test_meshio(self):
3131
assert len(m.faces) > 0
3232
assert m.area > 1e-5
3333

34+
def test_load_mesh(self):
35+
# test the influence of the parameter `process` for `load_mesh`
36+
with open(g.os.path.join(g.dir_models, "featuretype.STL"), "rb") as file_obj:
37+
mesh = g.trimesh.load_mesh(file_obj=file_obj, file_type="stl", process=False)
38+
# check that number of vertices is not being reduced
39+
assert len(mesh.vertices) == 10428
40+
41+
with open(g.os.path.join(g.dir_models, "featuretype.STL"), "rb") as file_obj:
42+
mesh = g.trimesh.load_mesh(file_obj=file_obj, file_type="stl", process=True)
43+
# check that number of vertices is being reduced
44+
assert len(mesh.vertices) == 1722
45+
3446
def test_fileobj(self):
3547
# make sure we don't close file objects that were passed
3648
# check load_mesh

trimesh/exchange/stl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ def load_stl(file_obj, **kwargs):
4343
# if that is true, it is almost certainly a binary STL file
4444
# if the header doesn't match the file length a HeaderError will be
4545
# raised
46-
return load_stl_binary(file_obj)
46+
return {**load_stl_binary(file_obj), **kwargs}
4747
except HeaderError:
4848
# move the file back to where it was initially
4949
file_obj.seek(file_pos)
5050
# try to load the file as an ASCII STL
5151
# if the header doesn't match the file length
5252
# HeaderError will be raised
53-
return load_stl_ascii(file_obj)
53+
return {**load_stl_ascii(file_obj), **kwargs}
5454

5555

5656
def load_stl_binary(file_obj):

0 commit comments

Comments
 (0)