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

Support STL #594

Merged
merged 3 commits into from May 17, 2022
Merged

Support STL #594

merged 3 commits into from May 17, 2022

Conversation

chrisprice
Copy link
Contributor

Fixes #154

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, @chrisprice, looks excellent!

use std::path::Path;
use std::{fs::File, path::Path};

use anyhow::{anyhow, Result};
Copy link
Owner

Choose a reason for hiding this comment

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

Since fj-export is a library, thiserror would be a more appropriate choice here for error handling. Doesn't really matter though. Good enough for now!

Comment on lines +91 to +95
[
vector.x.into_f32(),
vector.y.into_f32(),
vector.z.into_f32(),
]
Copy link
Owner

Choose a reason for hiding this comment

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

This kind of code can be shortened a bit:

Suggested change
[
vector.x.into_f32(),
vector.y.into_f32(),
vector.z.into_f32(),
]
vector.components.map(|s| s.into_f32())

Not necessary, just noting the possibility.

Comment on lines +85 to +87
.map(|triangle: Triangle<3>| triangle.to_parry().normal())
.collect::<Option<Vec<_>>>()
.ok_or_else(|| anyhow!("Unable to compute normal"))?;
Copy link
Owner

Choose a reason for hiding this comment

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

Since fj_math::Triangle is validated on construction, we could add an infallible normal method to it, which would make this kind of code simpler. Or, as a more incremental step, thanks to that validation the anyhow! here can probably be replaced with an unreachable!.

Neither of those need to happen in this pull request though.

@hannobraun hannobraun merged commit 2aecf7c into hannobraun:main May 17, 2022
@hannobraun hannobraun changed the title Support emf Support STL May 23, 2022
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.

Export to STL
2 participants