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

          Line data    Source code
       1             : """
       2             :     removeface!(mesh, f[; remove_isolated_vertices = false])
       3             : 
       4             : Unlink and remove face `f` from `mesh`. Removing `f` may leave
       5             : isolated vertices, which are optionally removed if
       6             : `remove_isolated_vertices==true`.
       7             : 
       8             : !!! warning "Precondition"
       9             :     Requires [`isused`](@ref) for `f`.
      10             : 
      11             : See also [`isisolated`](@ref), [`addface!`](@ref)
      12             : """
      13          70 : function removeface!(mesh::Mesh, f::FHnd;
      14             :                      remove_isolated_vertices::Bool = false)
      15          35 :     @massert isused(mesh, f)
      16             : 
      17          35 :     rmhs = Vector{HHnd}()
      18          35 :     sizehint!(rmhs, 3)
      19             : 
      20          35 :     vs = Vector{VHnd}()
      21          35 :     sizehint!(vs, 3)
      22             : 
      23          35 :     for h in halfedges(mesh, f)
      24         105 :         _setface!(mesh, h, NoF)
      25         105 :         push!(vs, destination(mesh, h))
      26         105 :         isboundary(mesh, opposite(mesh, h)) && push!(rmhs, h)
      27         105 :     end
      28             : 
      29          35 :     for h in rmhs
      30          41 :         _remove_face_edge!(mesh, h, remove_isolated_vertices)
      31          41 :     end
      32             : 
      33          35 :     for v in vs
      34         105 :         _adjustoutgoinghalfedge!(mesh, v)
      35         105 :     end
      36             : 
      37          35 :     _setunused!(mesh, f)
      38             : end
      39             : 
      40          41 : function _remove_face_edge!(mesh::Mesh, h::HHnd, rmivtx::Bool)
      41          41 :     h0, h1 = halfedges(mesh, h)
      42             : 
      43          41 :     v0 = destination(mesh, h0)
      44          41 :     next0 = next(mesh, h0)
      45          41 :     prev0 = prev(mesh, h0)
      46             : 
      47          41 :     v1 = destination(mesh, h1)
      48          41 :     next1 = next(mesh, h1)
      49          41 :     prev1 = prev(mesh, h1)
      50             : 
      51          41 :     _setnexthalfedge!(mesh, prev0, next1)
      52          41 :     _setnexthalfedge!(mesh, prev1, next0)
      53             : 
      54          41 :     _remove_face_edge_update!(mesh, v0, h1, next0, rmivtx)
      55          41 :     _remove_face_edge_update!(mesh, v1, h0, next1, rmivtx)
      56             : 
      57          41 :     _setunused!(mesh, edge(mesh, h0))
      58             : end
      59             : 
      60          82 : function _remove_face_edge_update!(mesh::Mesh, v0::VHnd, h1::HHnd, next0::HHnd,
      61             :                                    rmivtx::Bool)
      62          82 :     (halfedge(mesh, v0) != h1) && return
      63             : 
      64          48 :     (next0 == h1) && (next0 = NoH)      # v0 becomes isolated vertex
      65             : 
      66          48 :     if rmivtx
      67           0 :         _setunused!(mesh, v0)           # remove isolated
      68             :     else
      69          48 :         _sethalfedge!(mesh, v0, next0)  # keep isolated
      70             :     end
      71             : end

Generated by: LCOV version 1.16