mesh.components.RdCompute subsets of vertices and triangles in an inla.mesh object that are connected by edges.
inla.mesh.components(mesh)A list with elements vertex and triangle, vectors of
integer labels for which connected component they belong, and info,
a data.frame with columns
Connected component integer label.
The number of vertices in the component.
The number of triangles in the component.
The surface area associated with the component. Component lables are not comparable across different meshes, but some ordering stability is guaranteed by initiating each component from the lowest numbered triangle whenever a new component is initiated.
inla.mesh.2d, inla.mesh.create
# Construct two simple meshes:
loc <- matrix(c(0,1,0,1), 2, 2)
mesh1 <- inla.mesh.2d(loc = loc, max.edge=0.1)
#> Warning: error in running command
#> Error in fmesher.read(prefix, "manifold"): File '/tmp/RtmpB7Z7ym/fmesher9c6e6d201635.manifold' does not exist.
bnd <- inla.nonconvex.hull(loc, 0.3)
#> Error in inla.has_PROJ6(): inla.require("rgdal") is not TRUE
mesh2 <- inla.mesh.2d(boundary = bnd, max.edge=0.1)
#> Error: object 'bnd' not found
# Compute connectivity information:
conn1 <- inla.mesh.components(mesh1)
#> Error: object 'mesh1' not found
conn2 <- inla.mesh.components(mesh2)
#> Error: object 'mesh2' not found
# One component, simply connected mesh
conn1$info
#> Error: object 'conn1' not found
# Two disconnected components
conn2$info
#> Error: object 'conn2' not found
# Extract the subset mesh for the largest component:
# (Note: some information is lost, such as fixed segments,
# and boundary edge labels.)
maxi <- conn2$info$component[which.max(conn2$info$area)]
#> Error: object 'conn2' not found
mesh3 <- inla.mesh.create(loc = mesh2$loc,
tv = mesh2$graph$tv[conn2$triangle == maxi,,drop=FALSE])
#> Error: object 'mesh2' not found