diff options
Diffstat (limited to 'io_mesh_stl/stl_utils.py')
-rw-r--r-- | io_mesh_stl/stl_utils.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/io_mesh_stl/stl_utils.py b/io_mesh_stl/stl_utils.py index be4dc0a6..ded7d2c6 100644 --- a/io_mesh_stl/stl_utils.py +++ b/io_mesh_stl/stl_utils.py @@ -18,13 +18,13 @@ # <pep8 compliant> -''' +""" Import and export STL files Used as a blender script, it load all the stl files in the scene: blender --python stl_utils.py -- file1.stl file2.stl file3.stl ... -''' +""" import struct import mmap @@ -36,7 +36,7 @@ import itertools @contextlib.contextmanager def mmap_file(filename): - ''' + """ Context manager over the data of an mmap'ed file (Read ONLY). @@ -45,7 +45,7 @@ def mmap_file(filename): with mmap_file(filename) as m: m.read() print m[10:50] - ''' + """ with open(filename, 'rb') as file: # check http://bugs.python.org/issue8046 to have mmap context # manager fixed in python @@ -55,7 +55,7 @@ def mmap_file(filename): class ListDict(dict): - ''' + """ Set struct with order. You can: @@ -64,7 +64,7 @@ class ListDict(dict): Like collections.OrderedDict, but quicker, can be replaced if ODict is optimised. - ''' + """ def __init__(self): dict.__init__(self) @@ -72,9 +72,9 @@ class ListDict(dict): self._len = 0 def add(self, item): - ''' + """ Add a value to the Set, return its position in it. - ''' + """ value = self.setdefault(item, self._len) if value == self._len: self.list.append(item) @@ -92,13 +92,13 @@ def _header_version(): def _is_ascii_file(data): - ''' + """ This function returns True if the data represents an ASCII file. Please note that a False value does not necessary means that the data represents a binary file. It can be a (very *RARE* in real life, but can easily be forged) ascii file. - ''' + """ size = struct.unpack_from('<I', data, BINARY_HEADER)[0] return not data.size() == BINARY_HEADER + 4 + BINARY_STRIDE * size @@ -199,7 +199,7 @@ def _ascii_write(filename, faces): def write_stl(filename, faces, ascii=False): - ''' + """ Write a stl file from faces, filename @@ -210,12 +210,12 @@ def write_stl(filename, faces, ascii=False): ascii save the file in ascii format (very huge) - ''' + """ (_ascii_write if ascii else _binary_write)(filename, faces) def read_stl(filename): - ''' + """ Return the triangles and points of an stl binary file. Please note that this process can take lot of time if the file is @@ -238,7 +238,7 @@ def read_stl(filename): >>> >>> # print the coordinate of the triangle n >>> print(pts[i] for i in tris[n]) - ''' + """ tris, pts = [], ListDict() |