Manipulation
Add/remove vertices
PMesh.addvertex!
— Functionv = 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!
PMesh.addvertices!
— Functionrv = 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
.
For convenience, addvertices!
returns a UnitRange{Int}
and not a generator of VHnd
, see conversion above.
See also addvertex!
PMesh.removevertex!
— Methodremovevertex!(mesh, v::VHnd)
Remove vertex v
and any face incident to v
.
No effect if v
is not used.
Add/remove faces
PMesh.addface!
— Functionf = 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
.
- Face will not generate complex vertices/edges.
isused
andisboundary
for vertices.
Returns face handle FHnd
. Returns NoF
if the face could not be linked (prints an error message).
See also removeface!
PMesh.removeface!
— Methodremoveface!(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
.
Requires isused
for f
.
See also isisolated
, addface!
Edge flip
PMesh.flip!
— Functionflip!(mesh, e::EHnd)
flip!(mesh, h::HHnd)
Flip edge e
(possibly given by one of its half-edges h
) in triangulation mesh
.
See also mayflip
PMesh.mayflip
— Functionmayflip(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.
See also flip!
Face split and edge split
PMesh.split!
— Functionhs, vs = split!(mesh, e::EHnd[, v::VHnd = NoV])
Split edge e
adding vertex v
.
The method returns the new half-edge hs
and vertex vs
at which the edge was split.
- If
v == NoV
, a new vertexvs
is created. - If
!isused(mesh, v)
, the vertexv
is "reused", i.e.,vs == v
. - Otherwise
v
must be an isolated vertex, andvs == v
.
PMesh.split!
— Functionhs, 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
PMesh.split!
— Functionvcenter = 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 vertexvcenter
is created. - If
!isused(mesh, v)
, the vertexv
is "reused", i.e.,vcenter == v
. - Otherwise
v
must be an isolated vertex, andvcenter == v
.
Edge collapse
PMesh.collapse!
— Methodcollapse!(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
).
See also maycollapse
PMesh.maycollapse
— Functionmaycollapse(mesh, h::HHnd) :: Bool
Determine whether half-edge h
can be collapsed, i.e., its source vertex is "moved into" its destination vertex.
See also collapse!
Add/remove edge
PMesh.insertedge!
— Functionh = insertedge!(mesh, h0, h1) :: HHnd
Insert edge connecting destination
s v0
and v1
of h0
and h1
. Returns half-edge from v0
to v1
.
The half-edges h0
and h1
must be part of the same face, i.e., face(mesh, h0) == face(mesh, h1)
.
See also removeedge!
PMesh.mayremoveedge
— Functionmayremoveedge(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!
PMesh.removeedge!
— Functionremoveedge!(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.
See also mayremove
, insertedge!