Skip to content

mesh fails on quadrilateral mesh #1677

@BambOoxX

Description

@BambOoxX

It seems Makie assumes that a mesh should have triangular elements.

On the example below Makie (v0.5.1) works fine with triangular faces.

using GLMakie

u1 = LinRange(0, 2 * pi, 100) .* ones(100)'
v1 = LinRange(0, 2 * pi, 100)' .* ones(100)
u2 = cos.(u1) .* sin.(v1)

nl, nc = size(u1)

vertices = hcat(vec(u1), vec(v1), vec(u2))

v = collect(1:(nl-1))

faces = Matrix{Int64}(undef, (nl - 1) * (nc - 1), 3)
for c in 0:(nc-2)
    for (index, vval) in enumerate(v)
        faces[index+c*(nl-1), :] = [vval vval + 1 vval + nl + 1] .+ c * (nl)
    end
end

msh = mesh(vertices, faces, color = vec(u2), shading = false, axis = (type=Axis3,))
wireframe!(msh.axis, msh.plot[1][], color = :black)

image

If the triangular faces are replaced with quadrangular ones, Makie fails on a to_triangles. Is there a specific reason why ?
Code with quadrangular faces

using GLMakie

u1 = LinRange(0, 2 * pi, 100) .* ones(100)'
v1 = LinRange(0, 2 * pi, 100)' .* ones(100)
u2 = cos.(u1) .* sin.(v1)

nl, nc = size(u1)

vertices = hcat(vec(u1), vec(v1), vec(u2))

v = collect(1:(nl-1))

faces = Matrix{Int64}(undef, (nl - 1) * (nc - 1), 4)
for c in 0:(nc-2)
    for (index, vval) in enumerate(v)
        faces[index+c*(nl-1), :] = [vval vval + 1 vval + nl + 1 vval + nl] .+ c * (nl)
    end
end

msh = mesh(vertices, faces, color = vec(u2), shading = false, axis = (type=Axis3,))
wireframe!(msh.axis, msh.plot[1][], color = :black)

Metadata

Metadata

Assignees

No one assigned

    Labels

    MakieBackend independent issues (Makie core)conversionsMainly `convert_arguments`enhancementFeature requests and enhancementsgood first issueThis should come with some instructions!mesh(and poly)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions