# Trait plexus::builder::MeshBuilder

source · [−]```
pub trait MeshBuilder: ClosedInput {
type Builder: SurfaceBuilder<Error = Self::Error, Vertex = Self::Vertex, Facet = Self::Facet>;
type Vertex;
type Facet: Default;
fn surface_with<F, T, E>(&mut self, f: F) -> Result<T, Self::Error>
```

where

Self::Error: From<E>,

F: FnOnce(&mut Self::Builder) -> Result<T, E>;
fn build(self) -> Result<Self::Commit, Self::Error> { ... }
}

## Expand description

Incremental polygonal mesh builder.

This trait exposes types that allow for mesh data structures to be
constructed incrementally from *surfaces* and *facets*. A *surface* is a
collection of vertices and facets connecting those vertices and typically
describes a *manifold*. A *facet* is the connectivity between vertices in a
surface. Facets may also include associated data.

Construction is hierarchical, beginning with a surface and its vertices and
then facets. The association between a surface, its vertices, and facets is
enforced by the API, which accepts functions that operate on increasingly
specific builder types. The `build`

function is used
to complete the construction of a mesh.

Builders may emit errors at any stage and errors depend on the implementation of the builder types (and by extension the details of the underlying data structure).

## Required Associated Types

#### type Builder: SurfaceBuilder<Error = Self::Error, Vertex = Self::Vertex, Facet = Self::Facet>

## Required Methods

Constructs a surface.

The given function is invoked with a `SurfaceBuilder`

, which can be
used to insert vertices and construct facets.

## Provided Methods

Builds the mesh.

The builder is consumed and a mesh with the constructed surfaces and facets is produced.

##### Errors

Returns a latent error if the constructed surfaces and facets are incompatible with the underlying data structure. May return other errors depending on the details of the implementation.