# The marching-cubes Reference Manual

This is the marching-cubes Reference Manual, version 1.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Jul 15 05:51:46 2024 GMT+0.

## 2 Systems

The main system appears first, followed by any subsystem dependency.

### 2.1 `marching-cubes`

A marching cubes algorithm implementation in Common Lisp based on Paul Bourke’s (http://paulbourke.net/geometry/polygonise/)

Author

Masayuki Takagi

LLGPL

Long Description

# Marching-Cubes

A marching cubes algorithm implementation in Common Lisp based on Paul Bourke’s (http://paulbourke.net/geometry/polygonise/)

## API

### [Function] marching-cubes

MARCHING-CUBES density-function min-position max-position delta isolevel => triangles

Extracts a surface from density field represented with ‘density-function‘ and returns ‘triangles‘ which is a list of triangles. ‘density-function‘ is a function that takes three arguments representing the position of a point and returns density as a scalar at the point. ‘min-position‘ and ‘max-position‘ are ‘vec3‘ values and specify the minimun point and the maximun point of a grid to be processed. ‘delta‘ is a scalar that specifies the size of a cell in a grid to be processed. ‘isolevel‘ is a scalar that specifies the threshold of mesh construction.

### [Function] marching-cubes-smooth

MARCHING-CUBES-SMOOTH density-function normal-function min-position max-position delta isolevel => smooth-triangles

Same as ‘marching-cubes‘ except that ‘marching-cubes-smooth‘ returns a list of smooth triangles which have normal vectors at each vertex. ‘normal-function‘ is a function that takes three arguments representing the position of a point and returns a normal vector at the point. Other arguments are same as ‘marching-cubes‘’s.

## Example

See example/ directory.

## Author

* Masayuki Takagi (kamonama@gmail.com)

Copyright (c) 2012 Masayuki Takagi (kamonama@gmail.com)

Version

1.0

Source
Child Component

`src` (module).

## 3 Modules

Modules are listed depth-first from the system components tree.

### 3.1 `marching-cubes/src`

Source
Parent Component

`marching-cubes` (system).

Child Components

## 4 Files

Files are sorted by type and then listed depth-first from the systems components trees.

### 4.1 Lisp

#### 4.1.1 `marching-cubes/marching-cubes.asd`

Source
Parent Component

`marching-cubes` (system).

ASDF Systems
Packages

#### 4.1.2 `marching-cubes/src/package.lisp`

Source
Parent Component

`src` (module).

Packages

#### 4.1.3 `marching-cubes/src/tables.lisp`

Dependency

`package.lisp` (file).

Source
Parent Component

`src` (module).

Internals

#### 4.1.4 `marching-cubes/src/marching-cubes.lisp`

Dependency

`tables.lisp` (file).

Source
Parent Component

`src` (module).

Public Interface
Internals

## 5 Packages

Packages are listed by definition order.

### 5.1 `marching-cubes-asd`

Source
Use List
• `asdf/interface`.
• `common-lisp`.

### 5.2 `marching-cubes`

Source
Use List

`common-lisp`.

Public Interface
Internals

## 6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.

### 6.1 Public Interface

#### 6.1.1 Macros

Macro: smooth-triangle-normal (tri i)
Package
Source
Macro: smooth-triangle-vertex (tri i)
Package
Source
Macro: triangle-vertex (tri i)
Package
Source

#### 6.1.2 Ordinary functions

Function: make-smooth-triangle (vertex-0 normal-0 vertex-1 normal-1 vertex-2 normal-2)
Package
Source
Function: make-triangle (vertex-0 vertex-1 vertex-2)
Package
Source
Function: make-vec3 (x y z)
Package
Source
Function: marching-cubes (fn min max delta isolevel)
Package
Source
Function: marching-cubes-smooth (fn-value fn-normal min max delta isolevel)
Package
Source
Function: normalize-vec3 (v)
Package
Source
Function: smooth-triangle= (a b)
Package
Source
Function: triangle= (a b)
Package
Source
Package
Source
Target Slot
Package
Source
Target Slot
Package
Source
Target Slot
Function: vec3= (a b)
Package
Source

### 6.2 Internals

#### 6.2.1 Special variables

Special Variable: *vertex-offsets*
Package
Source
Special Variable: +edge-table+
Package
Source
Special Variable: +tri-table+
Package
Source

#### 6.2.2 Macros

Macro: grid-cell-value (grid i)
Package
Source
Macro: grid-cell-vertex (grid i)
Package
Source
Macro: inc-logior (x val)
Package
Source

#### 6.2.3 Ordinary functions

Function: copy-grid (instance)
Package
Source
Function: copy-grid-cell (instance)
Package
Source
Function: copy-smooth-triangle (instance)
Package
Source
Function: copy-triangle (instance)
Package
Source
Function: copy-vec3 (instance)
Package
Source
Function: degenerate-triangle (tri)
Package
Source
Function: grid-cell (grid i j k)
Package
Source
Function: grid-cell-p (object)
Package
Source
Function: grid-cell-values (grid i j k)
Package
Source
Writer: (setf grid-cell-values%) (instance)
Package
Source
Target Slot
Function: grid-cell-vertices (grid i j k)
Package
Source
Writer: (setf grid-cell-vertices%) (instance)
Package
Source
Target Slot
Writer: (setf grid-delta) (instance)
Package
Source
Target Slot
Writer: (setf grid-max) (instance)
Package
Source
Target Slot
Writer: (setf grid-min) (instance)
Package
Source
Target Slot
Function: grid-p (object)
Package
Source
Function: grid-point (grid i j k)
Package
Source
Writer: (setf grid-size-x) (instance)
Package
Source
Target Slot
Writer: (setf grid-size-y) (instance)
Package
Source
Target Slot
Writer: (setf grid-size-z) (instance)
Package
Source
Target Slot
Function: grid-value (grid i j k)
Package
Source
Writer: (setf grid-values%) (instance)
Package
Source
Target Slot
Function: make-grid (fn min max delta)
Package
Source
Function: make-grid-cell (vertices% values%)
Package
Source
Function: make-grid-values (fn i j k origin delta)
Package
Source
Function: make-raw-grid (min max size-x size-y size-z delta values%)
Package
Source
Function: polygonise (grid isolevel)
Package
Source
Function: reduce-grid (grid fn)
Package
Source
Function: remove-degenerate-triangles (tris)
Package
Source
Package
Source
Target Slot
Package
Source
Target Slot
Package
Source
Target Slot
Function: smooth-triangle-p (object)
Package
Source
Package
Source
Target Slot
Package
Source
Target Slot
Package
Source
Target Slot
Function: to-smooth-triangle (tri fn)
Package
Source
Function: triangle-p (object)
Package
Source
Package
Source
Target Slot
Package
Source
Target Slot
Package
Source
Target Slot
Function: vec3-p (object)
Package
Source
Function: vertex-interop (isolevel p1 p2 val1 val2)
Package
Source

#### 6.2.4 Structures

Structure: grid
Package
Source
Direct superclasses

`structure-object`.

Direct slots
Slot: min
Package

`common-lisp`.

Writers
Slot: max
Package

`common-lisp`.

Writers
Slot: size-x
Writers
Slot: size-y
Writers
Slot: size-z
Writers
Slot: delta
Writers
Slot: values%
Writers
Structure: grid-cell
Package
Source
Direct superclasses

`structure-object`.

Direct slots
Slot: vertices%
Writers
Slot: values%
Writers
Structure: smooth-triangle
Package
Source
Direct superclasses

`structure-object`.

Direct slots
Slot: vertex-0
Writers

Slot: normal-0
Writers

Slot: vertex-1
Writers

Slot: normal-1
Writers

Slot: vertex-2
Writers

Slot: normal-2
Writers

Structure: triangle
Package
Source
Direct superclasses

`structure-object`.

Direct slots
Slot: vertex-0
Writers

Slot: vertex-1
Writers

Slot: vertex-2
Writers

Structure: vec3
Package
Source
Direct superclasses

`structure-object`.

Direct slots
Slot: x
Initform

`0`

Writers

Slot: y
Initform

`0`

`0`