Learn R Programming

Rvcg (version 0.12.2)

vcgIsosurface: Create Isosurface from 3D-array

Description

Create Isosurface from 3D-array using Marching Cubes algorithm

Usage

vcgIsosurface(vol, threshold, spacing = NULL, origin = NULL,
  as.int = FALSE)

Arguments

vol
an integer valued 3D-array
threshold
threshold for creating the surface
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.
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

Run this code
#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"
mesh <- vcgIsosurface(v,threshold=10)
require(rgl)
wire3d(mesh)
##now smooth it a little bit
wire3d(vcgSmooth(mesh,"HC",iteration=3),col=3)

Run the code above in your browser using DataLab