MeshesDifference: Meshes difference

View source: R/operations.R

MeshesDifferenceR Documentation

Meshes difference

Description

Computes the difference between two meshes.

Usage

MeshesDifference(
  mesh1,
  mesh2,
  clean = FALSE,
  normals = FALSE,
  numbersType = "double"
)

Arguments

mesh1, mesh2

two 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 mesh (merging duplicated vertices, duplicated faces, removing 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
cube1 <- cube3d() # (from the rgl package)
mesh1 <-
  list(vertices = t(cube1[["vb"]][-4L, ]), faces = t(cube1[["ib"]]))

# mesh two: another cube
cube2 <- translate3d( # (from the rgl package)
  cube3d(), 1, 1, 0
)
mesh2 <-
  list(vertices = t(cube2[["vb"]][-4L, ]), faces = t(cube2[["ib"]]))

# compute the difference
differ <- MeshesDifference(mesh1, mesh2)

# plot
rgldiffer <- toRGL(differ)
open3d(windowRect = c(50, 50, 562, 562))
shade3d(cube1, color = "yellow", alpha = 0.2)
shade3d(cube2, color = "cyan", alpha = 0.2)
shade3d(rgldiffer, color = "red")
plotEdges(
  vertices = differ[["vertices"]], edges = differ[["exteriorEdges"]],
  edgesAsTubes = TRUE, verticesAsSpheres = TRUE
)

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