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

          Line data    Source code
       1             : """
       2             :     fmesh = fliporientation(mesh)
       3             : 
       4             : Get new mesh with inverse orientation of faces. Vertex handles and
       5             : face handles are preserved **if** `iscontiguous(mesh)`. There is no
       6             : mapping for attributes of (half-)edges.
       7             : 
       8             : !!! warning
       9             :     `fliporientation(mesh)` copies **only** user-defined vertex
      10             :     and face attributes!
      11             : """
      12           1 : function fliporientation(mesh::Mesh)
      13           1 :     fmesh = similar(mesh)
      14             : 
      15           1 :     sizehint!(fmesh, nv(mesh), nf(mesh))
      16             : 
      17             :     # NOTE: Yet another (expensive) copy, but this method is used rarely
      18           1 :     iscontiguous(mesh) || (mesh, _ = compact(mesh))
      19             : 
      20           1 :     for _ in 1:nv(mesh)
      21          58 :         addvertex!(fmesh)
      22         115 :     end
      23             : 
      24           2 :     for f in faces(mesh)
      25         112 :         vs = collect(vertices(mesh, f))
      26         112 :         reverse!(vs)
      27             : 
      28         112 :         ff = addface!(fmesh, vs)
      29         112 :         @massert ff != NoF
      30         223 :     end
      31             : 
      32           1 :     copyvattrs!(fmesh, mesh)
      33           1 :     copyfattrs!(fmesh, mesh)
      34             : 
      35           1 :     fmesh
      36             : end
      37             : 
      38             : """
      39             :     vs = vertices(mesh, hs::Vector{HHnd})
      40             : 
      41             : Get `Vector` of vertices `vs` from `Vector` of half-edges `hs`.  If
      42             : `hs` represents a closed edge loops, the first vertex is not repeated.
      43             : """
      44           4 : function vertices(mesh::Mesh, hs::Vector{HHnd})
      45           4 :     n = length(hs)
      46           4 :     (n == 0) && return VHnd[]
      47           3 :     (n == 1) && return collect(vertices(mesh, first(hs)))
      48             : 
      49           2 :     v1 = source(mesh, first(hs))
      50           2 :     vend = destination(mesh, last(hs))
      51             : 
      52           4 :     vs = Vector{VHnd}(undef, (v1 == vend) ? n : n+1)
      53             : 
      54           2 :     vs[1] = v1
      55             : 
      56           2 :     for i in 2:length(vs)
      57          12 :         vs[i] = destination(mesh, hs[i-1])
      58          22 :     end
      59             : 
      60           2 :     vs
      61             : end
      62             : 
      63             : 
      64             : # TODO:: map edge loops
      65             : 
      66             : # TODO:: connected components

Generated by: LCOV version 1.16