-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathplot.jl
More file actions
86 lines (74 loc) · 2.43 KB
/
plot.jl
File metadata and controls
86 lines (74 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
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
- `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),
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
@assert(istriangulate(Triangulate))
flags = makeflags(opts, :triangle)
if opts[:verbose]
@show flags
end
triin = nothing
try
triin = triangulateio(builder)
catch err
@error "Incomplete geometry description"
rethrow(err)
end
if !isnothing(opts[:unsuitable])
Triangulate.triunsuitable!(opts[:unsuitable])
end
triout, vorout = Triangulate.triangulate(flags, triin)
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
end