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

          Line data    Source code
       1             : # NOTE: Half-edges are not actively managed: they depend on (managed) edges.
       2             : #       - There is no n_used attribute in HAttr!
       3             : #       - There is no :_flags attribute within attrs!
       4             : #       - Neither of them can be accessed! Any function using these will fail!
       5             : #         (Such functions should not be called!)
       6             : # NOTE: We "add/remove" edges, iterate over all/count edges of a mesh, ...
       7             : #       ... and "map to" half-edges (e.g., half-edge count == 2 * edge count).
       8             : 
       9             : """
      10             : Abstract half-edge attributes.
      11             : 
      12             : Half-edge attributes like [`VAttr`](@ref) are declared a a subtype.
      13             : """
      14             : abstract type AbstractHAttr <: ManagedAttributes{HHnd}; end
      15             : 
      16             : """
      17             : Half-edge attributes consisting of  managed attributes `P` plus cached state.
      18             : """
      19             : mutable struct HAttr{P} <: AbstractHAttr
      20             :     const attrs::P
      21          64 :     HAttr{P}(attrs::P) where {P} = new(attrs)
      22             : end
      23             : 
      24          60 : _newhattr(ha::P) where {P} = HAttr{P}(ha)
      25             : 
      26             : """
      27             :     ha2 = similar(ha::Attr)
      28             : 
      29             : Create same attribute list as `va` but empty: without entries.
      30             : """
      31          58 : Base.similar(ha::HAttr) =
      32             :     _newhattr(createattributes(attrspecs(attrs(ha)); htyp=HHnd))
      33             : 
      34             : """
      35             : Internal link state of an half-edge.
      36             : """
      37             : struct HalfEdge
      38             :     v::VHnd
      39             :     f::FHnd
      40             :     next::HHnd
      41             :     prev::HHnd
      42             : 
      43      189652 :     HalfEdge(v::VHnd = NoV, f::FHnd = NoF,
      44             :              next::HHnd = NoH, prev::HHnd = NoH) =
      45             :                  new(v, f, next, prev)
      46          60 :     HalfEdge(h::HalfEdge) = new(h.v, h.f, h.next, h.prev)
      47             : end
      48             : 
      49           0 : Base.zero(::Type{HalfEdge}) = HalfEdge()
      50          60 : Base.copy(h::HalfEdge) = h
      51             : 
      52           0 : Base.show(io::IO, h::HalfEdge) =
      53             :     print(io, "(v=$(h.v), f=$(h.f), next=$(h.next), prev=$(h.prev))")
      54             : 
      55             : const NoHalfEdge = HalfEdge(NoV, NoF, NoH, NoH)
      56             : 
      57             : const HalfEdgeAttributesSpecs = (:_link => specifyattr(HalfEdge,
      58             :                                                        enabled=true,
      59             :                                                        x0=NoHalfEdge), )
      60             : 
      61           4 : createhattr(list...) =
      62             :     _newhattr(createattributes((HalfEdgeAttributesSpecs..., list...);
      63             :                                htyp=HHnd))
      64             : 
      65           2 : createhattr(list::Tuple) = createhattr(list...)
      66             : 
      67             : """
      68             :     createhattr(key => value, ...)
      69             :     createhattr((key => value, ...))
      70             : 
      71             : Create half-edge attribute list from `key => value` pairs, where `key` is a `Symbol` and
      72             : `value` either a type or the result from `specifyattr`.
      73             : 
      74             : See also [`similar`](@ref)
      75             : """ createhattr
      76             : 
      77             : """
      78             :     hc = clone(ha::HAttr)
      79             : 
      80             : Deep copy of attribute list but don't copy disabled attributes.
      81             : """
      82           4 : clone(ha::HAttr{P}) where {P} = HAttr{P}(clone(ha.attrs))

Generated by: LCOV version 1.16