Open benmkw opened 3 years ago
Thanks for opening this issue. This looks like a bug to me, b/c this library uses Manifold DC, which is an extension to DC that guarantees water tight meshes.
I can for now confirm that the mesh from the sphere sample does look like it's not a 2D manifold.
I tried to cleanup this mesh, exported as OBJ in Wings3D, and got a crash. From almost 20 years of experience with Wings3D I can say that this app is one of the most lenient ones in dealing with non-manifold topologies. Which suggests something is pretty bad.
In my fork I added the sample from the docs to an examples
folder which creates below mesh.
Here is an image from within Wings3D. I selected the three bad quads that are somehow weirdly connected to the rest of the mesh:
Thanks for looking into this in more detail. And thanks for the screenshot. It looks like indeed there is some lingering bug in the meshing. How much post processing was applied to above mesh? I'm asking b/c it looks like the some of the faces (e.g. the two large faces close to the top) seem to be 5-gons. And I wonder how this algorithm could possibly have produced those.
If somehow possible we should try to reduce this buggy example to an even simpler one and then try to find the step where things go wrong. One thing we can do for debugging is to disable subsample_octtree(), which tries to simplify the vertex structure by merging vertices that are within some error margin.
The above mesh has zero post processing. But what Wings3D does, on import, is turn the mesh into a 2D manifold. I.e. it may delete some non-manifold topological features locally and that may have caused this.
I added https://github.com/hmeyer/tessellation/commit/47fe5c2fe51e4e24b5104a1293a3cfe0b0fc642d, which exposes this bug. It also shows this bug seems to happen in the simplification step (as it is not triggered, when simplification is turned off).
Wonderful that I found a impl of Manifold dual contouring in Rust, I also know of another impl that under the hood uses a machine translated C -> Unsafe Rust version.
I'm working on some 3D stuff which would need this feature. Do we have an idea where the bug may lie?
This one has a impl in C#
https://github.com/Lin20/isosurface
This one is also in rust, but the dual contouring SVD/QEF solver was machine ported from C to unsafe Rust
I'm currently banging out a hashed linear octree.
Using the sphere example from the readme I get the following result (tried a few variations of parameters but with basically the same results):
I'm wondering if this is intended or a user error on my side as truescad does not seem to have this issue.
https://www.researchgate.net/publication/310783747_Watertight_and_2-manifold_Surface_Meshes_Using_Dual_Contouring_with_Tetrahedral_Decomposition_of_Grid_Cubes
seems to indicate that this may be limitation of the algorithm?