Manipulation

Convention

Methods that manipulate the mesh use the suffix !, e.g., addvertex!.

Add/remove vertices

PMesh.addvertex!Function
v = addvertex!(mesh[, v0])

Add new vertex and return its handle v.

If the optional hint v0::VHnd specifies an unused vertex, reinitialize its attributes and "reuse" it, i.e., return v0.

See also addvertices!

source
PMesh.addvertices!Function
rv = addvertices!(mesh, n)
rv = addvertices!(mesh, values[; attr=Val(:x))

vs = collect(VHnd, rv)      # create Vector{VHnd}
vs = (VHnd(v) for f in rv)  # generate VHnd from Int range

Add n or length(values) vertices and return range of handles to new vertices. Given values are set for vertex attribute attr.

Note

For convenience, addvertices! returns a UnitRange{Int} and not a generator of VHnd, see conversion above.

See also addvertex!

source
PMesh.removevertex!Method
removevertex!(mesh, v::VHnd)

Remove vertex v and any face incident to v.

No effect if v is not used.

source

Add/remove faces

PMesh.addface!Function
f = addface!(mesh, vertices[; fhint])
f = addface!(mesh, v1, v2, v3[, ...; fhint])

Add and link new face spanned by oriented sequence of vertices (VHnd).

If the optional fhint::FHnd is a valid handle to an unused face, this handle will be "reused" as f.

Reusing faces

The current implementation can "reuse" face handles – but not unused half-edges!

Preconditions
  • Face will not generate complex vertices/edges.
  • isused and isboundary for vertices.

Returns face handle FHnd. Returns NoF if the face could not be linked (prints an error message).

See also removeface!

source
PMesh.removeface!Method
removeface!(mesh, f[; remove_isolated_vertices = false])

Unlink and remove face f from mesh. Removing f may leave isolated vertices, which are optionally removed if remove_isolated_vertices==true.

Precondition

Requires isused for f.

See also isisolated, addface!

source

Edge flip

PMesh.flip!Function
flip!(mesh, e::EHnd)
flip!(mesh, h::HHnd)

Flip edge e (possibly given by one of its half-edges h) in triangulation mesh.

Precondition

This method requires a triangle mesh!

Precondition

Requires mayflip(mesh, e) == true immediately before flip!(mesh, e)!

See also mayflip

source
PMesh.mayflipFunction
mayflip(mesh, e::EHnd) :: Bool
mayflip(mesh, h::HHnd) :: Bool

Determine whether edge e (possibly given by one of its half-edges h) can be flipped.

Precondition

This method requires a triangle mesh!

See also flip!

source

Face split and edge split

PMesh.split!Function
hs, vs  = split!(mesh, e::EHnd[, v::VHnd = NoV])

Split edge e adding vertex v.

Procondition

This method requires a triangle mesh!

The method returns the new half-edge hs and vertex vs at which the edge was split.

  • If v == NoV, a new vertex vs is created.
  • If !isused(mesh, v), the vertex v is "reused", i.e., vs == v.
  • Otherwise v must be an isolated vertex, and vs == v.
source
PMesh.split!Function
hs, vs  = split!(mesh, h::HHnd[, v::VHnd = NoV])

Split edge given by h, similar to

split!(mesh, edge(mesh, h), v)

but return as hs the half-edge with the same orientation as h. This makes a difference if h != first(halfedges(e))

See also halfedges

source
PMesh.split!Function
vcenter = split!(mesh, f::FHnd[, v::VHnd = NoV])

Split face f by adding vertex v and connecting each of its edges to v. The face f remains valid and becomes a triangle, and degree(mesh, f)-1 new triangles are created. If f is a triangle, this is a 1:3-split. The method returns the vertex vcenter at which f or e is split.

  • If v == NoV, a new vertex vcenter is created.
  • If !isused(mesh, v), the vertex v is "reused", i.e., vcenter == v.
  • Otherwise v must be an isolated vertex, and vcenter == v.
source

Edge collapse

PMesh.collapse!Method
collapse!(mesh, h::HHnd)

Apply half-edge collapse such that the source vertex of h is "collapsed into" the destination vertex. This way, the source vertex and one (h isboundary) or two triangles incident to h and associated edges are removed from mesh (i.e, isused yields false).

Precondition

This method requires a triangle mesh!

Precondition

Requires maycollapse(mesh, h) == true immediately before collapse!(mesh, h)!

See also maycollapse

source
PMesh.maycollapseFunction
maycollapse(mesh, h::HHnd) :: Bool

Determine whether half-edge h can be collapsed, i.e., its source vertex is "moved into" its destination vertex.

Precondition

This method requires a triangle mesh!

See also collapse!

source

Add/remove edge

PMesh.insertedge!Function
h = insertedge!(mesh, h0, h1) :: HHnd

Insert edge connecting destinations v0 and v1 of h0 and h1. Returns half-edge from v0 to v1.

Precondition

The half-edges h0 and h1 must be part of the same face, i.e., face(mesh, h0) == face(mesh, h1).

See also removeedge!

source
PMesh.mayremoveedgeFunction
mayremoveedge(mesh, e::EHnd) :: Bool
mayremoveedge(mesh, h::HHnd) :: Bool

Determine whether edge e (possibly given by one of its half-edges h) can be removeedged.

See also removeedge!

source
PMesh.removeedge!Function
removeedge!(mesh, e::EHnd)
removeedge!(mesh, h::HHnd)

Remove edge e (possibly given by one of its half-edges h) and merge its two incident face into one face.

Precondition

The edge e must have two distinct incident faces.

Precondition

Requires mayremove(mesh, e) == true immediately before remove!(mesh, e)!

See also mayremove, insertedge!

source