MeshesUnion: Meshes union

View source: R/operations.R

MeshesUnionR Documentation

Meshes union

Description

Computes the union of the given meshes.

Usage

MeshesUnion(meshes, clean = FALSE, normals = FALSE, numbersType = "double")

Arguments

meshes

a list of two or more meshes, each being either a rgl mesh, or as a list with (at least) two fields: vertices and faces; the vertices matrix must have the bigq class if numbersType="gmp", otherwise it must be numeric

clean

Boolean, whether to clean the input meshes (merging duplicated vertices, duplicated faces, removed isolated vertices) as well as the output mesh

normals

Boolean, whether to return the per-vertex normals of the output mesh

numbersType

the type of the numbers used in C++ for the computations; must be one of "double", "lazyExact" (a type provided by CGAL for exact computations), or "gmp" (exact computations with rational numbers); of course using exact computations is slower but more accurate

Value

A triangle mesh given as a list with fields vertices, faces, edges, exteriorEdges, gmpvertices if numbersType="gmp", and normals if normals=TRUE.

Examples

library(MeshesOperations)
library(rgl)

# mesh one: a cube
mesh1 <- cube3d() # (from the rgl package)

# mesh two: another cube
mesh2 <- translate3d( # (from the rgl package)
  cube3d(), 1, 1, 1
)

# compute the union
umesh <- MeshesUnion(list(mesh1, mesh2))

# plot
rglumesh <- toRGL(umesh)
open3d(windowRect = c(50, 50, 562, 562))
shade3d(rglumesh, color = "red")
plotEdges(
  vertices = umesh[["vertices"]], edges = umesh[["exteriorEdges"]],
  edgesAsTubes = TRUE, verticesAsSpheres = TRUE
)

stla/MeshesOperations documentation built on Oct. 23, 2022, 8:23 a.m.