Skip to content

Commit ec79366

Browse files
committed
Allow for Triangle v3
use plot_triangulateio from GridVisualize.
1 parent 989232f commit ec79366

File tree

4 files changed

+57
-16
lines changed

4 files changed

+57
-16
lines changed

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
name = "SimplexGridFactory"
22
uuid = "57bfcd06-606e-45d6-baf4-4ba06da0efd5"
33
authors = ["Juergen Fuhrmann <[email protected]>"]
4-
version = "2.4.0"
4+
version = "2.5.0"
55

66
[deps]
77
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
88
ElasticArrays = "fdbdab4c-e67f-52f5-8c3f-e7b388dad3d4"
99
ExtendableGrids = "cfc395e8-590f-11e8-1f13-43a2532b2fa8"
1010
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
11+
GridVisualize = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8"
1112
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1213
MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118"
1314
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
@@ -21,9 +22,10 @@ DocStringExtensions = "0.8,0.9"
2122
ElasticArrays = "^1.2"
2223
ExtendableGrids = "1.6"
2324
FileIO = "1"
25+
GridVisualize = "1.7.0"
2426
LinearAlgebra = "1.9"
2527
MeshIO = "0.4, 0.5"
2628
Printf = "1.6"
2729
TetGen = "1.5,2"
28-
Triangulate = "2.3.1"
30+
Triangulate = "2.3.1, 3"
2931
julia = "1.9"

src/SimplexGridFactory.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ using ElasticArrays: ElasticArray
1212
import ExtendableGrids
1313
using ExtendableGrids: dim_space, Coordinates, BFaceNodes, BFaceRegions, simplexgrid, BinnedPointList
1414
using DocStringExtensions: SIGNATURES, TYPEDEF, TYPEDSIGNATURES
15+
using GridVisualize: GridVisualize, GridVisualizer, plot_triangulateio!
1516
using FileIO: load
1617
import MeshIO
1718

src/plot.jl

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,44 @@
11
"""
2-
$(TYPEDSIGNATURES)
2+
builderplot(
3+
builder::SimplexGridBuilder;
4+
Plotter::Module = nothing,
5+
size = (650, 300),
6+
input_slot = (1, 1),
7+
output_slot = (1, 2),
8+
layout = (1, 2),
9+
vis = GridVisualizer(; Plotter, layout, size),
10+
circumcircles = false,
11+
reveal = true,
12+
kwargs...
13+
)
314
415
Two panel visualization of gridfactory with input and resulting grid
5-
See [`default_options`](@ref) for available `kwargs`.
16+
- `builder` : Simplex grid builder
17+
- `Plotter` : Plotter
18+
- `size`: size of plot
19+
- `input_slot`: slot in visualizer for input plot
20+
- `output_slot`: slot in visualizer for output plot
21+
- `layout`: layout of grid visualizer
22+
- `vis`: grid visualizer
23+
- `circumcircles`: plot circumcicles in output
24+
- `reveal`: reveal plot upon return
25+
- `kwargs...`: passed to output constructor; see [`default_options`](@ref) for available `kwargs`.
626
"""
727
builderplot(gb::SimplexGridBuilder; Plotter = nothing, kwargs...) = builderplot(gb, Plotter; kwargs...)
828

929
builderplot(builder::SimplexGridBuilder, ::Nothing; kwargs...) = nothing
1030

11-
function builderplot(builder::SimplexGridBuilder, Plotter::Module; size = (650, 300), kwargs...)
31+
function builderplot(
32+
builder::SimplexGridBuilder, Plotter::Module;
33+
size = (650, 300),
34+
input_slot = (1, 1),
35+
output_slot = (1, 2),
36+
layout = (1, 2),
37+
vis = GridVisualizer(; Plotter, layout, size),
38+
circumcircles = false,
39+
reveal = true,
40+
kwargs...
41+
)
1242
opts = blendoptions!(copy(builder.options); kwargs...)
1343

1444
Triangulate = builder.Generator
@@ -34,15 +64,23 @@ function builderplot(builder::SimplexGridBuilder, Plotter::Module; size = (650,
3464

3565
triout, vorout = Triangulate.triangulate(flags, triin)
3666

37-
figure = nothing
38-
if Triangulate.ispyplot(Plotter)
39-
Plotter.close()
40-
Plotter.clf()
41-
fig = Plotter.figure(1; dpi = 100)
42-
fig.set_size_inches(size[1] / 100, size[2] / 100; forward = true)
43-
end
44-
if Triangulate.ismakie(Plotter)
45-
figure = Plotter.Figure(; size)
67+
plot_triangulateio!(
68+
vis[input_slot...],
69+
triin;
70+
title = "Input"
71+
)
72+
73+
plot_triangulateio!(
74+
vis[output_slot...],
75+
triout;
76+
voronoi = length(vorout.pointlist) > 0 ? vorout : nothing,
77+
circumcircles,
78+
title = "Output"
79+
)
80+
81+
if reveal
82+
return GridVisualize.reveal(vis)
83+
else
84+
return vis
4685
end
47-
return Triangulate.plot_in_out(Plotter, triin, triout; figure)
4886
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,5 +395,5 @@ end
395395
builder
396396
end
397397
@info builderplot(t2d(); Plotter = CairoMakie) |> typeof
398-
@test isa(builderplot(t2d(); Plotter = CairoMakie), CairoMakie.Figure)
398+
@test isa(builderplot(t2d(); Plotter = CairoMakie), CairoMakie.Scene)
399399
end

0 commit comments

Comments
 (0)