Skip to contents

Exports QSM cylinder mesh using the rgl library

Usage

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

Arguments

cylinder

QSM cylinder data frame

filename

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

radius

Radius column name either quoted or unquoted. Defaults to modified cylinders from the cylinder data frame.

color

Optional cylinder color parameter. Colors must be a single hex color string, a grDevices::colors(), a vector of hex colors, or a quoted/unquoted 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 colourvalues::color_palettes() or a user supplied RGB palette matrix with the length of cylinder. It can also be set to "random" to generate a random palette.

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.

Value

A mesh .ply file

Examples


## TreeQSM Processing Chain
file <- system.file("extdata/QSM.mat", package = "rTwig")
qsm <- import_qsm(file)
#> Importing TreeQSM
cylinder <- qsm$cylinder
cylinder <- update_cylinders(cylinder)
#> Updating Cylinder Ordering
#> Calculating Total Children
#> Building Cylinder Network
#> Caching Network
#> Verifying Topology
#> Calculating Growth Length
#> Calculating Reverse Branch Order
#> Calculating Branch Segments
#> Calculating Alternate Branch Numbers
#> Calculating Path Metrics

filename <- tempfile(pattern = "TreeQSM_mesh")
export_mesh(cylinder, filename)
#> Exporting Mesh

## SimpleForest Processing Chain
file <- system.file("extdata/QSM.csv", package = "rTwig")
cylinder <- read.csv(file)
cylinder <- update_cylinders(cylinder)
#> Finding Branches
#> Calculating Total Children
#> Building Cylinder Network
#> Caching Network
#> Verifying Topology
#> Calculating Path Metrics

filename <- tempfile(pattern = "SimpleForest_mesh")
export_mesh(cylinder, filename)
#> Exporting Mesh