mikedh / trimesh

Python library for loading and using triangular meshes.
https://trimesh.org
MIT License
3.02k stars 583 forks source link

Integration with manifold3d #2318

Open pca006132 opened 2 weeks ago

pca006132 commented 2 weeks ago

Some users (of manifold3d) asked if manifold3d can provide methods for import/export meshes using trimesh. However, we are not sure how optional dependencies work in trimesh, as well as how cyclic dependencies work (because trimesh also depends on manifold3d). I wonder if we can have functions in trimesh that convert a mesh to manifold3d mesh and reverse?

We already have a simple implementation of that: https://colab.research.google.com/drive/1VxrFYHPSHZgUbl9TeWzCeovlpXrPQ5J5?usp=sharing, the main problem is where this code should go to.

ping @elalish.

mikedh commented 2 weeks ago

Nice!! Yeah I think that makes total sense and happy to help!

However, we are not sure how optional dependencies work in trimesh

So the base dependencies pulled in by pip install trimesh is just numpy, which lets you do most things you'd want, and adding bare trimesh as a dep here would be easy.

as well as how cyclic dependencies work (because trimesh also depends on manifold3d)

So pip install trimesh[easy] does pull in manifold3d. I also am not all that sure how the pip resolver deals with a circular but seemingly resolvable dependency in an extra.

I think the case to check would be to add trimesh to a manifold dependency (maybe as a .rc0 prerelease for testing?), and then see if pip install --pre trimesh[easy] manifold3d does anything disastrous? My reading of the relevant document is that it seems like this should work? Happy to play with the dependency in trimesh too if that's necessary.

pca006132 commented 4 days ago

Sorry for the delay, I was busy working on the v3.0 release for manifold. Now that the package is released I finally have more time to come back and look at this. (and let you know the dependency can be updated!)

I'm thinking if it will be simpler if we add trimesh.exchange.manifold3d, and make trimesh.load/trimesh.export work with manifold3d object. Not sure if load and export will be the correct APIs here, considering they work with files instead of 3rd-party objects. Adding to trimesh simplifies the dependency issue because trimesh already (optionally) depends on manifold3d.