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

Added 2d generate support and mesh.show() previews based on matplotlib and vtkplotlib #27

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colinthart
Copy link

Added support for generate() to SDF2 based on scikit-image measure.fnd_contours(). Added show() to mesh.py using matplotlib for SDF2 and numpy-stl and vtkplotlib for SDF3. Note: vtkplotlib uses numpy-stl as a dependency.

Comments:
In order for generate and plot to determine the correct behavior, the dimension of sdf needs to be determined. My original approach was to use isinstance(sdf, SDF2) and isinstance(sdf, SDF3) but this created a circular dependency. I added a dimension parameter self.dim to each class that is used for checking.

The stl import in show() is for numpy-stl. I realize this might cause confusion with the existing sdf.stl so I call attention to it here.

I did not implement SDF2 save(). The analogous output to stl might be csv. Pandas may be provide similar flexibility for 2D tabular output files as what can be achieved for 3D meshes with meshio, or meshio may still be the appropriate choice for 2D.

I noticed some strange behavior with the union command. The union() of two SDF2 objects is promoted to SDF3 but the same operation using the overloaded or operator produces an SDF2 object. More testing on SDF2 objects would be useful.

I added three examples demonstrating the new features.

This is my first pull request so I'd be interested to know what your thoughts are. In general this is a great library to work with.
Thanks for sharing!

…nd_contours(). Added show() to mesh.py using matplotlib for SDF2 and numpy-stl and vtkplotlib for SDF3. Note: vtkplotlib uses numpy-stl as a dependency.
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.

2 participants