tessellation icon indicating copy to clipboard operation
tessellation copied to clipboard

watertight triangulation?

Open benmkw opened this issue 5 years ago • 8 comments

Using the sphere example from the readme I get the following result (tried a few variations of parameters but with basically the same results):

Bildschirmfoto 2020-11-05 um 11 52 08

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

However, DC is unable to guarantee 2-manifold and watertight meshes due to the fact that it produces only one vertex for each grid cube. We present a modified Dual Contouring algorithm that is capable of overcoming this limitation.

seems to indicate that this may be limitation of the algorithm?

benmkw avatar Nov 05 '20 10:11 benmkw

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.

hmeyer avatar Nov 24 '20 06:11 hmeyer

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: Screen Shot 2020-11-27 at 21 00 51

virtualritz avatar Nov 27 '20 20:11 virtualritz

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.

hmeyer avatar Nov 30 '20 05:11 hmeyer

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.

virtualritz avatar Jan 03 '21 15:01 virtualritz

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).

hmeyer avatar Jan 03 '21 17:01 hmeyer

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?

DanielJoyce avatar Nov 08 '23 00:11 DanielJoyce

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

https://github.com/swiftcoder/isosurface

DanielJoyce avatar Nov 08 '23 00:11 DanielJoyce

I'm currently banging out a hashed linear octree.

DanielJoyce avatar Nov 08 '23 00:11 DanielJoyce