Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normal_mesh based visualisation not valid. #34

Open
Kevin-Mattheus-Moerman opened this issue Dec 20, 2023 · 0 comments
Open

normal_mesh based visualisation not valid. #34

Kevin-Mattheus-Moerman opened this issue Dec 20, 2023 · 0 comments

Comments

@Kevin-Mattheus-Moerman
Copy link
Contributor

Kevin-Mattheus-Moerman commented Dec 20, 2023

The example in the README contains something like:

mesh!(ax1,normal_mesh(result),color=:blue, transparency=false, overdraw=false,shading = FastShading)

Where use is made of normal_mesh. However this function does not correctly obtain the triangles.

Below is my first attempt at fixing this, i.e. to get the tetrahedra and then to create a face based mesh representation to correctly visualise the tetrahedral mesh.

function tetgen2facemesh(result)
    E = faces(result) # Called "faces" but these are tetrahedral elements really 
    V = coordinates(result)

    F = Vector{TriangleFace{Int64}}(undef,length(E)*4)
    for q = eachindex(E)
        e = E[q]
        qf = 1 + (q-1)*4
        F[qf] = TriangleFace{Int64}(e[1],e[2],e[3])
        F[qf+1] = TriangleFace{Int64}(e[1],e[2],e[4])
        F[qf+2] = TriangleFace{Int64}(e[2],e[3],e[4])
        F[qf+3] = TriangleFace{Int64}(e[3],e[1],e[4])
    end

    return GeometryBasics.Mesh(V,F)
end

M = tetgen2facemesh(result)

# N,VN=meshnormal(M)

#Visualize mesh
GLMakie.activate!(inline=false) # To avoid plotting in plotpane as per: https://github.com/MakieOrg/Makie.jl/issues/2956
fig = Figure()

ax1=Axis3(fig[1, 1], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Using normal_mesh")
mesh!(ax1,normal_mesh(result),color=:blue, transparency=false, overdraw=false,shading = FastShading)
wireframe!(result, linewidth=5,  color=:black)

ax2=Axis3(fig[1, 2], aspect = :data, xlabel = "X", ylabel = "Y", zlabel = "Z", title = "Proper conversion to faces")
poly!(ax2,M,strokewidth=5, color=:blue, transparency=false, overdraw=false,shading = FastShading)
# arrows!(ax2,VN,N)


fig

My guess is that normal_mesh does not create all 4 tetrahedron triangles. The below shows the issue, i.e. several "holes" exist in the mesh (sorry hard to see as shading for these is a mess too... not sure how to fix that @SimonDanisch) and the bottom corner for instance clearly misses triangles. The visualisation on the right is for my "fixed" visualisation using the above.

Screenshot from 2023-12-20 12-39-57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant