Identifies the unshared edges of a 3D mesh, i.e., edges belonging to only one face.
These edges can be returned either as vertex indices or as a mesh3d object consisting
of the corresponding segments.
Arguments
- mesh
A
mesh3dobject representing the 3D mesh.- malla
Logical. If
TRUE, returns amesh3dobject containing the boundary segments; ifFALSE, returns only the vertex indices forming the boundary edges. Default isFALSE.- simplify
Logical. If
TRUEandmalla = TRUE, simplifies the resulting mesh usingcleanMesh3d_rgl(). Default isTRUE.
Value
If malla = FALSE, a matrix with the vertex indices forming the boundary edges.
If malla = TRUE, a mesh3d object representing the boundary segments.
Details
This function is an adaptation of rgl::getBoundary3d(). Unlike the original version,
which detects boundary edges by finding duplicates in the edge list, this implementation
uses a frequency table (data.table) to count how many times each edge appears in the mesh faces.
Edges that appear only once are considered boundary edges. Additionally, the function
allows returning either the vertex indices of the boundary edges or a mesh3d mesh
of the segments, with an optional additional simplification.
See also
rgl::getBoundary3d(), cleanMesh3d_rgl()
Examples
# Extract the boundary of a cube and visualize it
require(data.table)
#> Loading required package: data.table
# Create a cube and remove two faces
x <- rgl::cube3d(col = "lightblue")
x$ib <- x$ib[, -(1:2)]
# Generate the boundary
b <- getBoundarySegments3(x, malla = TRUE)
# Visualize the mesh and its boundary
rgl::open3d()
rgl::shade3d(x, alpha = 0.2)
rgl::shade3d(b, col = "red", lwd = 2)
3D plot