Skip to content

Commit

Permalink
add fallback for MetaMesh
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer authored and SimonDanisch committed Oct 17, 2024
1 parent 1d1dd5c commit b91e5c5
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/basic_recipes/mesh.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
function plot!(p::Mesh{<: Tuple{<: GeometryBasics.MetaMesh}})
metamesh = p[1][]
meshes = GeometryBasics.split_mesh(metamesh.mesh)

if !haskey(metamesh, :material_names) || !haskey(metamesh, :materials)
@error "The given mesh has no :material_names or :materials. Drawing without material information."
for (i, m) in enumerate(meshes)
attr = Attributes()
# Differentiate colors?
attr[:color] = i
attr[:colorrange] = (1, length(meshes))

for k in Makie.attribute_names(Makie.Mesh)
get!(attr, k, map(identity, p.attributes[k]))
end

mesh!(p, attr, m)
end

return p
end

names = metamesh[:material_names]

for (name, m) in zip(names, meshes)
Expand Down Expand Up @@ -46,10 +65,10 @@ function plot!(p::Mesh{<: Tuple{<: GeometryBasics.MetaMesh}})
end

for k in Makie.attribute_names(Makie.Mesh)
get!(attr, k, p.attributes[k])
get!(attr, k, map(identity, p.attributes[k]))
end

plt = mesh!(p, attr, m)
mesh!(p, attr, m)
end

return p
Expand Down

0 comments on commit b91e5c5

Please sign in to comment.