vcgIsosurface: Create Isosurface from 3D-array

View source: R/vcgIsosurface.r

vcgIsosurfaceR Documentation

Create Isosurface from 3D-array

Description

Create Isosurface from 3D-array using Marching Cubes algorithm

Usage

vcgIsosurface(
  vol,
  threshold,
  from = NULL,
  to = NULL,
  spacing = NULL,
  origin = NULL,
  direction = NULL,
  IJK2RAS = diag(c(-1, -1, 1, 1)),
  as.int = FALSE
)

Arguments

vol

an integer valued 3D-array

threshold

threshold for creating the surface

from

numeric: the lower threshold of a range (overrides threshold)

to

numeric: the upper threshold of a range (overrides threshold)

spacing

numeric 3D-vector: specifies the voxel dimensons in x,y,z direction.

origin

numeric 3D-vector: origin of the original data set, will transpose the mesh onto that origin.

direction

a 3x3 direction matrix

IJK2RAS

4x4 IJK2RAS transformation matrix

as.int

logical: if TRUE, the array will be stored as integer (might decrease RAM usage)

Value

returns a triangular mesh of class "mesh3d"

Examples

#this is the example from the package "misc3d"
x <- seq(-2,2,len=50)
g <- expand.grid(x = x, y = x, z = x)
v <- array(g$x^4 + g$y^4 + g$z^4, rep(length(x),3))
storage.mode(v) <- "integer"
## Not run: 
mesh <- vcgIsosurface(v,threshold=10)
require(rgl)
wire3d(mesh)
##now smooth it a little bit
wire3d(vcgSmooth(mesh,"HC",iteration=3),col=3)

## End(Not run)

Rvcg documentation built on Feb. 16, 2023, 5:12 p.m.