LCOV - code coverage report
Current view: top level - src - glimpse.jl (source / functions) Hit Total Coverage
Test: on branch nothing Lines: 29 54 53.7 %
Date: 2025-07-10 13:12:25 Functions: 0 0 -

          Line data    Source code
       1           8 : function glimpse(io::IO, attr::NamedTuple; header=nothing, suffix="\n")
       2           4 :     output = String[]
       3             : 
       4           4 :     for name in propertynames(attr)
       5          20 :         (first(String(name)) == '_') && continue
       6           4 :         p = getproperty(attr, name)
       7           5 :         e = p.enabled ? "" : "(disabled)"
       8           5 :         t = eltype(eltype(p))
       9           4 :         push!(output, "  - :$(name) $(t)[$(length(eltype(p)))]$e")
      10          12 :     end
      11             : 
      12           4 :     isempty(output) && return
      13             : 
      14           2 :     isnothing(header) || println(io, "$(header)")
      15             : 
      16           2 :     println(io, join(output, "\n"))
      17           2 :     print(io, suffix)
      18             : end
      19             : 
      20             : # TODO: short type
      21             : 
      22           1 : function glimpse(io::IO, mesh::Mesh)
      23           1 :     show(io, mesh)
      24           1 :     print(io, "\n\n")
      25             : 
      26           1 :     glimpse(io, vattr(mesh).attrs; header=" vertex attributes")
      27           1 :     glimpse(io, fattr(mesh).attrs; header=" face attributes")
      28           1 :     glimpse(io, hattr(mesh).attrs; header=" half-edge attributes")
      29           1 :     glimpse(io, eattr(mesh).attrs; header=" edge attributes")
      30             : 
      31           1 :     triangulation = istrianglemesh(mesh)
      32             : 
      33           1 :     println(io, " - triangulation:     $(triangulation)")
      34           1 :     println(io, " - manifold:          $(ismanifold(mesh))")
      35           1 :     println(io, " - isolated vertices: $(hasisolatedvertices(mesh))")
      36           1 :     println(io, " - contiguous:        $(iscontiguous(mesh))")
      37           1 :     println(io, " - boundary loops:    $(length(findboundaryloops(mesh)))")
      38             : 
      39           1 :     if hasvattr(mesh, Val(:x)) && nv(mesh) > 2
      40           0 :         println(io)
      41           0 :         g = geometry(mesh, Val(:x))
      42           0 :         xmin, xmax = extrema(g)
      43           0 :         emin, emax = extrema(edgelengths(g))
      44           0 :         emean = meanedgelength(g)
      45             : 
      46           0 :         println(io, " - bounding box\n   min  = $(xmin)\n   max  = $(xmax)")
      47           0 :         println(io, "   mean = $(mean(g))")
      48           0 :         println(io, " - edge lengths\n   min  = $(emin)\n   max  = $(emax)\n   mean = $(emean)")
      49             :     end
      50             : 
      51           1 :     if triangulation && nf(mesh) > 0
      52           0 :         println(io)
      53           0 :         vmin, vmax = extrema(degree(mesh, v) for v in vertices(mesh))
      54           0 :         println(io, " - vertex degree in $(vmin):$(vmax)")
      55             : 
      56             :         # TODO: facearea is currently not available for polygonal meshes
      57           0 :         println(io, " - surface area  =  $(surfacearea(g))")
      58             : 
      59           0 :         amin, amax = extrema(facearea(g, f) for f in faces(mesh))
      60           0 :         println(io, " - face areas\n   min  = $(amin)\n   max  = $(amax)")
      61           0 :         println(io, "   mean = $(mean(facearea(g, f) for f in faces(mesh)))")
      62             : 
      63           0 :         amin, amax = +Inf, -Inf
      64           0 :         function minmaxangle(g, f)
      65             :             extrema(anglenext(g, h) for h in halfedges(mesh, f))
      66             :         end
      67             : 
      68           0 :         for f in faces(mesh)
      69           0 :             afmin, afmax = minmaxangle(g, f)
      70           0 :             amin = min(amin, afmin)
      71           0 :             amax = max(amax, afmax)
      72           0 :         end
      73             : 
      74           0 :         amin, amax = SVector(amin, amax) * (180 / π)
      75           0 :         println(io, " - angles\n   min  = $(amin)°\n   max  = $(amax)°")
      76             :     end
      77             : 
      78           1 :     mesh
      79             : end
      80             : 
      81           0 : glimpse(mesh::Mesh) = glimpse(stdout, mesh)
      82             : 
      83             : """
      84             :     glimpse([io,] mesh)
      85             : 
      86             : Show a more detailed summary of the mesh than `Base.show`.
      87             : """ glimpse

Generated by: LCOV version 1.16