Skip to content

Commit b19b17e

Browse files
authored
Merge pull request #200 from JuliaGeometry/sd/fix-empty
fix empty case
2 parents 82cbf05 + cbf0740 commit b19b17e

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/geometry_primitives.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ collect_with_eltype(::Type{T}, vec::Vector{T}) where {T} = vec
7474
collect_with_eltype(::Type{T}, vec::AbstractVector{T}) where {T} = collect(vec)
7575

7676
function collect_with_eltype(::Type{T}, iter) where {T}
77+
isempty(iter) && return T[]
7778
# We need to get `eltype` information from `iter`, it seems to be `Any`
7879
# most of the time so the eltype checks here don't actually work
7980
l = if Base.IteratorSize(iter) isa Union{Base.HasShape,Base.HasLength}
8081
if Base.IteratorEltype(iter) isa Base.HasEltype && isconcretetype(eltype(iter))
81-
# Work out the exact length
82+
# Work out the exact length
8283
length(convert_simplex(T, first(iter))) * length(iter)
8384
else
8485
# We know it is at least the length of iter,

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,8 @@ end
458458
end
459459

460460
@testset "decompose/triangulation" begin
461+
@test isempty(decompose(Vec3f, []))
462+
@test decompose(Vec3f, []) isa Vector{Vec3f}
461463
primitive = Sphere(Point3f(0), 1)
462464
@test ndims(primitive) === 3
463465
mesh = triangle_mesh(primitive)

0 commit comments

Comments
 (0)