Imlementations of Java Bindings, Convex Hulls (2D/3D), Partial Revolve, Polyhedron #443
Replies: 2 comments
-
Thank you, that's amazing! Let's start with a PR for the partial revolve - that sounds like a simple win. My trepidation with polyhedra is what to do when the faces aren't planar; how do you tend to use them? I would definitely like to have a convex hull function here, but only if it's reliable. I wonder what the trouble is with qhull and manifolds? If we can't make it work, it'd probably be worth re-implementing from an ε-valid perspective. As for Java bindings, your library looks great. Personally, I hate Java, but I also haven't used it enough to really have a serious opinion 😁. Anyway, @geoffder convinced me to include C bindings (even though I also hate C) by promising to upkeep them here, so I'm open to that option as well. |
Beta Was this translation helpful? Give feedback.
-
Awesome, I'll get to work on that partial revolve PR as soon as I get the chance. I'm happy to wait on the other ones for now. If there starts to be any appreciable demand for the JNI bindings, maybe we can take another look at merging it. I am willing to commit to maintaining it. I'm not much of a Java guy either, but I am a unrepentant lisp fiend and Clojure is still the most usable lisp right now. Plus I've come to value the extreme stability of the JVM. I do feel bad about my feeble bindings the the beauty that is the GLM library though. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I recently wrote Javacpp bindings to Manifold and extended/tweaked the library in my fork to support convex hulls (2D and 3D) via.a qhull, partial revolutions, and polyhedrons. I also quickly extended the JS bindings to support CrossSection (which I see now there's another PR for). You can see the changes here:
master...SovereignShop:manifold:master
I'm currently migrating my personal projects which use Clojure to generate OpenSCAD, so I decided to just implement everything I needed to make the migration trivial. That library is here:
https://github.com/SovereignShop/clj-manifold3d
I understand little or none of these changes are likely to be something you'd be interested in including in Manifold. But if there's parts of it you think would be worth integrating, I'd be happy to open a pull request with clean commits. The JNI bindings could be added as essentially just another /java directory under bindings. If not I'll likely make it a totally independent repo.
The support for partial revolve I think would be nice to have in Manifold. I just tweaked the implementation to take a revolveDegrees parameter (defaults to 360). It Just adds front and back faces in the case of less than a full revolution, plus instead of the special case it just takes the x>0 slice if the bounding box has negative vertices and applies the revolve to that.
The polyhedron implementation simply calls manifold::Triangulate on the 2D projection of each face (with n>3 vertices) onto its plane then remaps the result. I also used polyhedron extensively in OpenSCAD. So far it has worked fine, but like most of the code it would probably need further testing. Plus I'm not sure what to do about the "precision" parameter.
The Convex Hull implementations are probably less than ideal. They just call out to qhull, which I build as another submodule. Unfortunately it does not produce valid 2-manifolds, but thankfully it's pretty easy to fix-up the mesh as the result is obviously convex. I happen to use Convex Hull extensively, so it's a must-have for me. So far it has worked well. But there are some issues: It's a C lib, primitive type (float or double) is a compile time flag, and it doesn't seem to consistently orient faces by default, nor does it sanely order 2D vertices. Some of these problems may be user error on my part.
The JS changes are mostly a for-fun experiment in supporting code-compatibility between JVM Clojure & ClojureScript. It does work, but it sure is annoying dealing with libraries provided as promises.
Anyway, thanks for creating this library! It's a total game-changer in the world of programmatic CAD.
Beta Was this translation helpful? Give feedback.
All reactions