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

          Line data    Source code
       1           9 : function mayremoveedge(mesh::Mesh, e::EHnd)
       2           9 :     h0, h1 = halfedges(mesh, e)
       3             : 
       4           9 :     v0 = destination(mesh, h0)
       5           9 :     v1 = destination(mesh, h1)
       6             : 
       7           9 :     f0 = face(mesh, h0)
       8           9 :     f1 = face(mesh, h1)
       9             : 
      10          10 :     (f0 != NoF && f1 != NoF) || return false   # boundary
      11             : 
      12           8 :     (f0 != f1) || return false                 # same face
      13             : 
      14           8 :     for v in vertices(mesh, f0)
      15          25 :         if v != v0 && v != v1
      16          47 :             any(f == f1 for f in fan(mesh, v)) && return false
      17             :         end
      18          25 :     end
      19             : 
      20           0 :     true
      21             : end
      22             : 
      23           0 : mayremoveedge(mesh::Mesh, h::Hnd) = mayremoveedge(mesh, edge(mesh, h))
      24             : 
      25             : """
      26             :     mayremoveedge(mesh, e::EHnd) :: Bool
      27             :     mayremoveedge(mesh, h::HHnd) :: Bool
      28             : 
      29             : Determine whether edge `e` (possibly given by one of its half-edges
      30             : `h`) can be removeedged.
      31             : 
      32             : See also [`removeedge!`](@ref)
      33             : """ mayremoveedge
      34             : 
      35           0 : removeedge!(mesh::Mesh, h::HHnd) = removeedge!(mesh, edge(mesh, h))
      36             : 
      37           4 : function removeedge!(mesh::Mesh, e::EHnd)
      38           4 :     @massert mayremoveedge(mesh, e)
      39             : 
      40           4 :     h0, h1 = halfedges(mesh, e)
      41             : 
      42           4 :     v0 = destination(mesh, h0)
      43           4 :     v1 = destination(mesh, h1)
      44             : 
      45           4 :     f0 = face(mesh, h0)
      46           4 :     f1 = face(mesh, h1)
      47             : 
      48           4 :     h0p = prev(mesh, h0)
      49           4 :     h0n = next(mesh, h0)
      50           4 :     h1p = prev(mesh, h1)
      51           4 :     h1n = next(mesh, h1)
      52             : 
      53             :     # adjust vertex -> half-edge
      54           4 :     (halfedge(mesh, v0) == h1) && _sethalfedge!(mesh, v0, h0n)
      55           4 :     (halfedge(mesh, v1) == h0) && _sethalfedge!(mesh, v1, h1n)
      56             : 
      57             :     # adjust half-edge -> face
      58           4 :     for h in halfedges(mesh, f0)
      59          13 :         _setface!(mesh, h, f1)
      60          13 :     end
      61             : 
      62             :     # adjust half-edge -> half-edge
      63           4 :     _setnexthalfedge!(mesh, h1p, h0n)
      64           4 :     _setnexthalfedge!(mesh, h0p, h1n)
      65             : 
      66             :     # adjust face -> half-edge
      67           4 :     (halfedge(mesh, f1) == h1) && _sethalfedge!(mesh, f1, h1n)
      68             : 
      69             :     # remove face f0 and edge e
      70           4 :     _setunused!(mesh, f0)
      71           4 :     _setunused!(mesh, e)
      72             : end
      73             : 
      74             : """
      75             :     removeedge!(mesh, e::EHnd)
      76             :     removeedge!(mesh, h::HHnd)
      77             : 
      78             : Remove edge `e` (possibly given by one of its half-edges `h`) and
      79             : merge its two incident face into one face.
      80             : 
      81             : !!! warning "Precondition"
      82             :     The edge `e` must have *two distinct* incident faces.
      83             : 
      84             : !!! warning "Precondition"
      85             :     Requires `mayremove(mesh, e) == true` immediately before `remove!(mesh, e)`!
      86             : 
      87             : See also [`mayremove`](@ref), [`insertedge!`](@ref)
      88             : 
      89             : """ removeedge!

Generated by: LCOV version 1.16