Compute Isosurface, a Three Dimension Contour

Share:

Description

Computes a 3D contours or isosurface by the marching cubes algorithm.

Usage

1
2
3
4
computeContour3d(vol, maxvol = max(vol), level,
                 x = 1:dim(vol)[1],
                 y = 1:dim(vol)[2],
                 z = 1:dim(vol)[3], mask)

Arguments

vol

a three dimensional array.

maxvol

maximum of the vol array.

level

The level at which to construct the contour surface.

x,y,z

locations of grid planes at which values in vol are measured.

mask

a function of 3 arguments returning a logical array, a three dimensional logical array, or NULL. If not NULL, only cells for which mask is true at all eight vertices are used in forming the contour.

Details

Uses the marching-cubes algorithm, with adjustments for dealing with face and internal ambiguities, to compute an isosurface. See references for the details. The function contour3d provides a higher-level interface.

Value

A matrix of three columns representing the triangles making up the contour surface. Each row represents a vertex and goups of three rows represent a triangle.

References

Chernyaev E. (1995) Marching Cubes 33: Construction of Topologically Correct Isosurfaces Technical Report CN/95-17, CERN

Lorensen W. and Cline H. (1987) Marching Cubes: A High Resolution 3D Surface Reconstruction Algorithm Computer Graphics vol. 21, no. 4, 163-169

Nielson G. and Hamann B. (1992) The Asymptotic Decider: Resolving the Ambiguity in Marching Cubes Proc. IEEE Visualization 92, 83-91

See Also

contour3d

Examples

1
2
3
4
5
  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))
  con <- computeContour3d(v, max(v), 1)
  drawScene(makeTriangles(con))