Plot mesh with a ill-oriented triangle crashes the Julia session
stla opened this issue · comments
Hello,
Here is a mesh with a ill-oriented triangle:
v1 = [1, 0, 0]
v2 = [0, 1, 0]
v3 = [0, 0, 1]
m12 = [0.5, 0.5, 0]
m13 = [0.5, 0, 0.5]
m23 = [0, 0.5, 0.5]
mesh = SimpleMesh(
Meshes.Point.([v1, v2, v3, m12, m13, m23]),
Meshes.connect.([(4,1,5), (2,6,4), (3,5,6), (4,5,6)], Meshes.Triangle)
)
viz(mesh)
First, the plot is strange: we see a shadowed triangle with two vertices that do not belong to the vertices of the mesh:
Now, viz(mesh; showfacets=true)
crashes the Julia session. I'm using the latest versions of Meshes.jl and MeshViz.jl.
Did you find any way to get an error message?
I think we have two issues in this case:
-
A residual issue of #30. I remember changing the algorithm in the HalfEdgeTopology to reorient the triangles whenever they had inconsistent orientation. However, I just realized that the new algorithm still has a bug when triangles are fed in arbitrary order. I will try to fix it in Meshes.jl over the week.
-
The other issue seems to exist in Makie.jl itself. Feeding triangles with incosistent orientation leads to a visualization that is not expected even if we disregard the normals pointing to different sides of the parent triangle.
This is the part of the algorithm that needs to be adjusted:
It fails if the triangles (i.e. elems) are traversed in arbitrary order. All examples we have in our test suite traverse the mesh in geometric order (i.e. top left to bottom right)
And I forgot to say there's also a crash if there's a face like (1, 2, 1)
.
And I forgot to say there's also a crash if there's a face like
(1, 2, 1)
.
Yes, we don't want to support such degenerate faces, at least for now.