11import numpy as np
22
33from .. import util
4+ from ..typed import Dict , Stream
45
56
67class HeaderError (Exception ):
@@ -19,22 +20,20 @@ class HeaderError(Exception):
1920_stl_dtype_header = np .dtype ([("header" , np .void , 80 ), ("face_count" , "<u4" )])
2021
2122
22- def load_stl (file_obj , ** kwargs ):
23+ def load_stl (file_obj : Stream , ** kwargs ) -> Dict :
2324 """
24- Load an STL file from a file object.
25+ Load a binary or an ASCII STL file from a file object.
2526
2627 Parameters
2728 ----------
28- file_obj : open file-like object
29+ file_obj
2930 Containing STL data
3031
3132 Returns
3233 ----------
33- loaded : dict
34- kwargs for a Trimesh constructor with keys:
35- vertices: (n,3) float, vertices
36- faces: (m,3) int, indexes of vertices
37- face_normals: (m,3) float, normal vector of each face
34+ loaded
35+ Keyword arguments for a Trimesh constructor with
36+ data loaded into properly shaped numpy arrays.
3837 """
3938 # save start of file obj
4039 file_pos = file_obj .tell ()
@@ -53,7 +52,7 @@ def load_stl(file_obj, **kwargs):
5352 return load_stl_ascii (file_obj )
5453
5554
56- def load_stl_binary (file_obj ) :
55+ def load_stl_binary (file_obj : Stream ) -> Dict :
5756 """
5857 Load a binary STL file from a file object.
5958
@@ -64,10 +63,9 @@ def load_stl_binary(file_obj):
6463
6564 Returns
6665 ----------
67- loaded: kwargs for a Trimesh constructor with keys:
68- vertices: (n,3) float, vertices
69- faces: (m,3) int, indexes of vertices
70- face_normals: (m,3) float, normal vector of each face
66+ loaded
67+ Keyword arguments for a Trimesh constructor with data
68+ loaded into properly shaped numpy arrays.
7169 """
7270 # the header is always 84 bytes long, we just reference the dtype.itemsize
7371 # to be explicit about where that magical number comes from
@@ -136,7 +134,7 @@ def load_stl_binary(file_obj):
136134 return result
137135
138136
139- def load_stl_ascii (file_obj ) :
137+ def load_stl_ascii (file_obj : Stream ) -> Dict :
140138 """
141139 Load an ASCII STL file from a file object.
142140
@@ -147,11 +145,9 @@ def load_stl_ascii(file_obj):
147145
148146 Returns
149147 ----------
150- loaded : dict
151- kwargs for a Trimesh constructor with keys:
152- vertices: (n, 3) float, vertices
153- faces: (m, 3) int, indexes of vertices
154- face_normals: (m, 3) float, normal vector of each face
148+ loaded
149+ Keyword arguments for a Trimesh constructor with
150+ data loaded into properly shaped numpy arrays.
155151 """
156152
157153 # read all text into one string
0 commit comments