Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name = "SimplexGridFactory"
uuid = "57bfcd06-606e-45d6-baf4-4ba06da0efd5"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>"]
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"
Expand All @@ -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"
1 change: 1 addition & 0 deletions src/SimplexGridFactory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
64 changes: 51 additions & 13 deletions src/plot.jl
Original file line number Diff line number Diff line change
@@ -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 circumcicles in output
- `reveal`: reveal plot upon return
- `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
Expand All @@ -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
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading