diff --git a/Project.toml b/Project.toml index 4ccca64..c90b7ed 100644 --- a/Project.toml +++ b/Project.toml @@ -1,13 +1,14 @@ name = "SimplexGridFactory" uuid = "57bfcd06-606e-45d6-baf4-4ba06da0efd5" authors = ["Juergen Fuhrmann "] -version = "2.4.0" +version = "2.5.0" [deps] DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae" ElasticArrays = "fdbdab4c-e67f-52f5-8c3f-e7b388dad3d4" ExtendableGrids = "cfc395e8-590f-11e8-1f13-43a2532b2fa8" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +GridVisualize = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" @@ -21,9 +22,10 @@ DocStringExtensions = "0.8,0.9" ElasticArrays = "^1.2" ExtendableGrids = "1.6" FileIO = "1" +GridVisualize = "1.7.0" LinearAlgebra = "1.9" MeshIO = "0.4, 0.5" Printf = "1.6" TetGen = "1.5,2" -Triangulate = "2.3.1" +Triangulate = "2.3.1, 3" julia = "1.9" diff --git a/src/SimplexGridFactory.jl b/src/SimplexGridFactory.jl index f87d692..2eaef75 100644 --- a/src/SimplexGridFactory.jl +++ b/src/SimplexGridFactory.jl @@ -12,6 +12,7 @@ using ElasticArrays: ElasticArray import ExtendableGrids using ExtendableGrids: dim_space, Coordinates, BFaceNodes, BFaceRegions, simplexgrid, BinnedPointList using DocStringExtensions: SIGNATURES, TYPEDEF, TYPEDSIGNATURES +using GridVisualize: GridVisualize, GridVisualizer, plot_triangulateio! using FileIO: load import MeshIO diff --git a/src/plot.jl b/src/plot.jl index 3af304d..7bdba7c 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -1,14 +1,44 @@ """ -$(TYPEDSIGNATURES) + builderplot( + builder::SimplexGridBuilder; + Plotter::Module = nothing, + size = (650, 300), + input_slot = (1, 1), + output_slot = (1, 2), + layout = (1, 2), + vis = GridVisualizer(; Plotter, layout, size), + circumcircles = false, + reveal = true, + kwargs... + ) Two panel visualization of gridfactory with input and resulting grid -See [`default_options`](@ref) for available `kwargs`. +- `builder` : Simplex grid builder +- `Plotter` : Plotter +- `size`: size of plot +- `input_slot`: slot in visualizer for input plot +- `output_slot`: slot in visualizer for output plot +- `layout`: layout of grid visualizer +- `vis`: grid visualizer +- `circumcircles`: plot circumcircles in output +- `reveal`: reveal plot upon return. If `revel==true`, `reveal(vis)` is returned, and the plot is shown automatically. If `revel==false`, the visualizer `vis` is returned, giving the user the possibility to add plots in other visualizer slots. +- `kwargs...`: passed to output constructor; see [`default_options`](@ref) for available `kwargs`. """ builderplot(gb::SimplexGridBuilder; Plotter = nothing, kwargs...) = builderplot(gb, Plotter; kwargs...) builderplot(builder::SimplexGridBuilder, ::Nothing; kwargs...) = nothing -function builderplot(builder::SimplexGridBuilder, Plotter::Module; size = (650, 300), kwargs...) +function builderplot( + builder::SimplexGridBuilder, Plotter::Module; + size = (650, 300), + input_slot = (1, 1), + output_slot = (1, 2), + layout = (1, 2), + vis = GridVisualizer(; Plotter, layout, size), + circumcircles = false, + reveal = true, + kwargs... + ) opts = blendoptions!(copy(builder.options); kwargs...) Triangulate = builder.Generator @@ -34,15 +64,23 @@ function builderplot(builder::SimplexGridBuilder, Plotter::Module; size = (650, triout, vorout = Triangulate.triangulate(flags, triin) - figure = nothing - if Triangulate.ispyplot(Plotter) - Plotter.close() - Plotter.clf() - fig = Plotter.figure(1; dpi = 100) - fig.set_size_inches(size[1] / 100, size[2] / 100; forward = true) - end - if Triangulate.ismakie(Plotter) - figure = Plotter.Figure(; size) + plot_triangulateio!( + vis[input_slot...], + triin; + title = "Input" + ) + + plot_triangulateio!( + vis[output_slot...], + triout; + voronoi = length(vorout.pointlist) > 0 ? vorout : nothing, + circumcircles, + title = "Output" + ) + + if reveal + return GridVisualize.reveal(vis) + else + return vis end - return Triangulate.plot_in_out(Plotter, triin, triout; figure) end diff --git a/test/runtests.jl b/test/runtests.jl index 7da66e0..d923825 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -395,5 +395,5 @@ end builder end @info builderplot(t2d(); Plotter = CairoMakie) |> typeof - @test isa(builderplot(t2d(); Plotter = CairoMakie), CairoMakie.Figure) + @test isa(builderplot(t2d(); Plotter = CairoMakie), CairoMakie.Scene) end