Skip to content

Generalise mesh3d within GR backend to support Integer types #5107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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: 3 additions & 3 deletions PlotsBase/ext/GRExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2147,14 +2147,14 @@ function gr_draw_surface(series, x, y, z, clims)
GR.setfillcolorind(0)
GR.surface(x, y, z, get(e_kwargs, :display_option, GR.OPTION_FILLED_MESH))
elseif st ≡ :mesh3d
if series[:connections] isa AbstractVector{<:AbstractVector{Int}}
if series[:connections] isa AbstractVector{<:AbstractVector{<:Integer}}
# Combination of any polygon types
cns = map(cns -> [length(cns), cns...], series[:connections])
elseif series[:connections] isa AbstractVector{NTuple{N,Int}} where {N}
elseif series[:connections] isa AbstractVector{NTuple{N,<:Integer}} where {N}
# Only N-gons - connections have to be 1-based (indexing)
N = length(series[:connections][1])
cns = map(cns -> [N, cns...], series[:connections])
elseif series[:connections] isa NTuple{3,<:AbstractVector{Int}}
elseif series[:connections] isa NTuple{3,<:AbstractVector{<:Integer}}
# Only triangles - connections have to be 0-based (indexing)
ci, cj, ck = series[:connections]
if !(length(ci) == length(cj) == length(ck))
Expand Down
16 changes: 16 additions & 0 deletions PlotsBase/test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ with(:gr) do
fillcolor = :blue,
fillalpha = 0.2,
)
# Validate still works when we iuse different int types
mesh3d(
x,
y,
z;
connections = [
Int32[1, 2, 4, 3], # Quadrangle
Int32[1, 2, 5], # Triangle
Int32[2, 4, 5], # Triangle
Int32[4, 3, 5], # Triangle
Int32[3, 1, 5], # Triangle
],
linecolor = :black,
fillcolor = :blue,
fillalpha = 0.2,
)
@test true
end

Expand Down
Loading