# Meshes

> They consider me to have sharp and penetrating vision because I see them through the mesh of a sieve.

— Khalil Gibran

Meshes in The GHOUL are generally used by functions from the Bézier Curves library, but the routines are treated here in their own right. They generate meshes on the basis of a set of cross-sections through the desired polyhedron. The generated mesh is then processed by the native OpenSCAD `polyhedron()` function, and turned into a 3D object.

## The routines.

### `CoverMesh()`

`CoverMesh(Polygons, Endcaps=true, Closed=false, Convexity=10)`

- Polygons, array of arrays, an array of 2D polygons, each an array of vertices on a plane transecting the polyhedron.

- Endcaps, Boolean, if true, the ends of the polyhedron will be 'capped'.

- Closed, Boolean, if true, the polyhedron is a 'closed tube' and `CoverMesh()` will connect the start and end polygons.

- Convexity, convexity for the OpenSCAD `polyhedron()` call.

`CoverMesh()` generates a triangular mesh on the basis of a set of cross-sections, i.e., an array of polygons, and calls `polyhedron()` with the vertices and faces of the mesh. The polyhedron can have open ends (both Endcaps and Closed are false), closed ends (Endcaps is true) or it can be 'closed' like a donut (Closed is true and Endcaps is false). If both Endcaps and Closed are true, Endcaps takes precedence.

CoverMesh.scad contains a function that returns the mesh as an array of two arrays `[Vertices,Faces]`, as well as a module that calls `polyhedron()` with the mesh and thus generates the polyhedron directly.

### `QuadSpace()`

`QuadSpace(Polygon,Vertex,VPP,NOV)`

- Polygon, index, current polygon.

- Vertex, index, current vertex.

- VPP, integer, 'Vertices Per Polygon'.

- NOV, integer, '(Total) Number Of Vertices'.

`QuadSpace()` is not a user function. It is used by `CoverMesh()` for generating the triangular mesh. `QuadSpace()` generates two triangular faces in the space between two corresponding vertex-pairs on successive polygons transecting the polyhedron. It’s mentioned here, just because it exists and this documentation aims to be fully comprehensive. QuadSpace.scad is extensively commented, if you want to dig deeper into it’s functionality.