Skip to content

Commit 5c248f0

Browse files
committed
fix and test single-face mesh constructor
1 parent 99a3e20 commit 5c248f0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/basic_types.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,12 @@ function Mesh(points::AbstractVector{<:Point}, faces::AbstractVector{<:Integer},
758758
return Mesh(points, connect(faces, facetype, skip))
759759
end
760760

761+
# the method above allows Mesh(..., Face(...), ...) to work, but produces bad results
762+
# explicitly error here
763+
function Mesh(points::AbstractVector{<:Point}, faces::AbstractFace, args...; kwargs...)
764+
throw(MethodError(Mesh, (points, faces, args...)))
765+
end
766+
761767
function Mesh(; kwargs...)
762768
fs = faces(kwargs[:position]::FaceView)
763769
va = NamedTuple{keys(kwargs)}(map(keys(kwargs)) do k

test/meshes.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ end
3131
@testset "Merge empty vector of meshes" begin
3232
# https://github.com/JuliaGeometry/GeometryBasics.jl/issues/136
3333
merge(Mesh[]) == Mesh(Point3f[], GLTriangleFace[])
34+
merge([Mesh(Point3f[], GLTriangleFace[])]) == Mesh(Point3f[], GLTriangleFace[])
35+
merge([Mesh(Point3f[], GLTriangleFace[]), Mesh(Point3f[], GLTriangleFace[])]) == Mesh(Point3f[], GLTriangleFace[])
3436
end
3537

3638
@testset "Vertex Index Remapping" begin
@@ -138,6 +140,8 @@ end
138140
@test faces(m) == fs
139141
end
140142

143+
@test_throws MethodError Mesh(Point2f[], GLTriangleFace(1,2,3))
144+
141145
@testset "Verification" begin
142146
# enough vertices present
143147
@test_throws ErrorException Mesh(rand(Point2f, 7), fs)

0 commit comments

Comments
 (0)