apparentlymart / python-stl

Python library for parsing and producing STL files, in both ASCII and binary formats. No longer maintained.
MIT License
9 stars 13 forks source link

Implements reading a binary STL's header #3

Closed zachwick closed 9 years ago

zachwick commented 9 years ago

This PR is the same as #2, but it has an additional commit which fixes the tests.

apparentlymart commented 9 years ago

Thanks!

Are all binary STL files guaranteed to have this header, or does this code somehow handle the case where a header isn't present?

I did originally have binary STL files that had no header, but it's been a while and I forget which tool generated them. I usually work with OpenSCAD so it might well have been OpenSCAD output.

zachwick commented 9 years ago

It is my understanding that all binary STL files have an 80byte header; However, that header is supposed to be all null bytes in binary STLs, and only populated in non-conforming cases. (at least according to Wikipedia) The code in my patch will happily create a null string if the entire first 80 bytes of the binary STL file are all null. The actual book excerpt in which the STL file format was(is) defined can be read at http://www.ennex.com/~fabbers/StL.asp There is reads that for binary STLs, the header is to be 80 bytes of ASCII data that is just a header, and does not impact the actual data of the mesh.

apparentlymart commented 9 years ago

Seems reasonable to me. Thanks!