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

          Line data    Source code
       1          13 : function mayflip(mesh::Mesh, e::EHnd)
       2          13 :     h0, h1 = halfedges(e)
       3             : 
       4          13 :     !isboundary(mesh, h0) || return false
       5          17 :     !isboundary(mesh, h1) || return false
       6             : 
       7           9 :     @massert(istriangle(mesh, h0))
       8           9 :     @massert(istriangle(mesh, h1))
       9             : 
      10           9 :     v0 = destination(mesh, next(mesh, h0))
      11           9 :     v1 = destination(mesh, next(mesh, h1))
      12             : 
      13           9 :     (v0 != v1) || return false
      14             : 
      15           9 :     h = halfedge(mesh, v0, v1)
      16           9 :     @massert (h == NoH) || isused(mesh, h)
      17           9 :     (h == NoH) || return false
      18             : 
      19           0 :     true
      20             : end
      21             : 
      22           2 : mayflip(mesh::Mesh, h::HHnd) = mayflip(mesh, edge(mesh, h))
      23             : 
      24             : """
      25             :     mayflip(mesh, e::EHnd) :: Bool
      26             :     mayflip(mesh, h::HHnd) :: Bool
      27             : 
      28             : Determine whether edge `e` (possibly given by one of its half-edges
      29             : `h`) can be flipped.
      30             : 
      31             : !!! warning "Precondition"
      32             :     This method **requires a triangle mesh**!
      33             : 
      34             : See also [`flip!`](@ref)
      35             : """ mayflip
      36             : 
      37           4 : function flip!(mesh::Mesh, e::EHnd)
      38           4 :     @massert mayflip(mesh, e)
      39             : 
      40           4 :     a0, b0 = halfedges(mesh, e)
      41             : 
      42           4 :     a1 = next(mesh, a0)
      43           4 :     a2 = next(mesh, a1)
      44             : 
      45           4 :     b1 = next(mesh, b0)
      46           4 :     b2 = next(mesh, b1)
      47             : 
      48           4 :     va0 = destination(mesh, a0)
      49           4 :     va1 = destination(mesh, a1)
      50             : 
      51           4 :     vb0 = destination(mesh, b0)
      52           4 :     vb1 = destination(mesh, b1)
      53             : 
      54           4 :     fa = face(mesh, a0)
      55           4 :     fb = face(mesh, b0)
      56             : 
      57           4 :     _setvertex!(mesh, a0, va1)
      58           4 :     _setvertex!(mesh, b0, vb1)
      59             : 
      60           4 :     _setnexthalfedge!(mesh, a0, a2)
      61           4 :     _setnexthalfedge!(mesh, a2, b1)
      62           4 :     _setnexthalfedge!(mesh, b1, a0)
      63             : 
      64           4 :     _setnexthalfedge!(mesh, b0, b2)
      65           4 :     _setnexthalfedge!(mesh, b2, a1)
      66           4 :     _setnexthalfedge!(mesh, a1, b0)
      67             : 
      68           4 :     _setface!(mesh, a1, fb)
      69           4 :     _setface!(mesh, b1, fa)
      70             : 
      71           4 :     _sethalfedge!(mesh, fa, a0)
      72           4 :     _sethalfedge!(mesh, fb, b0)
      73             : 
      74           4 :     (halfedge(mesh, va0) == b0) && _sethalfedge!(mesh, va0, a1)
      75           4 :     (halfedge(mesh, vb0) == a0) && _sethalfedge!(mesh, vb0, b1)
      76             : end
      77             : 
      78           1 : flip!(mesh::Mesh, h::HHnd) = flip!(mesh, edge(mesh, h))
      79             : 
      80             : """
      81             :     flip!(mesh, e::EHnd)
      82             :     flip!(mesh, h::HHnd)
      83             : 
      84             : Flip edge `e` (possibly given by one of its half-edges `h`) in
      85             : triangulation `mesh`.
      86             : 
      87             : !!! warning "Precondition"
      88             :     This method **requires a triangle mesh**!
      89             : 
      90             : !!! warning "Precondition"
      91             :     Requires `mayflip(mesh, e) == true` immediately before `flip!(mesh, e)`!
      92             : 
      93             : See also [`mayflip`](@ref)
      94             : 
      95             : """ flip!

Generated by: LCOV version 1.16