JuliaGeometry / GeometryBasics.jl

Basic Geometry Types
MIT License
164 stars 54 forks source link

Fix mesh(::AbstractPolygon) in case faces returns nothing #122

Closed knuesel closed 3 years ago

knuesel commented 3 years ago

When faces returns nothing, mesh(::Meshable) falls back on decompose(facetype, positions). The fallback is missing from mesh(::AbstractPolygon) so the following fails:

julia> t = Triangle(Point2f0(0), Point2f0(1), Point2f0(1,0))
Triangle(Float32[0.0, 0.0], Float32[1.0, 1.0], Float32[1.0, 0.0])

julia> GeometryBasics.mesh(t)
ERROR: MethodError: no method matching Mesh(::Array{Point{2,Float32},1}, ::Nothing)

This PR adds the fallback to the AbstractPolygon case.

SimonDanisch commented 3 years ago

Thanks