Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize export functions and make them public #2252

Merged
merged 1 commit into from Mar 5, 2024

Conversation

IamTheCarl
Copy link
Sponsor Contributor

Exposes export functions for specific mesh formats and generalizes them to write to objects that implement Write (except for 3MF which needs the target to implement both Write and Seek).

Copy link
Owner

@hannobraun hannobraun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @IamTheCarl, looks good!

except for 3MF which needs the target to implement both Write and Seek

I wonder why that is, and if that's a real requirement. Maybe it's just a weird leftover from an earlier version. Don't know!

@hannobraun hannobraun merged commit 82a90cb into hannobraun:main Mar 5, 2024
4 checks passed
@IamTheCarl
Copy link
Sponsor Contributor Author

I wondered that too so I gave the source code a quick peruse (I would have updated the ThreeMF library if it looked like an easy fix)

ThreeMF uses the Zip crate to produce the 3MF file.
ZipWriter expects an object that is both Write and Seek
ZipWriter uses the seek functionality of the writer multiple times during the finalization process.

This isn't a big problem for me though. I can just output the 3MF to a tempfile before I send it to stdout, in the rare case that someone wants to pipe a 3MF file to stdout. The only situation I can see that being useful in is if someone wanted to automatically pipe a model into a slicer without an intermediate file to clean up later, which is actually something I can see myself doing.

@hannobraun
Copy link
Owner

That makes sense. Thank you for looking into it!

This isn't a big problem for me though. I can just output the 3MF to a tempfile before I send it to stdout, in the rare case that someone wants to pipe a 3MF file to stdout. The only situation I can see that being useful in is if someone wanted to automatically pipe a model into a slicer without an intermediate file to clean up later, which is actually something I can see myself doing.

You actually don't need to go through a file. You can use Cursor to do everything in-memory.

@IamTheCarl
Copy link
Sponsor Contributor Author

I did consider that but my concern is how much memory do I need? I'm probably being paranoid (thanks to my embedded background) but a spooled temp file is the best of both worlds and easy to use: https://docs.rs/tempfile/3.10.1/tempfile/struct.SpooledTempFile.html

@hannobraun
Copy link
Owner

Ah, okay. I just mentioned it in case you're not aware. SpooledTempFile seems like a safe bet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants