Learn R Programming

rTwig (version 1.1.0)

export_mesh: Export Mesh

Description

Exports QSM cylinder mesh using the rgl library

Usage

export_mesh(
  cylinder,
  filename,
  radius = NULL,
  color = NULL,
  palette = NULL,
  facets = 6,
  normals = FALSE
)

Value

A mesh .ply file

Arguments

cylinder

QSM cylinder data frame

filename

File name and path for exporting. The .ply extension is automatically added if not present.

radius

Vector of cylinder radii. Defaults to modified cylinders from the cylinder data frame.

color

Optional cylinder color parameter. Colors must be a single hex color, a vector of hex colors, or a quoted column name. It can also be set to "random" to generate a random solid color, or FALSE to disable color on export. Vectors must have the same length as the cylinder data frame.

palette

Optional color palette for numerical data. Palettes include: viridis, inferno, plasma, magma, cividis, and rainbow.

facets

The number of facets in the polygon cross section. Defaults to 6, but can be increased to improve visual smoothness at the cost of performance and memory.

normals

Option to export normals. Defaults to FALSE, but can be set to TRUE.

Examples

Run this code

## TreeQSM Processing Chain
file <- system.file("extdata/QSM.mat", package = "rTwig")
qsm <- import_qsm(file)
cylinder <- qsm$cylinder
cylinder <- update_cylinders(cylinder)

filename <- tempfile(pattern = "QSM_mesh")
export_mesh(cylinder, filename)

## SimpleForest Processing Chain
file <- system.file("extdata/QSM.csv", package = "rTwig")
cylinder2 <- read.csv(file)
cylinder2 <- update_cylinders(cylinder2)

filename2 <- tempfile(pattern = "QSM_mesh2")
export_mesh(cylinder2, filename2)

## All Parameters

filename3 <- tempfile(pattern = "QSM_mesh3")
export_mesh(
  cylinder = cylinder,
  filename = filename3,
  radius = "UnmodRadius",
  color = "growthLength",
  palette = "viridis"
)

Run the code above in your browser using DataLab