JuliaGeometry / MeshViz.jl

Makie.jl recipes for visualization of Meshes.jl

Home Page:https://github.com/JuliaGeometry/Meshes.jl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't visualize multiple meshes

cserteGT3 opened this issue · comments

I'm trying to visualize multiple meshes (for example multiple planes), but I can't do it, because it is not implemented (I suppose).
Is there any reason behind this?
What I found weird, that I can't do the same thing with Makie neither (mwes below, ran in new sessions). I'm on Windows 11, Julia version 1.8.4, and:

  [e9467ef8] GLMakie v0.8.1
  [9ecf9c4f] MeshViz v0.7.1
  [eacbb407] Meshes v0.26.6

MeshViz mwe:

using Meshes, MeshViz
import GLMakie

points = [(0,0,1), (1,0,0), (1,1,0), (0,1,1)]
connec = [connect((1,2,3)), connect((3,4,1))]
mesh = SimpleMesh(points, connec)
f = viz(mesh)
viz!(f, mesh)

The f = viz(mesh) line works great, then the viz!(f, mesh) call throws error:

julia> viz!(f, mesh)
ERROR: PlotMethodError: no viz method for arguments (::Makie.FigureAxisPlot, ::SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}). To support these arguments, define
  plot!(::MakieCore.Combined{MeshViz.viz, S} where S<:Tuple{Makie.FigureAxisPlot, SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}})
Available methods are:
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{DomainView{Dim, T, <:CartesianGrid{Dim, T}} where {Dim, T}}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\optimized.jl:13
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{PointOrGeometry}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\fallbacks.jl:26
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{AbstractVector{<:PointOrGeometry}}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\fallbacks.jl:8
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{Partition}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\partition.jl:7
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{Collection}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\collection.jl:7
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{CartesianGrid}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\cartesiangrid.jl:7
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{SimpleMesh}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\simplemesh.jl:7
  plot!(plot::MakieCore.Combined{MeshViz.viz, <:Tuple{Domain}}) in MeshViz at C:\Users\username\.julia\packages\MeshViz\vjshU\src\fallbacks.jl:44

Stacktrace:
  [1] _plot!(p::MakieCore.Combined{MeshViz.viz, Tuple{Makie.FigureAxisPlot, SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:344
  [2] plot!(p::MakieCore.Combined{MeshViz.viz, Tuple{Makie.FigureAxisPlot, SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:339
  [3] plot!(scene::Makie.Scene, P::Type{MakieCore.Combined{MeshViz.viz, Tuple{Makie.FigureAxisPlot, SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}}}}, attributes::MakieCore.Attributes, input::Tuple{Observables.Observable{Makie.FigureAxisPlot}, Observables.Observable{SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}}}, args::Observables.Observable{Tuple{Makie.FigureAxisPlot, SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:421
  [4] plot!(::Makie.Scene, ::Type{MakieCore.Combined{MeshViz.viz}}, ::MakieCore.Attributes, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:336
  [5] plot!(::Makie.Scene, ::Type{MakieCore.Combined{MeshViz.viz}}, ::MakieCore.Attributes, ::Makie.FigureAxisPlot, ::SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}})  
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:303
  [6] plot!(::Makie.LScene, ::Type{MakieCore.Combined{MeshViz.viz}}, ::MakieCore.Attributes, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:6
  [7] plot!(::Makie.LScene, ::Type{MakieCore.Combined{MeshViz.viz}}, ::MakieCore.Attributes, ::Makie.FigureAxisPlot, ::SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}}) 
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:1
  [8] plot!(::Type{MakieCore.Combined{MeshViz.viz}}, ::Makie.LScene, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:16
  [9] plot!(::Type{MakieCore.Combined{MeshViz.viz}}, ::Makie.LScene, ::Makie.FigureAxisPlot, ::SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:12
 [10] plot!(::Type{MakieCore.Combined{MeshViz.viz}}, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\figureplotting.jl:66
 [11] plot!(::Type{MakieCore.Combined{MeshViz.viz}}, ::Makie.FigureAxisPlot, ::SimpleMesh{3, Float64, Vector{Point3}, SimpleTopology{Connectivity{Triangle{Dim, T} where {Dim, T}, 3}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\figureplotting.jl:63
 [12] viz!(::Makie.FigureAxisPlot, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ MeshViz C:\Users\username\.julia\packages\MakieCore\bV281\src\recipes.jl:38
 [13] viz!(::Makie.FigureAxisPlot, ::Vararg{Any})
    @ MeshViz C:\Users\username\.julia\packages\MakieCore\bV281\src\recipes.jl:37
 [14] top-level scope
    @ REPL[3]:1

Somewhat similarly (though a different error), the following happens with Makie:

using GLMakie
points = [(0,0,1), (1,0,0), (1,1,0), (0,1,1)]
faces = [1 2 3; 3 4 1]
s = mesh(points, faces)
mesh!(s, points, faces)

The last line throws:

julia> mesh!(s, points, faces)
ERROR: MethodError: no method matching to_opengl_mesh!(::Dict{Symbol, Any}, ::Observable{Makie.FigureAxisPlot})
Closest candidates are:
  to_opengl_mesh!(::Any, ::Union{Observable{var"#s298"}, var"#s298"} where var"#s298"<:GeometryBasics.Mesh) at C:\Users\username\.julia\packages\GLMakie\6Blp9\src\glshaders\mesh.jl:1
Stacktrace:
  [1] draw_mesh(screen::GLMakie.Screen{GLFW.Window}, mesh::Any, data::Dict{Symbol, Any})
    @ GLMakie C:\Users\username\.julia\packages\GLMakie\6Blp9\src\glshaders\mesh.jl:38
  [2] mesh_inner(screen::GLMakie.Screen{GLFW.Window}, mesh::Observable{Makie.FigureAxisPlot}, transfunc::Observable{Any}, gl_attributes::Dict{Symbol, Any}, space::Observable{Symbol})
    @ GLMakie C:\Users\username\.julia\packages\GLMakie\6Blp9\src\drawing_primitives.jl:499
  [3] (::GLMakie.var"#242#243"{GLMakie.Screen{GLFW.Window}, Scene, Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}}})(gl_attributes::Dict{Symbol, Any})
    @ GLMakie C:\Users\username\.julia\packages\GLMakie\6Blp9\src\drawing_primitives.jl:507
  [4] (::GLMakie.var"#168#171"{GLMakie.var"#242#243"{GLMakie.Screen{GLFW.Window}, Scene, Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}}}, GLMakie.Screen{GLFW.Window}, Scene, Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}}})()
    @ GLMakie C:\Users\username\.julia\packages\GLMakie\6Blp9\src\drawing_primitives.jl:111
  [5] get!(default::GLMakie.var"#168#171"{GLMakie.var"#242#243"{GLMakie.Screen{GLFW.Window}, Scene, Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}}}, GLMakie.Screen{GLFW.Window}, Scene, Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}}}, h::Dict{UInt64, GLMakie.GLAbstraction.RenderObject}, key::UInt64)
    @ Base .\dict.jl:481
  [6] cached_robj!(robj_func::GLMakie.var"#242#243"{GLMakie.Screen{GLFW.Window}, Scene, Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}}}, screen::GLMakie.Screen{GLFW.Window}, scene::Scene, x::Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}})
    @ GLMakie C:\Users\username\.julia\packages\GLMakie\6Blp9\src\drawing_primitives.jl:84
  [7] draw_atomic
    @ C:\Users\username\.julia\packages\GLMakie\6Blp9\src\drawing_primitives.jl:503 [inlined]
  [8] insert!(screen::GLMakie.Screen{GLFW.Window}, scene::Scene, x::Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}})
    @ GLMakie C:\Users\username\.julia\packages\GLMakie\6Blp9\src\drawing_primitives.jl:126
  [9] push!(scene::Scene, plot::Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\scenes.jl:409
 [10] plot!(scene::Scene, P::Type{Mesh{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}}}, attributes::Attributes, input::Tuple{Observable{Makie.FigureAxisPlot}, Observable{Vector{Tuple{Int64, Int64, Int64}}}, Observable{Matrix{Int64}}}, args::Observable{Tuple{Makie.FigureAxisPlot, Vector{Tuple{Int64, Int64, Int64}}, Matrix{Int64}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:422
 [11] plot!(::Scene, ::Type{Mesh}, ::Attributes, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:336
 [12] plot!(::Scene, ::Type{Mesh}, ::Attributes, ::Makie.FigureAxisPlot, ::Vector{Tuple{Int64, Int64, Int64}}, ::Matrix{Int64})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\interfaces.jl:303
 [13] plot!(::LScene, ::Type{Mesh}, ::Attributes, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:6
 [14] plot!(::LScene, ::Type{Mesh}, ::Attributes, ::Makie.FigureAxisPlot, ::Vector{Tuple{Int64, Int64, Int64}}, ::Matrix{Int64})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:1
 [15] plot!(::Type{Mesh}, ::LScene, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:16
 [16] plot!(::Type{Mesh}, ::LScene, ::Makie.FigureAxisPlot, ::Vector{Tuple{Int64, Int64, Int64}}, ::Matrix{Int64})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\makielayout\blocks\scene.jl:12
 [17] plot!(::Type{Mesh}, ::Makie.FigureAxisPlot, ::Vararg{Any}; kw_attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\figureplotting.jl:66
 [18] plot!(::Type{Mesh}, ::Makie.FigureAxisPlot, ::Vector{Tuple{Int64, Int64, Int64}}, ::Matrix{Int64})
    @ Makie C:\Users\username\.julia\packages\Makie\Za3LL\src\figureplotting.jl:63
 [19] mesh!(::Makie.FigureAxisPlot, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ MakieCore C:\Users\username\.julia\packages\MakieCore\bV281\src\recipes.jl:38
 [20] mesh!(::Makie.FigureAxisPlot, ::Vararg{Any})
    @ MakieCore C:\Users\username\.julia\packages\MakieCore\bV281\src\recipes.jl:37
 [21] top-level scope
    @ REPL[5]:1

Oh, that was a stupid mistake on my side. Thanks for the quick reply!