Skip to content

Commit cba8ec8

Browse files
committed
fix constructor and print Mesh more nicely
1 parent ffa5e08 commit cba8ec8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/basic_types.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function MetaMesh(points::AbstractVector{<:Point}, faces::AbstractVector{<:Abstr
271271
end
272272

273273
function MetaMesh(m::AbstractMesh; kw...)
274-
MetaMesh(m, merge(meta(m), values(kw)))
274+
MetaMesh(Mesh(m), merge(meta(m), values(kw)))
275275
end
276276

277277
@inline Base.hasproperty(mesh::MetaMesh, field::Symbol) = hasproperty(getfield(mesh, :meta), field)

src/meshes.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,30 @@ function Base.get(f, mesh::MetaMesh, key::Symbol)
174174
hasproperty(mesh, key) && return getproperty(mesh, key)
175175
return f()
176176
end
177+
178+
function Base.show(io::IO, ::MIME"text/plain", mesh::Mesh{N, T}) where {N, T}
179+
FT = eltype(faces(mesh))
180+
println(io, "Mesh{$N, $T, $(FT)}")
181+
println(io, " vertices: ", length(coordinates(mesh)))
182+
println(io, " faces: ", length(faces(mesh)), " $(FT)")
183+
end
184+
185+
function Base.show(io::IO, mesh::Mesh{N, T}) where {N, T}
186+
FT = eltype(faces(mesh))
187+
print(io, "Mesh{$N, $T, $(FT)}(...)")
188+
end
189+
190+
function Base.show(io::IO, ::MIME"text/plain", mesh::MetaMesh{N, T}) where {N, T}
191+
FT = eltype(faces(mesh))
192+
println(io, "MetaMesh{$N, $T, $(FT)}")
193+
println(io, " vertices: ", length(coordinates(mesh)))
194+
println(io, " faces: ", length(faces(mesh)), " $(FT)")
195+
for (k, v) in pairs(meta(mesh))
196+
println(io, " ", k, ": ", length(v), " $(eltype(v))")
197+
end
198+
end
199+
200+
function Base.show(io::IO, mesh::MetaMesh{N, T}) where {N, T}
201+
FT = eltype(faces(mesh))
202+
println(io, "MetaMesh{$N, $T, $(FT)}($(join(keys(meta(mesh)), ", ")))")
203+
end

0 commit comments

Comments
 (0)