Source code for butterfly.stl


import ascii
import binary
from types import Solid, Facet, Vector3d


[docs]def read_ascii_file(file): """Read an STL file in the *ASCII* format. Takes a :py:class:`file`-like object (supporting a ``read`` method) and returns a :py:class:`stl.Solid` object representing the data from the file. If the file is invalid in any way, raises :py:class:`stl.ascii.SyntaxError`. """ return ascii.parse(file)
[docs]def read_binary_file(file): """Read an STL file in the *binary* format. Takes a :py:class:`file`-like object (supporting a ``read`` method) and returns a :py:class:`stl.Solid` object representing the data from the file. If the file is invalid in any way, raises :py:class:`stl.binary.FormatError`. """ return binary.parse(file)
[docs]def read_ascii_string(data): """Read geometry from a :py:class:`str` containing data in the STL *ASCII* format. This is just a wrapper around :py:func:`read_ascii_file` that first wraps the provided string in a :py:class:`StringIO.StringIO` object. """ from StringIO import StringIO return read_ascii_file(StringIO(data))
[docs]def read_binary_string(data): """Read geometry from a :py:class:`str` containing data in the STL *binary* format. This is just a wrapper around :py:func:`read_binary_file` that first wraps the provided string in a :py:class:`StringIO.StringIO` object. """ from StringIO import StringIO return read_binary_file(StringIO(data))