vagran / dxf-viewer

DXF 2D viewer written in JavaScript
Mozilla Public License 2.0
290 stars 86 forks source link

Add missing indices when decomposing faces #74

Open MPanknin opened 1 year ago

MPanknin commented 1 year ago

Hi again,

we would like to suggest a small change in the decomposition of faces. In some dxf files we experienced minor rendering artifacts because the surfaces were not closed properly.

UI Before: before

After: after

Thx

vagran commented 1 year ago

Hi, This fix does not look valid. What you do is adding third triangle, so ending up with three overlapping triangles (you can check resulting topology with sceneOptions.wireframeMesh option set to true). Instead it should be investigated, how to ensure proper quad decomposition into two triangles. I have already faced similar problems and tried to modify decomposition algorithm to cover all cases, but seems it is still not robust enough for a wild files. DXF does not specify vertices order of a quad, seems it may be completely arbitrary. It would be nice to have a sample file to properly fix this issue.

MPanknin commented 1 year ago

We did not check the resulting mesh topology, to be honest, because this solution simply works in our use case.

It would be nice to have a sample file to properly fix this issue.

I will see if I can find one that exhibits this behavior if that would help?

vagran commented 1 year ago

I will see if I can find one that exhibits this behavior if that would help?

Yes, that will definitely help to find proper solution.