manifolds
1.0.0Various manifold mesh algorithms
Table of Contents
About Manifolds
This library implements a variety of algorithms for querying and creating triangle meshes.
Since this is a toolkit library, please refer to the symbol index for the available operations and what they do.
Note that the library requires the following format for all mesh data:
Vertices are packed into a single array of a specialised element-type, either single- or double-float, with three consecutive elements describing one vertex.
Faces are triangular only and are also packed into a single array specialised on unsigned-byte 32, with three consecutive elements describing one face in counter-clockwise winding order. The indices are indices of a vertex. Meaning to reach the first element of the vertex in the corresponding vertex array, it must be multiplied by 3.
This format is compact, efficient, and compatible with graphics APIs, allowing for easy sharing between libraries and making it convenient to display.
System Information
Definition Index
-
ORG.SHIRAKUMO.FRAF.MANIFOLDS
No documentation provided.-
EXTERNAL STRUCTURE EDGE
No documentation provided. -
EXTERNAL STRUCTURE EXTENDED-EDGE
No documentation provided. -
EXTERNAL TYPE-DEFINITION F32
Type alias for SINGLE-FLOAT. See F32
-
EXTERNAL TYPE-DEFINITION F64
Type alias for DOUBLE-FLOAT. See F64
-
EXTERNAL TYPE-DEFINITION FACE
Type for a face index. See FACE-ARRAY (type)
-
EXTERNAL TYPE-DEFINITION FACE-ARRAY
Type for a face vertex indices array. Faces are always triangular, meaning a pair of three vertex indices represents a face. The order of the vertices must always be counter-clockwise whenever the normal of the face matters. Each vertex index in the face array describes the index of the vertex, NOT the starting index in the corresponding vertex-array. Meaning in order to reach the first element of the described vertex, the index must first be multiplied by 3. This is an alias for: (SIMPLE-ARRAY (UNSIGNED-BYTE 32) (*))
-
EXTERNAL TYPE-DEFINITION U16
No documentation provided. -
EXTERNAL TYPE-DEFINITION U32
Type alias for (UNSIGNED-BYTE 32) See U32
-
EXTERNAL TYPE-DEFINITION VERTEX
Type for a vertex index. See VERTEX-ARRAY (type)
-
EXTERNAL TYPE-DEFINITION VERTEX-ARRAY
Type for a vertex array. Vertices are always a triplet of X Y Z coordinates. The vertices by themselves represent a point cloud. A FACE-ARRAY is required to build a surface using the vertices. If an element-type argument is given is an alias for: (SIMPLE-ARRAY element-type (*)) Otherwise is an alias for: (OR (SIMPLE-ARRAY SINGLE-FLOAT (*)) (SIMPLE-ARRAY DOUBLE-FLOAT (*)))
-
EXTERNAL FUNCTION 2-MANIFOLD-P
- FACES
- &OPTIONAL
- ADJACENCY
- &REST
Returns true if the face array describes a 2-manifold. FACES must be a FACE-ARRAY. See FACE-ARRAY (type)
-
EXTERNAL FUNCTION BOUNDARY-LENGTH
- VERTICES
- FACES
- &REST
Returns the length of the boundary of the mesh. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See BOUNDARY-LIST See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION BOUNDARY-LIST
- FACES
- &REST
Returns a vector of edges on the boundary of the faces. Each entry in the resulting vector is one edge described by an EXTENDED-EDGE instance with the START and END slots being vertex indices, and the edge pointing from the START to the END. The OPPOSITE slot contains the index of the third vertex of the face to which the edge indicated by START and END belongs. Note that this requires that the FACES describe one coherent shape with only one outside edge. It does not consider multiple edge loops on the faces as separate boundaries. FACES must be a FACE-ARRAY. See FACE-ARRAY (type)
-
EXTERNAL FUNCTION BOUNDING-BOX
- VERTICES
- &REST
Returns the AABB of the point cloud. The AABB is returned as two VEC3s, the first being the center,, and the second being the half-size. VERTICES must be a VERTEX-ARRAY. See VERTEX-ARRAY (type)
-
EXTERNAL FUNCTION BOUNDING-SPHERE
- VERTICES
- &REST
Computes a tight bounding sphere encapsulating the set of vertices. Returns two values, the center of the sphere as a *VEC3 and its radius. The returned types match the input vertex array's element type. See VERTEX-ARRAY (type)
-
EXTERNAL FUNCTION CENTROID
- VERTICES
- FACES
- &REST
Returns the centroid of the mesh. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION CLOSEST-POINT-ON-TRIANGLE
- VERTICES
- FACES
- FACE
- POINT
- &REST
Returns the closest point to POINT that lies on the FACE. FACE must be a FACE. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See FACE (type) See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION CONVEX-VOLUME
- VERTICES
- FACES
- &REST
Returns the volume of the mesh. The mesh must be convex. If it is concave, the result will not be accurate and may fail to compute. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION EDGE
- START
- END
- &REST
No documentation provided. -
EXTERNAL FUNCTION EDGE-LIST
- FACES
- &REST
Returns a vector of bidirectional edges for the described faces. Unlike the half-edge-list, this edge-list does not contain any duplicated edges between any two vertices. Each entry in the resulting vector is one edge described by an EDGE instance with the START and END slots being vertex indices. Note that the actual direction of the edge is not indicated. FACES must be a FACE-ARRAY. See FACE-ARRAY (type) See HALF-EDGE-LIST
-
EXTERNAL FUNCTION END
- INSTANCE
- &REST
No documentation provided. -
EXTERNAL FUNCTION (SETF END)
- VALUE
- INSTANCE
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENSURE-F32
- A
- &REST
Ensure the given vector is an F32-vector. If it is not, returns a fresh vector that is. See F32 (type)
-
EXTERNAL FUNCTION ENSURE-F64
- A
- &REST
Ensure the given vector is an F64-vector. If it is not, returns a fresh vector that is. See F64 (type)
-
EXTERNAL FUNCTION ENSURE-U16
- A
- &REST
No documentation provided. -
EXTERNAL FUNCTION ENSURE-U32
- A
- &REST
Ensure the given vector is an U32-vector. If it is not, returns a fresh vector that is. See U32 (type)
-
EXTERNAL FUNCTION EXTENDED-EDGE
- START
- END
- OPPOSITE
- &REST
No documentation provided. -
EXTERNAL FUNCTION F32
- A
- &REST
Coerce a REAL into a F32. See F32 (type)
-
EXTERNAL FUNCTION F32*
- &REST
- I
- &REST
Construct a F32-vector from arguments. The arguments are automatically coerced to F32 elements. See F32 (type)
-
EXTERNAL FUNCTION F64
- A
- &REST
Coerce a REAL into a F64. See F64 (type)
-
EXTERNAL FUNCTION F64*
- &REST
- I
- &REST
Construct a F64-vector from arguments. The arguments are automatically coerced to F64 elements. See F64 (type)
-
EXTERNAL FUNCTION FACE-ADJACENCY-LIST
- FACES
- &OPTIONAL
- ADJACENCY
- &REST
Returns a vector of adjacent faces for each face. To get the list of adjacent faces for a face, access the element corresponding to the face's index. FACES must be a FACE-ARRAY. See FACE-ARRAY (type)
-
EXTERNAL FUNCTION FACE-AREA
- VERTICES
- FACES
- FACE
- &REST
Returns the area covered by the face. FACE must be a FACE. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See FACE (type) See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION FACE-IN-VOLUME-P
- VERTICES
- FACES
- FACE
- LOCATION
- BSIZE
- &REST
Returns true if the FACE is within the AABB described by LOCATION and BSIZE. LOCATION should be the center of the AABB, and BSIZE the half-size extent of the AABB. FACE must be a FACE. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See FACES-IN-VOLUME See FACE (type) See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION FACE-NORMAL
- VERTICES
- FACES
- FACE
- &REST
Returns the normal vector of the FACE. FACE must be a FACE. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See FACE (type) See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION FACE-NORMALS
- VERTICES
- FACES
- &OPTIONAL
- FACE-NORMALS
- &REST
Returns an array of the normals of all faces. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION FACES-IN-VOLUME
- VERTICES
- FACES
- LOCATION
- BSIZE
- &REST
Returns a vector of all faces that are part of the AABB described by LOCATION and BSIZE. LOCATION should be the center of the AABB, and BSIZE the half-size extent of the AABB. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See FACE-IN-VOLUME-P See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION HALF-EDGE-LIST
- FACES
- &REST
Returns a vector of half edges for the described faces. A half-edge is a directed edge from one vertex of a face to another. Each entry in the array represents a half-edge and contains an EDGE instance with the START and END slots each being vertex indices, and the edge pointing from the START to the END. FACES must be a FACE-ARRAY. See FACE-ARRAY (type) See EDGE-LIST
-
EXTERNAL FUNCTION INTERSECTS-VOLUME-P
- VERTICES
- FACES
- LOCATION
- BSIZE
- &REST
Returns whether the mesh intersects the AABB described by LOCATION and BSIZE. LOCATION should be the center of the AABB, and BSIZE the half-size extent of the AABB. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See FACE-IN-VOLUME-P See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION NORMALIZE
- VERTICES
- INDICES
- &KEY
- THRESHOLD
- CENTER
- SCALE
- ANGLE-THRESHOLD
- &REST
Normalizes the mesh by removing faces with no surface area, and merging vertices that are within a threshold from each other. Returns two values, a fresh VERTICES array and fresh FACES array. The THRESHOLD is the distance threshold below which two vertices are considered the same. You may also optionally pass in a CENTER and SCALE to which the resulting vertices are positioned and scaled prior to normalisation. The ANGLE-THRESHOLD is a separate parameter to determine how obtuse an angle should be for a face to be considered to have no relevant surface and be removed. This may introduce tiny holes and make the meshes no longer manifold. To keep all triangles, set this parameter to zero. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION OPPOSITE
- INSTANCE
- &REST
No documentation provided. -
EXTERNAL FUNCTION (SETF OPPOSITE)
- VALUE
- INSTANCE
- &REST
No documentation provided. -
EXTERNAL FUNCTION RAY-TRIANGLE
- P
- DIR
- A
- B
- C
- &REST
No documentation provided. -
EXTERNAL FUNCTION SEPARATE-MESHES
- VERTICES
- FACES
- &REST
Returns a list of disjoint meshes. Each entry in the list is a CONS of a VERTEX-ARRAY and a FACE-ARRAY that make up the mesh. Each mesh is also disjoint from every other mesh, meaning they do not share any vertices. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION START
- INSTANCE
- &REST
No documentation provided. -
EXTERNAL FUNCTION (SETF START)
- VALUE
- INSTANCE
- &REST
No documentation provided. -
EXTERNAL FUNCTION SURFACE-AREA
- VERTICES
- FACES
- &REST
Returns the total surface area of the mesh. FACES must be a FACE-ARRAY. VERTICES must be a VERTEX-ARRAY. See FACE-AREA See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL FUNCTION TRANSFORM-MESH
- VERTICES
- MATRIX
- &REST
Transforms all vertices of the mesh by the given transform matrix. Returns the modified vertex array. See VERTEX-ARRAY (type) See 3D-MATH:MAT See 3D-MATH:DMAT
-
EXTERNAL FUNCTION TRIANGLE-AREA
- P1
- P2
- P3
- &REST
No documentation provided. -
EXTERNAL FUNCTION U16
- A
- &REST
No documentation provided. -
EXTERNAL FUNCTION U16*
- &REST
- I
- &REST
No documentation provided. -
EXTERNAL FUNCTION U32
- A
- &REST
Coerce a REAL into a U32. See U32 (type)
-
EXTERNAL FUNCTION U32*
- &REST
- I
- &REST
Construct a U32-vector from arguments. The arguments are automatically coerced to U32 elements. See U32 (type)
-
EXTERNAL FUNCTION V
- VERTICES
- I
- &OPTIONAL
- VEC
- &REST
Access a vertex as a vector. The vector matches the element-type of the vertices array. VERTICES must be a VERTEX-ARRAY. See VERTEX-ARRAY (type)
-
EXTERNAL FUNCTION (SETF V)
- V
- VERTICES
- I
- &REST
No documentation provided. -
EXTERNAL FUNCTION VERTEX-ADJACENCY-LIST
- FACES
- &OPTIONAL
- ADJACENCY
- &REST
Returns a vector of adjacent vertices for each vertex. To get the list of adjacent vertices for a vertex, access the element corresponding to the vertex' index. FACES must be a FACE-ARRAY. See FACE-ARRAY (type)
-
EXTERNAL FUNCTION VERTEX-FACES
- FACES
- &OPTIONAL
- VERTEX-FACES
- &REST
Returns a vector of faces bordering each vertex. Each element in the returned array is another vector of face indices for the element's corresponding vector. FACES must be a FACE-ARRAY. See FACE-ARRAY (type)
-
EXTERNAL FUNCTION VERTEX-NORMAL
- VERTICES
- VERTEX
- ADJACENTS
- &REST
Returns the normal vector of the VERTEX with ADJACENTS. You can obtain the ADJACENTS list via VERTEX-ADJACENCY-LIST. The normal is "smooth" based on the surrounding adjacent vertices. See VERTEX-ARRAY (type) See VERTEX (type) See VERTEX-ADJACENCY-LIST
-
EXTERNAL FUNCTION VOXELIZE
- VERTICES
- FACES
- &KEY
- GRID
- &REST
Creates a voxel representation of the given mesh. If FILL-INSIDES is T, the mesh is treated as a filled volume, otherwise as a hollow shell. GRID may be one of the following: INTEGER --- The resolution in each dimension SINGLE-FLOAT --- The approximate size of a voxel cube (X Y Z) --- The resolution of the voxel grid in each dimension ARRAY --- The voxel grid to use. Must be a 3D SIMPLE-ARRAY of element-type BIT. Returns the voxel grid, which is a 3-d array with the indices being DEPTH HEIGHT WIDTH, in that order. Each element is a BIT where 0 means empty space and 1 means occupied. The grid is normalised to be centred around the mesh's centroid and scaled according to its bounding size, which are returned as secondary values. See INTERSECTS-VOLUME-P See VERTEX-ARRAY (type) See FACE-ARRAY (type)
-
EXTERNAL MACRO DO-FACES
- A
- B
- C
- FACES
- &OPTIONAL
- RESULT
- &REST
- &BODY
- BODY
- &REST
Iterate over the faces of a FACE-ARRAY. A B and C are bound to the vertex indices for each face in the FACE-ARRAY. RESULT is evaluated and returned at the end of iteration. FACES must be of type FACE-ARRAY. See FACE-ARRAY (type)
-