Skip to content

Commit da1000d

Browse files
committed
improve propertynames + simplex convert
1 parent 39d0711 commit da1000d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

src/geometry_primitives.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ end
1414
1515
Triangulate an N-Face into a tuple of triangular faces.
1616
"""
17-
@generated function convert_simplex(::Type{TriangleFace{T}}, f::NgonFace{N}) where {T, N}
18-
3 <= N || error("decompose not implented for N <= 3 yet. N: $N")# other wise degenerate
17+
@generated function convert_simplex(::Type{TriangleFace{T}}, f::Union{SimplexFace{N}, NgonFace{N}}) where {T, N}
18+
3 <= N || error("decompose not implemented for N <= 3 yet. N: $N")# other wise degenerate
1919
v = Expr(:tuple)
2020
for i = 3:N
2121
push!(v.args, :(TriangleFace{T}(f[1], f[$(i-1)], f[$i])))
@@ -28,7 +28,7 @@ end
2828
2929
Extract all line segments in a Face.
3030
"""
31-
@generated function convert_simplex(::Type{LineFace{T}}, f::NgonFace{N}) where {T, N}
31+
@generated function convert_simplex(::Type{LineFace{T}}, f::Union{SimplexFace{N}, NgonFace{N}}) where {T, N}
3232
2 <= N || error("decompose not implented for N <= 2 yet. N: $N")# other wise degenerate
3333

3434
v = Expr(:tuple)

src/metadata.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ macro meta_type(name, mainfield, supertype, params...)
113113
return MT(obj, nt)
114114
end
115115

116+
function Base.propertynames(::$MetaName{$(params...), Typ, Names, Types}) where {$(params...), Typ, Names, Types}
117+
return ($field, Names...)
118+
end
119+
116120
function StructArrays.staticschema(::Type{$MetaName{$(params...), Typ, Names, Types}}) where {$(params...), Typ, Names, Types}
117121
NamedTuple{($field, Names...), Base.tuple_type_cons(Typ, Types)}
118122
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ using LinearAlgebra
8383
pm = GeometryBasics.PointMeta(1.1, 2.2; a=1, b=2)
8484
@test meta(pm) === (a=1, b=2)
8585
@test metafree(pm) === p
86+
@test propertynames(pm) == (:position, :a, :b)
8687
end
8788
end
8889

0 commit comments

Comments
 (0)