-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature/additional geometry file export methods #225
Feature/additional geometry file export methods #225
Conversation
Planning to start drafting some tests tomorrow. |
for more information, see https://pre-commit.ci
In a conversation offline, @janbridley suggested putting this functionality in a separate file, rather than attaching it via methods to the Currently, the implementation only works for polyhedrons, because it requires explicitly defined vertices and faces. If we put export functions into a separate file, it may be reasonable to allow them to accept any subclass of |
As a simpler alternative, we could have the export code in a separate file that is called as a |
pre-commit.ci autofix |
for f in shape.faces: | ||
# Decompose face into triangles | ||
# ref: https://stackoverflow.com/a/66586936/15426433 | ||
triangles = [[vs[f[0]], vs[b], vs[c]] for b, c in zip(f[1:], f[2:])] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice little snippet
for more information, see https://pre-commit.ci
coxeter/io.py
Outdated
coordinate_indices.insert(len(f) + prev_index, -1) | ||
prev_index += len(f) + 1 | ||
|
||
coordinate_points = [v for f in shape.faces for i in f for v in shape.vertices[i]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider rewriting this with numpy functions - ravel, etc. Should be possible to simplify!
for more information, see https://pre-commit.ci
5415ab4
to
fa10da7
Compare
fa10da7
to
6e28a64
Compare
121f496
to
f260fd2
Compare
af49d65
to
d8b7726
Compare
for more information, see https://pre-commit.ci
@janbridley all the tests are now passing, thanks to @joaander 's help. As the code currently stands, we would need to re-generate the control files with every version release, since the export functions include the coxeter version number in some of the files. There's an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you for this
It should be fairly simple to automate running that file with the CI. I'll add this in the next release PR. I think the comparison function is good for now, and we can always replace the contents of that function in the future for more detailed/version-agnostic feedback. |
Description
I have added a some methods to the
shapes.Polyhedron
class to allow users to export 3D geometry to a handful of common file formats. None of these methods introduce additional dependencies. The following file formats would be supported:.obj
Wavefront OBJ.off
Object File Format.stl
Stereolithography.ply
Polygon File Format.x3d
Extensible 3D.vtk
Legacy VTK.html
HTML (embedded X3D in a simple HTML document)Note: this is a DRAFT PULL REQUEST. With input from other collaborators, I may still make significant changes to the new methods.
Motivation and Context
This change could make it significantly easier for users to visualize their geometries and export them for rendering and other publication-related tasks. Currently, users have to hack together their own export functions if they want to export their geometries to, say, blender.
Types of Changes
1The change breaks (or has the potential to break) existing functionality.
Checklist: