Skip to content

Commit

Permalink
fix 2D assumption in point-based convert_args for lines (#4585)
Browse files Browse the repository at this point in the history
* fix 2D assumption in point-based convert_args for lines

* add changelog entry

* add test

---------

Co-authored-by: Frederic Freyer <[email protected]>
  • Loading branch information
asinghvi17 and ffreyer authored Nov 12, 2024
1 parent d7d407e commit 2feb058
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

## [Unreleased]

- Fix an error in `convert_arguments` for PointBased plots and 3D polygons [#4585](https://github.com/MakieOrg/Makie.jl/pull/4585).
- Fix polygon rendering issue of `crossbar(..., show_notch = true)` in CairoMakie [#4587](https://github.com/MakieOrg/Makie.jl/pull/4587).

## [0.21.16] - 2024-11-06
Expand Down
2 changes: 1 addition & 1 deletion src/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function convert_arguments(PB::PointBased, mp::Union{Array{<:Polygon{N, T}}, Mul
converted = convert_arguments(PB, mp[idx])[1] # this should always be a Tuple{<: Vector{Point}}
append!(arr, converted)
if idx != n # don't add NaN at the end
push!(arr, Point2(NaN))
push!(arr, Point{N, float_type(T)}(NaN))
end
end
return (arr,)
Expand Down
4 changes: 4 additions & 0 deletions test/convert_arguments.jl
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ Makie.convert_arguments(::PointBased, ::MyConvVector) = ([Point(10, 20)],)
geom = Sphere(Point3{T_in}(0), T_in(1))
_mesh = GeometryBasics.mesh(rect3; pointtype=Point3{T_in}, facetype=GLTriangleFace)
polygon = Polygon(Point2.(xs, ys))
polygon3d = Polygon(Point3.(xs, ys, zs))
line = LineString(Point3.(xs, ys, zs))
bp = BezierPath([
MoveTo(T_in(0), T_in(0)),
Expand Down Expand Up @@ -228,6 +229,9 @@ Makie.convert_arguments(::PointBased, ::MyConvVector) = ([Point(10, 20)],)
@test apply_conversion(CT, polygon) isa Tuple{Vector{Point2{T_out}}}
@test apply_conversion(CT, [polygon, polygon]) isa Tuple{Vector{Point2{T_out}}}
@test apply_conversion(CT, MultiPolygon([polygon, polygon])) isa Tuple{Vector{Point2{T_out}}}
@test apply_conversion(CT, polygon3d) isa Tuple{Vector{Point3{T_out}}}
@test apply_conversion(CT, [polygon3d, polygon3d]) isa Tuple{Vector{Point3{T_out}}}
@test apply_conversion(CT, MultiPolygon([polygon3d, polygon3d])) isa Tuple{Vector{Point3{T_out}}}
@test apply_conversion(CT, line) isa Tuple{Vector{Point3{T_out}}}
@test apply_conversion(CT, [line, line]) isa Tuple{Vector{Point3{T_out}}}
@test apply_conversion(CT, MultiLineString([line, line])) isa Tuple{Vector{Point3{T_out}}}
Expand Down

0 comments on commit 2feb058

Please sign in to comment.