HxSTLParser icon indicating copy to clipboard operation
HxSTLParser copied to clipboard

Binary STL support

Open tanqci opened this issue 7 years ago • 4 comments

Your project is wonderful!

As I know, stl file have Binary and Ascii two type , does your parser support both of them?

tanqci avatar Oct 14 '17 07:10 tanqci

Glad to know it is useful for someone else. Currently, this library only supports ASCII-based STL files, although the binary version can be easily implemented using a simple finite state machine.

I'll try to add support to the binary format in the next week or so.

heyvito avatar Oct 14 '17 17:10 heyvito

Here too: cudos on the project!

I was wondering if there's anything we can do to help with the binary format? Cheers, EP

epologee avatar Nov 03 '17 13:11 epologee

Hi @epologee! Sorry taking so long to answer your question.

Implementing the binary format should be quite straightforward, and you can even reuse the current implementation. A simple finite state machine should be enough to parse the structure documented here and here. After reading the normal vector, vertexes, and discarding any defined attributes1, it would then just be a matter of instantiating SCNVector3s and dealing with SceneKit's oddities (SCNGeometrySource & friends).

Sadly I don't have enough time to work on this right now. PRs are super welcome! ✨

Best wishes!

[1] - No one should be using it, but we might want to be extra-cautious with binary formats.

heyvito avatar Nov 05 '17 16:11 heyvito

Thanks for the links, @victorgama! The binary STL spec looks easier than the ascii one :)

I can't really make a PR on your repository, because I decided to parse the binary STL with Swift. Your HxSTLParser code was very essential in recreating this with Swift, even though I didn't go the state machine way for simplicity. Let me at least share it here, so maybe @tanqci can benefit from it as well:

https://gist.github.com/epologee/7373ea371812e8facd5a7a00e6b80d70

epologee avatar Nov 08 '17 11:11 epologee