Graph connectivity
MeshProcessing.adjacencymatrix
— MethodA = adjacencymatrix(mesh)
Get adjacency matrix.
MeshProcessing.boundaryloops
— Methodloops, indices = boundaryloops(mesh)
Find boundary loops of mesh
.
Returns pair (loops, indices)
:
loops
in a 2 ×n
Array{Int}
of ranges intoindices
with start and stop in first and second row, respectively.n
is the number of boundary loops.indices
is aVector{Int}
with indices of all boundary vertices in order.
loops, b = boundaryloops(mesh, sort=true)
provides the boundary loops
in order of decreasing vertex count.
Example: The vertex indices of the first boundary loop are indices[loops[1,1]:loops[2,1]]
.
See also boundaryvertices
, nboundaryloops
, largestboundaryloop
MeshProcessing.boundaryvertices
— Methodi = boundaryvertices(mesh)
Find all boundary vertices as an unordered Vector{Int}
.
See also boundaryloops
MeshProcessing.connectedcomponent
— Methodi = connectedcomponent(mesh, seed::Int[; A]) ::Vector{Int}
Find one connected component from seed
vertex. If the adjacency matrix is available, it can be passed as A
.
See also connectedcomponents
MeshProcessing.connectedcomponents
— Methodcc, seeds = connectedcomponents(mesh)
Find all connected components:
cc
is aVector{Int}
of length #V which contains the component index for each vertex:extrema(cc) == (1,ncc)
seeds
is aVector{Int}
of lengthncc
which contains seeds forconnectedcomponent(mesh, seed)
.
where ncc == ncomponents(mesh)
and #V is the number of vertices.
Note that each isolated vertex is one component.
See also connectedcomponent
MeshProcessing.disconnectvertices
— Methodpart, ti, rti = disconnectvertices(f, mesh)
Generate a triangulation with all vertices !f(idx)
disconnected.
The disconnected vertices become isolated vertices, i.e., the total number of vertices doesn't change in the output mesh. In fact, the output shares the vertex table with the input mesh
!
Returns (part, ti, rti)
with maps of triangle indices from part
and from mesh
.
MeshProcessing.edges
— Methodfor (i,j) in edges(mesh)
...
end
Generate all edges (i,j)
. Each edge, inner or boundary, is generated once.
MeshProcessing.filterisolatedvertices
— Methodfmesh, rvi, rti = filterisolatedvertices(mesh)
Generate fmesh
with isolatedvertices
removed from mesh
. Calls filtervertices
, which returns (fmesh, rvi, rti)
.
MeshProcessing.filtervertices
— Method fmesh, rvi, rti = filtervertices(f, mesh)
Generate mesh with all vertices !f(idx)
removed.
fmesh
new mesh with filtered verticesrvi
index array of lengthn
with vertex indices infmesh
tvi
index array of lengthm
with triangle indices infmesh
where n, m = size(mesh)
are the size of the input mesh
.
MeshProcessing.hasboundary
— Methodhasboundary(mesh) :: Bool
Does mesh
have a boundary?
Note that isolatedvertices(mesh)
are not boundary!
MeshProcessing.hasisolatedvertices
— Methodhasisolatedvertices(mesh) :: Bool
Does mesh
have isolated vertices?
MeshProcessing.hasmultiplecomponents
— Methodhasmultiplecomponents(mesh) :: Bool
Does the mesh consist of multiple connected components?
See also ncomponents
, hassinglecomponent
MeshProcessing.hassinglecomponent
— Methodhassinglecomponent(mesh) :: Bool
Does the mesh consist of a single connected component?
Note that en empty mesh does not have a (single) component.
See also ncomponents
, hasmultiplecomponents
MeshProcessing.isolatedvertices
— Methodi = isolatedvertices(mesh)
Find all isolated vertices.
MeshProcessing.largestboundaryloop
— Methodi = largestboundaryloop(mesh) :: Vector{Int}
Find the largest boundary loop, i.e., the one with the maximum number of vertices.
See also boundaryloops
, longestboundaryloop
MeshProcessing.longestboundaryloop
— Methodi = longestboundaryloop(mesh)
Find boundary loop with maximum length, returns indices, length
.
See also boundaryloops
, largestboundaryloop
, shortestboundaryloop
MeshProcessing.mergevertices
— Methodmergedmesh, rvi, replace = mergevertices(mesh[; maxdist=0, reldist=true,
isequal=alwaysequal, p = 2)
Generate mesh with (approximately) equal vertices being merged.
maxdist
maximum distance of vertices considered equal; use default if <=0reldist
maximum distance is relative tostd
isequal
additional binary predicate for testing equality (e.g.isapprox
)p
metric: measure distance in p-norm; p ∈ [1,2,Inf]
Returns mergedmesh, rvi, replace
with vertex replacements rvi, replace
: mergevertices
calls replacevertices
with replace
as input and rvi
as output.
replace
contains replacement index for every vertex (including "self-replacements"!)rvi
contains indices in resulting
MeshProcessing.nboundaryloops
— MethodMeshProcessing.ncomponents
— Methodn = ncomponents(mesh)
Compute the number of connected components.
MeshProcessing.pathlength
— Methodlen = pathlength(mesh, idx[; loop=false)
Compute length of path specified by vertex indices idx
.
Close the path if loop==true
: add length of segment from last to first vertex.
MeshProcessing.pathlengths
— Methodlengths = pathlengths(mesh, loops, b[; loop=false])
Compute pathlength
for multiple paths.
The paths are given in the representation (loops, b)
that is returned by boundaryloops
.
MeshProcessing.shortestboundaryloop
— Methodi = shortestboundaryloop(mesh)
Find boundary loop with minimum length, returns indices, length
.
See also longestboundaryloop
MeshProcessing.sortloopsbylength
— Methodloops, b, lengths = sortloopsbylength(mesh, loops, b[; loop=false])
loops, b, lengths = sortloopsbylength(mesh, boundaryloops(mesh)...; loop=true)
Sort loops returned by boundaryloops
by pathlength
.
MeshProcessing.splitcomponents
— Methodparts = splitcomponents(mesh)
Split connected components into multiple meshes parts::Vector{TriMesh}
.
The inverse operation is union
: ∪(splitcomponents(mesh))
→ mesh
.
See also splitcomponentsmapped
MeshProcessing.splitcomponentsmapped
— Methodmparts = splitcomponentsmapped(mesh)
Split connected components into multiple meshes.
The returned array mparts
has entries (part, (i, ri), (ti, rti))
with
part
is aTriMesh
as returned bysplitcomponents
vi, rvi
map vertex indices frompart
(length(vi)==nv(part)
) and to frommesh
(length(rvi)
==nv(mesh)`)ti, tvi
map triangle indices frompart
(length(ti)==mt(part)
) and to frommesh
(length(rti)
==mt(mesh)`)
See also splitcomponents
MeshProcessing.splitcomponentsshared
— Methodparts = splitcomponentsshared(mesh)
Partition mesh into components.
Similar top splitcomponents
but parts *share* vertex table [
positions(mesh)`]. Empty parts refer to isolated verrtices.
The difference to splitcomponents
is calling disconnectvertices
rather than filtervertices
.
MeshProcessing.valencies
— Methodval = valence(mesh) :: Vector{Int}
Compute the valence (degree) for all vertices (handles boundary vertices).
Base.union
— Methodmesh = union(part1, part2, ...)
mesh = part1 ∪ part2 ∪ ...
Merge disjoint components into mesh.
See also splitcomponents
MeshProcessing.fliporientation
— Methodfmesh = fliporientation(mesh)
Flip orientation of all triangles.